Saturday, October 4, 2008

A19 – Probabilistic Classification

In this activity we try to classify objects into classes using Linear Discriminant Analysis (LDA). A detailed discussion was given by Dr. Sheila Marcos in the pdf file given by Dr. Maricor Soriano.
We used two classes from the previous activity. I used the quail eggs class and the squid balls class. I already obtained its features from the previous activity. The features I chose were the mean of normalized r and g value as well as the product of their standard deviation. The features are shown below for the two classes.



Using this set of data I calculated the covariance matrix in scilab using the process described in the pdf file. The covariance matrix calculated is shown below.



Then using this covariance matrix we calculate for the discriminant values using scilab. The results are shown below.



We see that the classification was 100% accurate which means the we were successful in employin LDA to our given data.

I give myself a grade of 10 for this activity since I have achieved a good result using LDA. No one helped me in this activity. I think this is one of the easiest activity.

chdir('D:\Mer\Documents\Majors\AP186\A19\');
vector=[];
for j=1:8
img = imread("k"+string(j)+".jpg");

i = (img(:, :, 1) + img(:, :, 2) + img(:, :, 3));
r = img(:, :, 1)./i;
g = img(:, :, 2)./i;
b = img(:, :, 3)./i;

mnr=mean(r);
mng=mean(g);
str=stdev(r);
stg=stdev(g);
strg=str*stg;


k(j,:)=[mnr,mng,strg];
end

uk=[mean(k(:,1)),mean(k(:,2)),mean(k(:,3))];

for j=1:8
img = imread("sq"+string(j)+".jpg");

i = (img(:, :, 1) + img(:, :, 2) + img(:, :, 3));
r = img(:, :, 1)./i;
g = img(:, :, 2)./i;
b = img(:, :, 3)./i;

mnr=mean(r);
mng=mean(g);
str=stdev(r);
stg=stdev(g);
strg=str*stg;


s(j,:)=[mnr,mng,strg];
end

us=[mean(s(:,1)),mean(s(:,2)),mean(s(:,3))];
u=uk*8+us*8;
u=u/16;
xk=[];
xs=[];

for j=1:8
xk(j,:)=k(j,:)-u;
xs(j,:)=s(j,:)-u;
end

ck=(xk'*xk)/8;
cs=(xs'*xs)/8;
C=.5*(ck+cs);
Ci=inv(C);
kk=uk*Ci*k'-0.5*uk*Ci*uk'+log(0.5);
ks=us*Ci*k'-0.5*us*Ci*us'+log(0.5);

sk=uk*Ci*s'-0.5*uk*Ci*uk'+log(0.5);
ss=us*Ci*s'-0.5*us*Ci*us'+log(0.5);

No comments: