Monday, August 11, 2008

Activity 9 :Binary Operations

The activity's objective is to find the best estimate of the cell area. Using GIMP, the image above was cropped into 9 parts measuring 256 x 256 pixels. The subimages were then converted to black & white by finding the threshold of the images.
With the code below, the closing and opening operators were used to clean the image of isolated pixels andcells very near each other.
//img = imread("G:\to be posted\186_09\C1_01_bw.jpg");

//img = imread("G:\to be posted\186_09\C1_02_thresh205.jpg");
//img = imread ("G:\to be posted\186_09\C1_03_thresh223.jpg");
//img = imread ("G:\to be posted\186_09\C1_04_thresh194.jpg");
//img = imread ("G:\to be posted\186_09\C1_05_thresh190.jpg");
//img = imread ("G:\to be posted\186_09\C1_06_thresh215.jpg");
//img = imread ("G:\to be posted\186_09\C1_07_thresh200.jpg");
//img = imread ("G:\to be posted\186_09\C1_08_thresh194.jpg");
img = imread ("G:\to be posted\186_09\C1_09_thresh213.jpg");
imgray = im2gray(img);
mat = size(img);
pic = imgray;for i = 1:mat(1) //rows
for j = 1:mat(2) //columns
if pic(i,j) <>
pic(i,j) = 0;
else
pic(i,j) = 1;
end
end
end

SE = [];for i = 1:4 for j =1:4 SE(i,j) = 1; end end
img_co = erode(dilate(pic,SE),SE);

//img_co = dilate(erode(pic,SE),SE);
scf(1);
imshow (img_co4);
imwrite (img_co4, 'G:\to be posted\186_09\C1_09_co.jpg');

After cleaning the images, each blob was then labelled and the area of each was measured.

//labellingimg = imread ("G:\to be posted\186_09\C1_09_co.jpg");
imgray = im2gray (img);pic = imgray;
mat = size(pic);
for x = 1:mat(1);
for y = 1:mat(2);
if pic (x, y) <>
pic (x, y) = 0;
else
pic (x, y) = 1;
end
end
end[L, n] = bwlabel(pic);
scf(3);
imshow(pic, []);
scf(4);
imshow (L+1,rand(n+1,3));

//area
for i = 1: max(bwlabel(pic))
v = find(L == i);
w = size(v);
area(i) = w(2);
end

The following images show the blobs binarized, cleaned, and labelled.



With the use of Microsoft Excel, the histogram was plotted. The values used were in the range of 400 to 700. mean = 498.2 ; standard deviation = 55.19

No comments: