Monday, 17 June 2013

Activity 4 - Image Types and Formats

In digital imaging there are four basics types which consist of:

  • Binary images are characterized by two values, 0 or 1, which represent black or white, respectively. They are used in many processes since they are the most simplest to process. Though they also carry the least image information that they cannot be used all the time. However, they can be used on object identification, object orientation and text interpretation. A simple way in which to obtain a binary image is by thresholding a grayscale image.
    Shown below is an example of binary image of a binary number:
Figure 1. Binary image example [3]

Dimensions : 204 x 204
Width : 204 pixels
Height : 204 pixels
Horizontal Resolution : 96 dpi
Vertical Resolution : 96 dpi
Bit Depth : 24
Item type : jpeg file

  • Grayscale images are images represented in shades of black and white, which range between 0 (black) and 255 (white) in numerical value, where in one pixel is one Byte. The need for a grayscale image is that it requires less information compared to a colored image. A gray image can be achieved in a colored image if rgb components in a pixel have the same values, but in a grayscale image only one pixel value is needed instead of three. Compared to a binary image, a grayscale image offers finer image details through the use of different gray tones.
    One such example of a grayscale image, which was derived from a true color image, is as shown below:
Figure 2. Grayscaled image

Dimensions : 600 x 337
Width : 600 pixels
Height : 337 pixels
Horizontal Resolution : 96 dpi
Vertical Resolution : 96 dpi
Bit Depth : 24
Item type : jpeg file


  • True color images are images which are made up of three bands; one for each of the three primary colors. When the three are combined it is possible to replicate almost all of the colors, this is made possible because the human eye only has three color sensors, one for each of the primary colors. But since each pixel is composed of three bands, it is one of the heaviest images as can be seen on the details describing Figure 3.
Figure 3. True color image taken from an iPhone a year ago

Dimensions : 2048 x 1536                    Resolution unit: 2
Width : 2048 pixels                 Color Representation: sRGB
Height : 1536 pixels              Camera maker : Apple
Horizontal Resolution : 72 dpi              Camera Model : iPhone 3GS
Vertical Resolution : 72 dpi                           F-stop : f/2.8
Bit Depth : 24                          Exposure time: 1/15 sec
Item type : jpeg file              ISO speed : ISO-500
Focal length : 4 mm

  • Indexed images are colored images whose colors are represented by numbers which denote the index of colors in a color map. Colored images makes use of a 24-bit color, but sometimes there is no need to make use of the full 24-bit range. Therefore indexing is used based on a variety of color palettes which can be composed of 8, 24 or 256 colors. The procedure is that the computer makes a list of the 256 most use color values, also called a color map or a color palette.In the past, indexed images were essential when computers were limited to only 256 colors, but up till present it is still used to save on bandwidth and storage space. One disadvantage though is that if an image is given a wrong color palette it is near to impossible to retrieve the original image.

Figure 4. Indexed image (Right) created using a color palette composed of 256 colors based from the original image (Left) [5]

Dimensions : 226 x 200
Width : 226 pixels
Height : 200 pixels
Bit Depth : 8
Item type : png file


There are many ways to identify image properties using Gimp, three of which include changing file format, histogram formation and image cropping, all of which I will implement upon the image shown in Figure 3 and 4.

Figure 5. Converted file (Left) and Cropped Image (Right)

Figure 6. Converted file (Left) and Cropped Image (Right)


Changing an images format is useful since each format offers its own advantages as will be discussed further own into the blog. Cropping on the other hand removes unnecessary details outside the region of interest and can even isolate features needed by the user. Lastly, a histogram plot of the image describes the color distribution along the image, which can be categorized into very dark, dark, medium, light and very light.

From the discussion earlier one can see that an indexed image, binary image and a grayscale image can be produced from a true color image. One has to simply manipulate the pixel values for each of the three color band to achieve this goal. Gimp, example offers a variety of tools with which one can perform the tasks mentioned. Shown in Figure 7 is another true color image used for this process. The image was originally of a larger size but was scaled down to 33% of its original value for easier handling.

Figure 7. True Color image of a Kite used in a ARRAS Fieldwork in the summer of 2012

Dimensions : 1006 x 754
Width : 1006 pixels
Height : 654 pixels
Bit Depth : 24
Item type : PNG
Size : 667kB

In gimp, one can convert this image into grayscale by right-clicking the image and selecting Image -> Mode  -> Grayscale. What happens is that Gimp varies the values along the RGB bands according to a set formula, one can actually perform the grayscale manually by using the channel mixer by going into Image-> Color-> Components -> Channel Mixer and define which percentage of the three bands/channels to use. But an easier way to is to go to Image -> Color -> Components -> Decompose, in this toolbox the user is offered a variety of ways in order to perform grayscale which allow image decomposition into CMYK, HSL, HSV, RGB and others. Decomposing the image into the RGB channel, results in three different grayscales as each channel can be represented in gray values. In Figure 10, note how the RGB channels differ from the default grayscale result. The variation is caused by the information that each channel contains. The red channel contains most of the luminance information as well as most of the noise. The green channel contains the least noise, while the blue channel contains shadow information and noise.

