Wednesday, August 26, 2009

A14 Pattern Recognition

PROCEDURE:
1. Trials
Pattern recognition by way of shape classification was implemented in this activity where I took an image full of various shapes(Fig.1a),convert it to black and white after thresholding, and took the edges of each shape, then labeled each shape and computed its perimeter by bwlabel and tabul.

a.original imageb. bw of the original im


c. thind. skeleton

Figure1.

Figure 2. Took the edge this time
Figure 3. Barplot of each shape tagged from 1-30 and its corresponding perimeter.

From Figure 3, the tally of the shapes are :DEW: 8,HEART: 5, petal :6, circle :10, leaf:1 and these results agree with the number of occurrence of those patterns in Figure 1,2. :)


2. Minimum Distance Classification
Applying this,we captured an image of 2 kinds(2 class) of chips and extracted the best features of the objects. After obtaining these features I separated them in half as training feature and test features.For each class, I computed mean feature vector mj and which I then used to classify the remaining test features. The one with the minimum distance was used determining which class an object belonged to. Afterward, the percent error of the classifier was then computed.

The original image (Fig4)has these vertical that I cannot remove using fft so I just used Gimp to remove it.Then I converted the image to grayscale then to bw after thresholding. I used dilation and erosion to finally clean the image. Here they are(Fig5).
I then extracted the following features:

1. AREA1 from the vertical and horizontal length of each chip,

hor=[];ver=[];this=1;

for i=2:n

[x,y]=find(L==i); hor(this)=max(y)-min(y); ver(this)=max(x)-min(x);

area1=ver.*hor; this=this+1;

end

area1



2. AREA from the length of the bwlabel(L,n) then the are itself by area=tabul(L,"i")


3. the perimeter using edge of the bwlabel(L,n) then the are itself by perimeter=tabul(L,"i")


4. ratio of area /perimeter by (area./perimeter)


5. rgb component of each chip by

r=im1(:,:,1);g=im1(:,:,2);b=im1(:,:,3);red=[];blue=[];green=[];

this=1;for i=1:n

[x,y]=find(L==i);

//at that chip lang

red(this)=mean(r(x));

green(this)=mean(g(x));

blue(this)=mean(b(x));

this=this+1;

end

//lhat ng chip

red

green

blue


After obtaining these features I separated them in half as training feature and test features.For each class, I computed mean feature vector mj and which I then used to classify the remaining test features. The one with the minimum distance was used determinining which class an object belonged to. Afterwards, the percent error of the classifier was then computed.


Fig 4 Image of the chips :), cheeseit and pillows

Fig 5 After removing the lines, graycaling, converting to bw, dilation and erosion .
From here got the area from the vertical*horizontal line running across each chip and area from the sum(pixels)

Fig 6 Got the perimeter from the edges.
Table1: Summary of the extracted features.

Table 2. Summary of the data after Minimum Distance Classification. In the classification I just used area1, area,perimeter, and area/perimeter in the classification(para madali).

SOURCE: A14 Pattern Recognition Manual

ASSESSMENT: 10/10 because I implemented my idea of using of using only bwlabel and tabul in getting the features from areas to RGB of each sample.I was also able to apply other techniques from the previous activity. Then the classifier was 100% error free in classifying the two chips. (yes:)

No comments:

Post a Comment