How can i implement this code?

6 ビュー (過去 30 日間)
Tomas
Tomas 2012 年 10 月 17 日
Hi
I'm looking for a matlab code which estimates the two principal directions (axes) using principal components analysis (PCA)?? Then any an other algorithm can be applied to estimate the asymmetry of the region of image in terms of the two principal axis. I tried several times to implement it and I looked everywhere to no avail. Now I ask my question on this forum hoping to get the right answer. thanks

回答 (3 件)

Sachin Ganjare
Sachin Ganjare 2012 年 10 月 17 日
  1 件のコメント
Tomas
Tomas 2012 年 10 月 17 日
thank you for this link. I visited it but since I'm a beginner in matlab I have not got to use these concepts to draw the axes of the region in the segmented image and estimate the asymmetry.

サインインしてコメントする。


Tomas
Tomas 2012 年 10 月 17 日
編集済み: Tomas 2012 年 10 月 18 日
I tried to do this code but i need your help please
I2=segmentation(I);
[n m] = size(I2);
AMean = mean(I2);
co=I2*I2'; % Compute the covariance matrix (co)
% Compute the eigen values and eigen vectors of the covariance matrix
[eigvector,eigvl]=eig(co);
eigvalue = diag(eigvl);
pc = eigvector * I2;
plot(pc(1,:),pc(2,:))
  2 件のコメント
Matt Kindig
Matt Kindig 2012 年 10 月 18 日
What is your question? What about this code doesn't work?
Tomas
Tomas 2012 年 10 月 18 日
Hi
I'm looking for a matlab code which estimates the two principal directions (axes) using principal components analysis (PCA)?? Then any an other algorithm can be applied to estimate the asymmetry of the region of interest of the segmented image in terms of the two principal axis. I tried to do this code but it doesn't work so i need your help.

サインインしてコメントする。


Tomas
Tomas 2012 年 10 月 18 日
編集済み: Tomas 2012 年 10 月 18 日
Hi, Can any one please correct this code
A=imread('aeroplane silhouette.png');
bw=~im2bw(A,0.5); %Threshold and invert
subplot(1,2,1), imshow(bw,[]);
[y,x]=find(bw>0.5); %Get coordinates of non zero pixels
centroid=mean([x y]); %Get (centroid) of data
hold on; plot(centroid(1),centroid(2),'rd'); %Plot shape centroid
C=cov([x y]); %Calculate covariance of coordinates
[U,S]=eig(C)
m=U(2,1)./U(1,1);
const=centroid(2)/m.*centroid(1);
xl=50:450; yl=m.*xl+const
subplot(1,2,2), imshow(bw,[]); h=line(xl,yl); %Display image and axes
set(h,'Color',[1 0 0],'LineWidth',2.0)
m2=U(2,2)./U(1,2);
const=centroid(2)/m2.*centroid(1);
x2=50:450; y2=m2.*x2+const
h=line(x2,y2);
set(h,'Color',[1 0 0], 'LineWidth',2.0)
you find the images here
  2 件のコメント
Matt Kindig
Matt Kindig 2012 年 10 月 18 日
Before asking us to correct the code, you should tell us what's wrong with the code. From the second image, it seems that the gray lines lie along what I would expect to be the principal components.
Tomas
Tomas 2012 年 10 月 18 日
These image explained what i should to do but this code didn't plot the two axes

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by