- Binary image which are either 1 or 0, black or white. For an image of size 128 x 128 pixels, each pixel occupies 1 bit, so 128 x 128 = 2048bytes or 2KB.
- Grayscale image which contain 8 bits of information. That is, their pixel value can span the range between 0-255. Since it contains 8 bits of information, each pixel occupies 1 byte, for an image of 128x128 pixels = 16384 bytes or 16KB.
- Truecolor image is equivalent to 3 grayscale images called channels. Truecolor images are also know as RGB because each R, G, B represent the 3 different channels of the image (red, green and blue). Per pixel, there are 256^3 possible combination of information. Most colored photos, i.e, taken using digital cameras are RGB.
- Indexed images are color images that contain index numbers mapped to a color map. Thus, they contain two data, the colormap and image. They are generally smaller in file size compared to RGB but less color information because the maximum colors it can contain are indicated in the colormap.
JPEG images of Lena obtained from this source [1]. Note of the difference in file size between the different image file types: Truecolor (RgB), grayscale and binary (black and white).
File Properties: RGB (72.4KB) Grayscale (26KB) Black and white (5KB) Index(31.6KB)
*(http://www.ee.columbia.edu/~cylin/course/mss/MSS_hw1.html)
In the next part, we are going to apply what we learned in activity 2 by obtaining the area of a scanned image. I would like to acknowledge Mark Jayson 'master' Villangca for lending me his scanned image for this activity. In order to check if our area calculation is correct, a ruler was placed side by side with the image. We can then obtain a pixel:physical unit calibration to obtain the true area of the image.
FileSize: 208681
Format: PNG
Width: 905
Height: 446
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
XResolution: 59.050000
YResolution: 59.050000
Format: PNG
Width: 905
Height: 446
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
XResolution: 59.050000
YResolution: 59.050000
In order to obtain the area of the image above, we need to binarize the image using im2bw. In doing this, we need to select the correct threshold using the histogram of the image.
Histogram of the above image using my own code for histogram below,
function histogram = fhistogram(img, depth)
bits=(2^depth)-1;
histogram = zeros(bits,2);
bins = 0.5:bits; bins = bins./bits; //bins for [0,1] image.
for i=1:bits,
frequency(i) = sum(img>=(bins(i)-1/(2*bits))&img<(bins(i)+1/(2*bits))); end; histogram(:,1)=bins'; histogram(:,2)=frequency; endfunction
From the histogram we can choose a suitable threshold (i.e, ~ pixel value of 100). Using im2bw, we can then set the threshold (since 0-1, divide 100 by 255) and specify the ROI in the image by defining another matrix. In the above image, we opted to remove the ruler in the thresholding and focused on the image.
Histogram of the above image using my own code for histogram below,
function histogram = fhistogram(img, depth)
bits=(2^depth)-1;
histogram = zeros(bits,2);
bins = 0.5:bits; bins = bins./bits; //bins for [0,1] image.
for i=1:bits,
frequency(i) = sum(img>=(bins(i)-1/(2*bits))&img<(bins(i)+1/(2*bits))); end; histogram(:,1)=bins'; histogram(:,2)=frequency; endfunction
From the histogram we can choose a suitable threshold (i.e, ~ pixel value of 100). Using im2bw, we can then set the threshold (since 0-1, divide 100 by 255) and specify the ROI in the image by defining another matrix. In the above image, we opted to remove the ruler in the thresholding and focused on the image.
Resulting image after converting to binary and applying a region of interest
After using the contour follow, we obtain the contour of the image.
[2] http://www.ee.columbia.edu/~cylin/course/mss/MSS_hw1.htmlAfter using the contour follow, we obtain the contour of the image.
Using the algorithm in activity 2, we obtain the following results
Area of master = 16576 pixels.
Pixel count = 16894 pixels.
Observe the converted binary image has extra white pixels outside the contour 'master'.
In order to calibrate this to physical units we can obtain the pixel:physical ratio using paint. (i.e., we obtained 1cm:30pixels ~ ). Thus the area of the contour in physical units is
Area = 552.533 cm^2.
For this activity I give myself a grade of 9 for finishing the activity although a bit late and additional bonus for providing my own code for the histogram.
I would like to acknowledge Mark Jayson Villangca for lending me the scanned image. Jica and Miguel for useful discussions.
References:
[1] Activity 3 manual.
Area of master = 16576 pixels.
Pixel count = 16894 pixels.
Observe the converted binary image has extra white pixels outside the contour 'master'.
In order to calibrate this to physical units we can obtain the pixel:physical ratio using paint. (i.e., we obtained 1cm:30pixels ~ ). Thus the area of the contour in physical units is
Area = 552.533 cm^2.
For this activity I give myself a grade of 9 for finishing the activity although a bit late and additional bonus for providing my own code for the histogram.
I would like to acknowledge Mark Jayson Villangca for lending me the scanned image. Jica and Miguel for useful discussions.
References:
[1] Activity 3 manual.