Monday, June 22, 2009

Activity 3 - Image types

In this activity, different types of images are being discussed namely binary, grayscale, indexed and true color images. Their properties are being discussed and sample types of images are presented.

Below is a binary image.
FileName: 6_m_airpistol.bmp
FileSize: 237882
Format: BMP
Width: 1481
Height: 1265
Depth: 8
StorageType: indexed
NumberOfColors: 2
ResolutionUnit: centimeter
XResolution: 62.990000
YResolution: 62.990000
http://www.louiscandell.com/pdf/targets/6_m_airpistol.BMP
Below is a grayscale image.
FileName: gray parrot.png
FileSize: 29342
Format: PNG
Width: 150
Height: 200
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 72.000000
YResolution: 72.000000
http://en.wikipedia.org/wiki/File:Grayscale_8bits_palette_sample_image.png
Below is a true color image.
FileName: pahiyas.jpg
FileSize: 27871
Format: JPEG
Width: 400
Height: 300
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: inch
XResolution: 160.000000
YResolution: 160.000000
Below is an indexed image
FileName: indexed.gif
FileSize: 16029
Format: GIF
Width: 155
Height: 148
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 72.000000
YResolution: 72.000000
http://www.devx.com/projectcool/article/19997/0/page/8

CODE:

imfinfo('6_m_airpistol.bmp', 'verbose');
imfinfo('pahiyas.jpg', 'verbose');
imfinfo('gray parrot.png', 'verbose')
imfinfo('indexed.gif', 'verbose');

bw = imread('circle.bmp');
gr = imread('gray parrot.png');
in = imread('indexed.gif');
tc = imread('pahiyas.jpg');


Binary images are easy to find in the net since they are images with pixel values of 1 or 0. They are commonly known as black and white images. Also when presented in scilab, they are those with only 2 number of colors. Grayscale images are those images with 256 number of colors and of one layer only unlike truecolor images where they have 3 color channels for red, green and blue. That's why truecolor images are referred to as RGB images. I am not so sure with regards to indexed images since they are somewhat similar with grayscale images although they have additional stored information -- colormap value. Pixel values are based (ranges) only to some colormap values.

I give myself 9 points for taking all images of different types and also obtaining important information although i am not so sure with the indexed image sample.

References:
http://docs.gimp.org/2.2/en/gimp-images-in.html
http://www.mathworks.com/access/helpdesk/help/toolbox/images/index.html?
A3 – Image types and basic image enhancement -- manual

ROI extension


FileName: circles.bmp

FileSize: 179874

Format: BMP

Width: 324

Height: 185

Depth: 8

StorageType: truecolor

NumberOfColors: 0

ResolutionUnit: centimeter

XResolution: 37.800000

YResolution: 37.800000



FileName: circles_gray.bmp

FileSize: 61018

Format: BMP

Width: 324

Height: 185

Depth: 8

StorageType: indexed

NumberOfColors: 256

ResolutionUnit: centimeter

XResolution: 37.800000

YResolution: 37.800000



//histogram

x = imread('circles_gray.bmp');

mx = max(x);

sz = size(x,1)*size(x,2);

h = [];

for i = 1:mx

f = find(x == i);

h(i) = length(f);

end

scf(); plot2d(h/sz) // histogram plot


Looking at the histogram, it can be noticed that each colored circle has a distinct gray value (ROI’s) and the white background can be easily separated from the ROI’s through proper thresholding. We then convert the image to binary image and select first the ROI with the lowest gray value up to the highest gray value ROI. The following code and set of images demonstrates how I did it. Separating the objects of interest can be done using proper histogram thresholding.



//blue

xb = im2bw(x,0.12);

scf(); imshow(abs(xb-1), 2);

//blue and red

xbr = im2bw(x, 0.22);

scf(); imshow(abs(xbr-1), 2);

//red

scf(); imshow(xr-xbr, 2);

//blue, red, violet

xbrv = im2bw(x, 0.3);

scf(); imshow(abs(xbrv-1), 2);

//violet

scf(); imshow(xbr-xbrv, 2);

//blue, red, violet, green

xbrvg = im2bw(x, 0.8);

scf(); imshow(abs(xbrvg-1), 2);

//green

scf(); imshow(xbrv-xbrvg, 2);

//blue, red, violet, green, yellow

xbrvgy = im2bw(x, 0.94);

scf(); imshow(abs(xbrvgy-1), 2);

//yellow

scf(); imshow(xbrvg-xbrvgy, 2);


Since the sum of the individual color’s analytic area matches with all colors, then it must be correct. Also, the obtained total individual color’s area using Green’s is comparable with all color’s area. Thus, the validity of the code is exemplified with less than 1% error.


0 comments:

Post a Comment

Followers