i got error in color based segmentation using K-means?

2 visualizzazioni (ultimi 30 giorni)
error that i got is Error in ==> Untitled3 at 16 [cluster_idx cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean','Replicates',3);
  2 Commenti
Chandra Shekhar
Chandra Shekhar il 28 Mar 2013
post your full code or give link of your program which you used. I need to know how your passing inputs to the function.
Jude Cyrus Simon Anandraj
Jude Cyrus Simon Anandraj il 28 Mar 2013
clc clear all; he = imread('sam.tif'); imshow(he),
cform = makecform('srgb2lab'); lab_he = applycform(he,cform);
ab = double(lab_he(:,:,3)); nrows = size(ab,1); ncols = size(ab,2); ab = reshape(ab,nrows*ncols,1);
nColors = 3;
[cluster_idx cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ... 'Replicates',3);
pixel_labels = reshape(cluster_idx,nrows,ncols); imshow(pixel_labels,[]), title('image labeled by cluster index');
segmented_images = cell(1,3); rgb_label = repmat(pixel_labels,[1 1 3]);
for k = 1:nColors color = he; color(rgb_label ~= k) = 0; segmented_images{k} = color; end
figure;imshow(segmented_images{1}), title('objects in cluster 1');
figure;imshow(segmented_images{2}), title('objects in cluster 2');
figure;imshow(segmented_images{3}), title('objects in cluster 3');

Accedi per commentare.

Risposte (1)

Chandra Shekhar
Chandra Shekhar il 28 Mar 2013

Community Treasure Hunt

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

Start Hunting!

Translated by