V(1,:) = [0.085832 0.17365 0.98106];
Wednesday, August 13, 2008
Activity 13: Photometric Stereo
V(1,:) = [0.085832 0.17365 0.98106];
Monday, August 11, 2008
Activity 11: Camera Calibration
x0 = [0 1 3 0 2 0 0 0 8 3 0 0 0 0 3 8 5 1 6 0];
y0 = [0 0 0 3 0 6 7 3 0 0 8 1 6 8 0 0 0 0 0 2];
z0 = [0 1 4 5 9 11 5 7 0 12 7 10 9 0 6 8 8 10 11 1];
yi = [100 117 154 70 138 37 24 70 243 157 13 92 36 13 154 248 192 120 212 80];
zi = [234 218 163 145 62 26 156 105 251 3 115 41 68 265 123 89 86 41 26 222];for i = 1:20
Q((2*i)+1,:) = [x0(i) y0(i) z0(i) 1 0 0 0 0 -(yi(i)*x0(i)) -(yi(i)*y0(i)) -(yi(i)*z0(i))];
Q((2*i)+2,:) = [0 0 0 0 x0(i) y0(i) z0(i) 1 -(zi(i)*x0(i)) -(zi(i)*y0(i)) -(zi(i)*z0(i))];
d((2*i)+1,:) = [yi(i)];
d((2*i)+2,:) = [zi(i)];
end
Qt = Q'
a = inv(Qt*Q)*Qt*d;
for j = 1:20
y2(j,:) = ((a(1))*x0(j)+(a(2))*y0(j)+(a(3))*z0(j)+a(4))/((a(9))*x0(j)+(a(10))*y0(j)+(a(11))*z0(j)+1);
z2(j,:) = ((a(5))*x0(j)+(a(6))*y0(j)+(a(7))*z0(j)+a(8))/((a(9))*x0(j)+(a(10))*y0(j)+(a(11))*z0(j)+1);
end
The code above used the equation from the manual.
Activity 10: Preprocessing Handwritten Text
img = im2gray(im);
imgfft=fft2(img);
scf (1);
imshow(imgfft);
imwrite (imgfft, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imgray.jpg')
With the use of techniques learned from previous activities, the lines were removed using a filter just like the one below.
filter=imread('C:\Users\nez\Documents\tresloco\ap186_2\activity 10\f.jpg');
imf = im2gray(filter);
imffft=fftshift(imf);
imffft=ff1.*ff2; The image is then convolved with the filter, converted to binary, and cleaned using the closing/opening operator.
//filtering the image
a=real(fft2(imffft));
scf(2)imshow(a,[]);
imwrite (a, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imfilter.jpg')
//binarize the image
b=im2bw(a, 127/255);
c=1-b;
scf(3);imshow(c,[]);
imwrite (c, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imbinary.jpg')
//opening operation
SE = ones(2,2);
d=erode(c,SE);
e=dilate(d,SE)scf(4);
imshow(e,[]);
imwrite (e, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imcloseopen.jpg')
After this is done, the image is then labelled.
//labelling the image
imfinal=bwlabel(e);
scf(5);
imshow(imfinal,[]);
//imwrite (imfinal, 'C:\Users\nez\Documents\tresloco\ap186_2\activity 10\imlabel.jpg')
Activity 9 :Binary Operations
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.