%Read image
im = im2double(imread('1.png'));
%Convert RGB to GRAY via PCA
lab = rgb2lab(im);
f = 0;
wlab = reshape(bsxfun(@times,cat(3,1-f,f/2,f/2),lab),[],3);
[C,S] = pca(wlab);
S = reshape(S,size(lab));
S = S(:,:,1);
gray = (S-min(S(:)))./(max(S(:))-min(S(:)));
These error occurs when I try to run the code...
Error using images.color.ColorConverter/convert (line 218)
Mismatch between input size and the expected number of input color
components.
Error in images.color.ColorConverter/evaluate (line 364)
out = convert(self, in);
Error in images.color.internal.Callable/subsref (line 15)
[varargout{1:nargout}] = self.evaluate(s(1).subs{:});
Error in rgb2lab (line 65)
lab = converter(rgb);
Error in PCA1 (line 8)
lab = rgb2lab(im);
Can anyone explain to me why? I don't quite understand the error...

 採用された回答

KSSV
KSSV 2018 年 6 月 1 日

0 投票

YOur image happens to be a gray image....I mean it is only 1D pixel data. If your image were color image i.e RGB image, then no error will pop out. Check your image. Give RGB image as input.

3 件のコメント

athirahlan
athirahlan 2018 年 6 月 1 日
I did try the RGB images, as you said no error occurs.
My actual input image is from a mammographic images, I did try with other mammpographic image and it works, It just not works with my mammographic images...
Thank you so much, your answer helps me understands the error much better
KSSV
KSSV 2018 年 6 月 1 日
Check the dimensions of working images and non-working images.
Stephen23
Stephen23 2018 年 6 月 1 日

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

質問済み:

2018 年 6 月 1 日

コメント済み:

2018 年 6 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by