フィルターのクリア

Segmentation & confusion matrix for colored image; matrix dimensions must agree.

1 回表示 (過去 30 日間)
bayoishola20
bayoishola20 2014 年 9 月 22 日
回答済み: Nurudeen Ayanleye Yusuff 2018 年 7 月 22 日
Pls I'm having issues getting my confusion matrix done. Below are all code-files and picture '1.jpg' is NOT a monochrome image. On plotting the confusion matrix, it keeps giving me
'matrix dimensions must agree'
thank u for the quick response.
  2 件のコメント
Sreeja Banerjee
Sreeja Banerjee 2014 年 9 月 29 日
I see that your code requires the file '1.jpg' in order to execute. Could you please attach the file so that I can try to reproduce the error?
bayoishola20
bayoishola20 2014 年 10 月 2 日

okay! Thank you so much, here is the file

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

回答 (2 件)

Ping-Chang Shih
Ping-Chang Shih 2014 年 9 月 29 日
Given that the input image is not a monochrome image, all elements in your "segmented_images" cell array have three dimensions. However, the polygonal ROI image you create (stored as variable "BW_1") has two dimensions. Plugging the two types of variables into the MATLAB "confusion" function causes an error since the two arguments are expected to have the same number of dimensions.
The above conclusion is obtained from my interpretation of your code. If I misunderstood your code, please let me know.
  3 件のコメント
Image Analyst
Image Analyst 2014 年 10 月 10 日
Are you still having trouble? If so, post your latest code.
bayoishola20
bayoishola20 2014 年 10 月 10 日
編集済み: bayoishola20 2014 年 10 月 10 日
Yes I am.
For image segmentation.
he= imread('C:\Users\ISHOLA\Desktop\1.jpg');
imshow(he), title('ORIGINAL IMAGE');
cform = makecform('srgb2lab');
lab_he = applycform(he,cform);
ab = double(lab_he(:,:,2:3));
nrows = size(ab,1);
ncols = size(ab,2);
disp(nrows);
disp(ncols);
ab = reshape(ab,nrows*ncols,2);
nColors = 6;
[cluster_idx cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean','replicates',6);
pixel_labels = reshape(cluster_idx,nrows,ncols);
%figure, imshow(pixel_labels,[]), title('image labeled by cluster index');
segmented_images = cell(1,3);
rgb_label = repmat(pixel_labels,[1 3]);
for k = 1:nColors
color = he;
color(rgb_label ~= k) = 0;
segmented_images{k} = color;
end
For dataset training;
%training of classes
imshow(he);
%Training of class 1
BW_1=roipoly(he);
%Training of class 2
BW_2=roipoly(he);
%Training of class 3
BW_3=roipoly(he);
%Training of class 4
BW_4=roipoly(he);
%Training of class 5
BW_5=roipoly(he);
%Training of class 6
BW_6=roipoly(he);
On the aspect of the confusion Matrix, I don't really know how to put it although I know that "pixel_labels" is what I need from the segmentation done. I tried this for instance and it tells me
'Index exceeds matrix dimensions.'
confusionMatrix(r,c)=confusionMatrix(pixel_labels==1,BW_1) +1;
But how to get it right to plot the confusion matrix is what I don't still understand. Thank you.

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


Nurudeen Ayanleye Yusuff
Nurudeen Ayanleye Yusuff 2018 年 7 月 22 日
please i need code for ISODATA which i will implement in my GUI i created. Also i need how to code accuracy assessment for classified image using kmean of unsupervised classification

Community Treasure Hunt

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

Start Hunting!

Translated by