Saturday, July 4, 2009

Activity 3 Image Types and Basic Image Enhancements

Isn't it surprising to discover how much we don't know about things we commonly use or encounter; just like in this activity for example. I am sure that most of us, if not all of us, are already aware of the different image or picture formats that are recognized by our personal computers. But to be honest I don't really know the difference between these formats or even how they are interpreted by our machines. In this activity I learned that there are just a few basic types of digital images. The simplest is that of a binary images which is suitable for black and white images since it can only store a single bit of information per pixel; ones or zeros, black or white. Next would be a grayscale image which commonly has 8bits of information, meaning it has 256 different gray values between black and white. The third are RGB images or true color images that stores about 3 times the information than a grayscale image, a value each for Red, Green, Blue. This image format imitates how are eyes interpret color as different combinations of Red, Green, and Blue. Finally there are the indexed images which are also colored images like the RGB. But instead of storing informations for the RGB channels an indexed image stores the image as index in a colormap. Hence it stores only 2 information; the image and its color map. As I gather the various image formats that we are more familiar with such as jpg, gif, png, tiff, etc. are just different ways of handling the these image types. Examples of these images are presented at the end of this post.

Also in this activity we employ the skills we obtained in Activities 1 and 2 to calculate the area of a real scanned image. For this activity I opted to create my own picture by writing my name on a piece of paper and scanning it with a ruler to give an idea of the actual size of the image. The resulting image is shown bellow together with its information obtained using the function imfinfo(). I drew a green rectangle over the scanned image to indicate my designated region of interest.

Original Scanned Image with Indication of the Region of Interest

FileName: miguel.bmp
FileSize: 372262
Format: BMP
Width: 834
Height: 444
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter

XResolution: 59.060000
YResolution: 59.060000
Size: 444 rows X 834 columns
Indexed Image

Just like in activity 2 I needed to convert this image to a binary black and white image in order for me to utilize the same algorithm in calculating the are. So to determine what the adequate threshold should be I made an algorithm to obtain the histogram or Probability Distribution Function of gray values for this image. As seen below, the resulting histogram is dominated by
//create histogram or PDF
hist = zeros([1:256]);
for i = 1:256,
hist(i)=sum(name==i);
end
hist = hist/total; //noramlize
the black background, which is expected by simply looking at the picture. The only light colored regions in the image are the ruler and my name. These areas are clearly indicated in the histogram, encircled by the green highlight, and are completely separated from the background. Using the information provided by the histogram I selected a suitable threshold indicated by the dashed red line.

To be able to calculate the area accurately I separated the ruler from my region of interest before I converted it to a binary image. This was simply done by selecting the range with in the image matrix that you are interested with. After this we are now ready to calculate the area of my name.
ROI = name((10:444),(85:820));
ROI = im2bw(ROI, 0.5);


Binary Image of the Region of Interest
Boundary of the Region for Area Calculation

By using the same algorithm used in Activity 2, I calculated the area of this image to be 56,140 pixels. Since we also scanned a ruler beside the image we can use the skills we employed in Activity 1 to estimate the actual physical area occupied by my name. Doing the same method of calibration as in Activity 1, I calculated that the calibration is 1mm/5.9 pixels or 1pixel = 0.169492 mm. From these calibration we can say that 1x1 pixel has an are of 0.028727 square mm. So the total area of my name is 56,140pixel x 0.028727 square mm/pixel =1612.755 square mm or 16.13 square cm. This is probably not a 100% calculation of area since we can see from the image that there are some black pixels inside my name. Also there can be an error introduced when the image was scanned which would affect the calibration. Still I believe that the combination of these 2 errors is very minimal.


Overall I think this was a fruitful activity. I was able to combine the things I previously learned in Activities 1 and 2. I think I deserve a pretty high grade for this one, maybe a 9 or a 10 plus a bonus since I was able to make my own histogram. Hahaha!

Binary Image


Grayscale Image


Indexed Image


True Color Images

No comments:

Post a Comment