フィルターのクリア

Why i dont see my image after pca analysis?

1 回表示 (過去 30 日間)
Hydro
Hydro 2014 年 11 月 11 日
回答済み: Brendan Hamm 2015 年 4 月 6 日
Hello, I am working on an image to reduce its size without comprising much on the quality. i gound the first 300 eigenvectors are the most significant and i process my image based on those. below is my coding. when i try to plot it i get only grey color screen. any thought on fixing it will be appreciated highly.
>> I=imread('abc.jpg');
>> I2 = im2double(I);
>> II=I2(:,:,1);
>> [coeff,score,latent] = pca(II);
>> Me=mean(II);
>> plot(0:2847,[0;cumsum(latent)/sum(latent)],'-ob');
>> plot(0:400,[0;cumsum(latent(1:400))/sum(latent)],'-ob');
>> C300=coeff(:,300);
>> S300=score(:,300);
>> Z300=C300*S300';
>> Z300=Z300';
>> MM=repmat(Me,2848,1);
>> Z300M=Z300+MM;
>> Z300mu=uint8(Z300M);
>> image(repmat(Z300mu,1,1,3))

回答 (3 件)

Image Analyst
Image Analyst 2014 年 12 月 24 日
What is the range of Z300mu and what is its data type? Try using imshow() with the [] option, instead of image().

Chris Jademan
Chris Jademan 2015 年 4 月 3 日
Hello Hydro, I have just applied the code you had given and there is an error.
Error in CompressImage (line 4) [coeff,score,latent] = pca(II);
What should I do to fix it ?
  1 件のコメント
Image Analyst
Image Analyst 2015 年 4 月 3 日
Give the complete error (ALL the red text), not just the line of code.

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


Brendan Hamm
Brendan Hamm 2015 年 4 月 6 日
So the fact that you have an indexing:
II=I2(:,:,1);
implies that II is a m-by-n-by-1 array (3-dimensional array). The pca function expects a m-by-n matrix. You can achieve this with the squeeze function:
II = squeeze(I2(:,:,1));
which will remove the singleton dimension of your 3-d array, then the pca function should work.

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by