
First, the image is cut up into 9 256x256 images using GIMP to save memory. On the assumption that all the sub-images have the same PDF and CDF, the histogram of one is processed to find the threshold for the next step, and fix the contrast if neccessary.
(The program used is simply that used in activity 4)
Next, in a loop where each sub-image is processed then analyzed individually before returning the final result (thanks to jeric's help with the strcat() function); the following program:
stacksize(4e7);
pre='cir';
counter=1;
for i=1:9
im=imread(strcat([pre,string(i),'.jpg']));
imb=im2bw(im,0.79);
//imshow(imb,[]);
se=[0 1 0; 1 1 1; 0 1 0];
//se=ones(2,2);
dil=dilate(imb,se,[1,1]);
ero=erode(dil,se,[1,1]);
//imshow(ero,[]);
//se1=[0 1 0; 1 1 1; 0 1 0];
se1=ones(3,3);
ero1=erode(ero,se1,[1,1]);
dil1=dilate(ero1,se1,[1,1]);
//imshow(im,[]);
[L,n]=bwlabel(dil1);
for j=1:n
area(counter)=length(find(L==j));
counter=counter+1;
end
end
scf(10);
histplot(length(area),area);
x=find(area<600>400);
scf(11) histplot(length(x), area(x));
a=area(x);
a=sum(a)/length(x) //area
y=stdev(area(x)) //error
i.e.





...this last gives the considered histogram range:

From the process used, to the obtained histogram and standard deviation value, this is a reasonable estimate. Sources of error are possibly the truncation of a few image details when the image was converted to binary before the opening and closing, and the slight distortion of the circles caused by the choice of structural element/s.
**i give myself a grade of 10 for this activity because the objective was achieved and the obtained final values were quite plausible, not to mention the extra effort benj and i put in initially to enhance the images to separate the stubborn circles. if i actually get that done, i might put that up here as an update.
*thank you to benj,mark leo, jeric
EDIT: for some reason this was saved as a draft while just my initial program from last week was published,i didn't even notice until just now. problem fixed, every picture once again painstakingly uploaded, actual report posted.
No comments:
Post a Comment