Image types are dime a dozen now a days. Different types of images have plagued the word compared to the simple film and prints method of the olden days. With the boom of the internet, compression seemed to be the word to look out for. While the increase in digital single-lens reflex (dslr) cameras has put the retention of data at the forefront.
So, as video and image processers, we need to understand how each image type is formed and how it is read by the computer.
For starters, we examine a few image types and how they look as a matrix. There four basic image types, Binary, Grayscale, Truecolor and Indexed images. These for images will vary in terms of matrix size and how they interpret the data inside the matrix.
Binary images are very simple. They contain only zeros and ones. Usually, black is equal to zero and white is equal to white. Binary images will have a matrix size of MxNx1. Some of the file formats that support binary images are text documents, Monochromatic BMP files, etc.
Grayscale images are just 1 step ahead of binary images. Grayscale images have the same matrix size as that of binary images. But each pixel will have a higher bit depth. Most grayscale images will range in values from 0 to 255. These values will create a gradient from black to white as the values move from 0 to 255. This saves a little more detail for the user while still maintaining compression.
JPEG images are the most common example of Indexed images. Indexed images are composed of two important parts. The first is the data or matrix of the image and the second is the color map. The matrix is of size MxNx1 and contains values from 0 to 255. The color map is a list of colors that corresponds to certain values in the image matrix. Your computer then translates the image matrix values into a True Color image using the color map provided. This increases the compression, while retaining color. One limitation of indexed images is that it has a limited number of colors, a maximum of 256. The makers of JPEG knew this problem, but utilized the ability of our brains to process color. Since most people have difficulty differentiating colors, they were able to reduce the number of colors needed to show an image.
Finally, True Color images are the biggest in terms of size. These images provide color detail of the picture. Matrix size will now be MxNx3 where the 3 corresponds to the Red, Blue and Green color intensities. This file type is the largest but is the most comprehensive in terms of data retention.
Unfortunately, Blogger doesn't support some of the image formats in my collection so i wont be able to post these images. But we can discuss then anyway. One common file format used is the bitmap format or .bmp. This is a common output of of Windows operating systems. BMP formats supports all four image types depending on the bit depth set.
Another file format is the Tagged Image File Format or .tiff. This image format is very popular with Apple Macintosh owners. This also supports all four image types.
The most common image format today is the Joint Photographic Experts Group or .jpg. This image format is an indexed image. This allows compression of the data while still maintaining the color detail of the image.
Now let us see how we can manipulate these images using Scilab.
First, let us look into converting indexed images and true color images into binary and gray scale images. We look at figure 1 which is a picture of the CS Lantern School Year 2009-2010. We can utilize this image with its different colors to see the effect of converting color into black and white or gray scale.
Figure 1: CS Lantern SY 2009-2010
We now convert the image to binary using the im2bw function of Scilab. Here, we can adjust the threshold at which Scilab will consider a pixel as 1 or 0. We can now iterate the code for different values of threshold, from 0.2 - 0.8 (figures 2-5).
Figure 2: CS Lantern Binary with Threshold of 0.2
Figure 3: CS Lantern Binary with Threshold of 0.4
Figure 4: CS Lantern Binary with Threshold of 0.6
Figure 5: CS Lantern Binary with Threshold of 0.8
We can see in figure 1 that the boundaries of the color pattern on the lantern is clearly defined, but the hand prints on the base became blurred. This problem was solved by increasing the threshold to 0.4, but the color boundaries this time blurred. As we increase further, we can no longer see the outline of the image.
Figure 6: Lantern in Gray Scale
Comparatively, we can see increase in detail retention when using the gray scale function of Scilab, im2gray. Though some colors look the same, we can see a slight difference in gray-ness of the colors. Also, details in the base is clearly defined. We can see the superiority in terms of data retention of the gray scale versus binary. But we can see a greater file size for the gray scale with 218 KB versus the 21 KB of the binary type.
We now look at how we can benefit from these methods as researchers. Here we try to clean up a photocopied graph by converting it to binary type image. We can see that by photocopying a graph, dark spots occur due to the limitations of the equipment. So to be able to present this graph to a proper journal, it needs to be cleaned up. What we can do is convert the image into binary (since the image is really supposed to be black and white anyway) and adjust the threshold to eliminate the dark spots.
Figure 7: Original Graph
Figure 8: Graph in Binary with 0.1 Threshold
Figure 9: Graph in Binary with 0.5 Threshold
Figure 10: Graph in Binary with 0.9 Threshold
We can see from the iterations above, using a low threshold, we can eliminate most of the dirt on the image. Comparatively, we can see that the dark spot on the right of the image is reduced drastically.
We can see the usefulness of the methods employed in this activity. For this activity, I give myself a score of 9. Though I finished the activity and managed to compare the effects of thresholding on the image, I submitted late and must be punished.
I would like to thank Melissa Dy of the 09-10 College of Science Student Council for the picture of the CS Lantern. And Androphil Polinar and Arvin Mabilangan for their comments on style of the presentation.
No comments:
Post a Comment