Figure 8. Selecting Grayscale tool



Figure 9. Selecting the Decompose tool

Figure 10. Grayscale result. (Top Left) Default Grayscale Result. Grayscale representation of the RGB channels: Red (Top Right), Green (Bottom Left), Blue (Bottom Right)

A binary image can be formed from a grayscale image or directly from the true color image. Gimp allows this by making use of the images histogram. Going into Image -> Color -> Threshold, a window opens containing a select region of the histogram and the image is converted into binary. Gimp gives a pixel value of 1 or white to the pixels falling into the highlighted histogram range while giving a pixel value of 0 otherwise.

Figure 11. Highlighted region in the histogram can be changed by the user although an autoselect function is available. (Left) Threshold toolbox. (Right) Resulting image derived from the upper left grayscale image in Figure 10.

Finally, the image can be indexed by going into Image -> Mode -> Indexed. Once clicked, a window appears in which the user defines how many colors should be present in the color palette. Using a color palette containing 256 colors, a quick glance shows that indexing did little to add changes in the image.

Figure 12. (Left) Indexed Toolbox window. (Right) Resulting Indexed Image 

Image can be divided into two formats:
  • Lossy image compression, when applied, results in the lost of data and quality from the original file. In images this can be seen in the either the form of jagged edges or pixelation. But because the image is compressed, it is smaller in size compared to the original image. Examples of such an image format includes:
    • GIF - Graphics Interchange format developed by CompuServe. These images are based on indexed images, which consists of a color palette of at most 256 colors. The compression of these images allow for fast transfer over a network though they lack the color range to be used for high-quality photos. This format is usually used for animated images and small icons. 
    • JPEG - stands for "Joint Photographic Experts Group" named after the group which developed the format. This image format is not as limited to its color range like GIF which makes it highly used when compressing photographic images.
  • Lossless image compression allows for the original data to be reconstructed from the compressed data. It is used when even a single pixel is crucial like in medical imaging, clipart and archiving important document. Examples include:
    • PNG - Portable Networks Graphics was created as a replacement for GIF. It is the most used lossless image format and was designed for image transfer in the internet. Thus it is mostly RGB based (binary, grayscale, RGB[A], etc) and can support more than 8-bit RGB. It does not, however, support non-RGB color spaces.
    • TIFF - Tagged Image File Format is used mostly by graphic artists and publishing industry and is controlled by the Adobe systems. It was developed in the mid-1980's to encouraged desktop scanner vendors to use a single format. TIFF began as a binary image but as scanners grew to support higher color palettes TIFF became able to support grayscale and, eventually, colored images. 
    • MNG - Multiple-Image Network Graphics was released in 2001 as an animation version of PNG. 

Lastly, we were instructed to install SIVP in Scilab, but I have already installed the toolbox in the previous meeting so I just went ahead investigated the given functions.

imread and imshow, works hand in hand together. The former, loads an image from the specified file while the latter opens the image in different window. imwrite on the other hand saves the image to the specified format and is oriented as imwrite(data, filename.format)

gray_imread reads the image in the stated profile address into grayscale while im2bw converts an image into binary based on a threshold defined by the user. It is oriented as im2bw(name of image, threshold). This threashold ranges from 0 to 1, pixel values are normalized with respect to the maximum pixel value and those lower then the set threshold is given a pixel value of 0 while 1 otherwise.

histplot plots a histogram of the image according to the number of bins stated by the user. It assumes the form histplot( number of bins, data). Finally, imfinfo shows image information such as those shown in Figure 13.

In this activity, I have done everything that was asked and I felt that I even went beyond the requirement and thus I give myself a grade of 11.

References:
[1] http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT2/node3.html
[2] http://homepages.inf.ed.ac.uk/rbf/HIPR2/gryimage.htm
[3] http://www.omomnia.com/room/binary-art/
[4]http://www.wookmark.com/image/131336/grayscale-pencils-grayscale-pencils-1920x1080-wallpaper-grayscale-wallpapers-free-desktop-wallpapers
[5]http://en.wikipedia.org/wiki/Indexed_color
[6]http://encyclopedia2.thefreedictionary.com/indexed+color
[7]http://www.gimp.org/tutorials/Color2BW/
[8]http://www.techterms.com/definition/gif
[9]http://www.techterms.com/definition/jpeg
[10]http://en.wikipedia.org/wiki/Portable_Network_Graphics
[11]http://en.wikipedia.org/wiki/TIFF
[12]http://www.libpng.org/pub/png/pngfaq.html#animation
[13]http://siptoolbox.sourceforge.net/doc/sip-0.7.0-reference/imfinfo.html

No comments:

Post a Comment