Image segmentation & confusion matrix
显示 更早的评论
I've trained six(6) classes of features & performed image segmentation but trying to ascertain the accuracy of this, but it keeps telling me 'matrix dimension must agree' among the run error. Below is my segmentation code as well as roi.
he= imread('C:\Users\ISHOLA\Desktop\1.jpg'); imshow(he), title('ORIGINAL IMAGE'); text(size(he,2),size(he,1)+15,... 'Vellore,Tamilnadu,India', ... 'FontSize',7,'HorizontalAlignment','right'); 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; % repeat the clustering 3 times to avoid local minima [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
ROI;
BW_1=roipoly(he);%for class 1
But on running this for the confusion matrix, it doesn't work [c,cm,ind,per] = confusion(BW_1,segmented_images{1});
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 k-Means and k-Medoids Clustering 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!