Tuesday, June 28, 2011

three

Get your reading glasses on, this is gonna be a long one.

Before I go on and on about what the activity actually made me do, I think it’s only right I give you a (relatively) brief  introduction into the world of digital images – something that I myself went through these past few days. 

First off, there are four basic image types – binary, grayscale, truecolor and indexed images. 

A binary image is – like most computer geeks can tell you – made up of 0’s and 1’s.  In other words, there are only two colors present – black and white.   Grayscale images on the other hand have 256 colors present, albeit all of these colors being various “shades” of gray existing between black and white.  Nevertheless, they are not the same, despite what modern photography tells us.  A good example would be the two images that follow which, at first glance, may seem to belong under the same basic image type.  Using the imfinfo command in Scilab (via SIP Toolbox), we see that the first image contains only 2 colors and the second, 256, characteristics respectively of binary and grayscale images.

binary
info binary
Figure 1. (top) A binary image. (bottom) Image Properties Obtained through imfinfo in Scilab (SIP Toolbox)

grayscale
info grayscale
Figure 2. (top) A grayscale image. (bottom) Image Properties Obtained through imfinfo in Scilab (SIP Toolbox)

Like the preceding basic image types, truecolor and indexed images seem like they’re one and the same.  By definition however, truecolor images are ones with three channels or bands so that each channel is representative of the intensities of the colors red, green and blue within each pixel.  Indexed images, on the other hand basically contain two data sets – the image itself and the color map.  Differentiating the two is easily done using again the same command we employed earlier.

truecolortruecolor info
Figure 3. (top) A truecolor image. (bottom) Image Properties Obtained through imfinfo in Scilab (SIP Toolbox)

indexed
info indexed
Figure 4. (top) An indexed image. (bottom) Image Properties Obtained through imfinfo in Scilab (SIP Toolbox)

The world can’t function with just these four basic image types.  Advances in technology brought on a subsequent leap forward in the types of images available to us.  A few samples of these advanced image types are high dynamic range (HDR), multi or hyperspectral, 3D and temporal images.  HDR images are used to record digital x-rays or bright events while multispectral images are used for satellite images due to greater number of channels that each pixel can hold as compared to truecolor images.  3D images are used to store spatial 3D information and temporal images (otherwise called videos) are, well, images captured and presented together sequentially.

hdr
Figure 5. An example of a high dynamic range (HDR) image

hyperspectral
Figure 6. An example of a multi or hyperspectral image

3d
Figure 7. An example of a 3D image

Figure 8. An example of temporal images or a video

I am aware the quality of the above video isn’t all that great. I included it here because, well, who doesn’t love the mentos and coke experiment?  But if you, like me, had to squint through most of the video, here’s another science-y video dealing with … uhh.. pendulums. *grin*  It’s longer, yes, but the quality is so much better and the content even more so.
 
Figure 9. A much better example of temporal images or a video best viewed in HD

The truecolor image from Figure 3 was converted into grayscale and binary using the code below and from the image sizes, it can be seen that the red, green and blue color channels representative of a truecolor image is no longer present (Figure 10).  Also shown below are the grayscale and binary images that resulted from the conversion.

truecolor_codetruecolor_size
Figure 10. (top) Scilab code used to convert a truecolor image to grayscale and binary and
(bottom) the image sizes of the respective images.

truecolor_gray
truecolor_bw
Figure 11. (top) Resulting grayscale and (bottom) binary image.

Remember the first activity and the lifesaving scanned image that went with it?  Well, the cropped version of that same image makes a cameo in this activity.  The image – which was originally a truecolor image - was first read as a grayscale image whose histogram was then taken.  With the help of Mr. Timothy Joseph Abregana, I was able to realize that the proper threshold value for my image was 0.30 on account of its grainy quality.  All things I deemed important to this part of the activity are shown below

fmc_code
Figure 12. Scilab code used to perform the necessary operations on the scanned image.

fmc_gray
fmc_histplot
Figure 13. (top) Grayscale image of the graph and (bottom) its histograph with 255 divisions.

fmc_bw
Figure 14. Obtained Binary image using a threshold value of 0.3

But then image types aren’t the only important things to note when it comes to images.  File formats are important as well.  Different file formats arose from the realization that better cameras meant better pictures with greater resolution and size.  Images can be compressed either in lossy or lossless compression formats.  Both are appropriately named as lossy image compression results to smaller sized files with certain data missing.  Lossless image compression, on the otherhand. preserved every single pixel information – a trait that makes it beneficial for medical imaging, research or professional purposes.  A variety of image file formats are now available for use, each one with its own history and purpose elaborated on below.

More Common Image File Formats

JPEG (Joint Photographic Expert Group)
This lossy file format saves certain color  information might be saved at a lower resolution especially those which the human eye cannot discern at adjustable compression levels.

TIF (Tagged Image File)
This sometimes-lossy-but-usually-lossless image format store details of the compression as part of the image file itself.  Because no image detail is lost, files of this format are usually large.


PNG (Portable Network Graphic)
This is exclusively a lossless storage format that  looks for patters so it can compress an image and decompress it as well.

BMP (Bitmap)
This is a lossless file format that was invented by Microsoft.


GIF (Graphic Interchange Format)
This is a file format that is selectively lossless – specifically for images with less than 256 colors.  If the image has a greater color number than these, algorithms are used to approximate the other colors.  For images with a lot of colors, up to 99.998% of the colors could be lost.

Other File Formats


RAW
This is an optional lossless file format that is used by cameras.  Because of this, certain camera manufacturers have different software geared towards reading their own RAW file versions.

PSD, PSP, etc.
These are file formats used by image enhancement or modification programs (i.e. Photoshop, etc.) and is normally large due to the layers and other elements that these images contain.  Like RAW files, these files have to be opened using particular programs.

At the end of the day, I have to give myself an 11.  My images are of very good quality and I finished the work on time with little help from others.  The 1 extra point that I gave myself was simply because I did look for other file formats and I went to the effort of uploading videos onto my YouTube account to both provide an example of a video file and to entertain.

REFERENCES:
Applied Physics 186 Image Types and Formats 2010 Manual
IMAGES*
Binary | Grayscale | Truecolor | Indexed | HDR | Hyperspectral | 3D | Temporal – taken from personal archives
*Images presented above have been resized for economy of presentation.  Images used in analysis are of the size in their source links.

No comments:

Post a Comment