Error in srgb2lab for cform
Show older comments
cform = makecform('srgb2lab');
lab_he = applycform(I,cform);
ab = double(lab_he(:,:,2:3));
nrows = size(ab,1);
ncols = size(ab,2);
ab = reshape(ab,nrows*ncols,2);
nColors = 3;
[cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ...
'Replicates',k_val);
pixel_labels = reshape(cluster_idx,nrows,ncols);
segmented_images = cell(1,k_val);
rgb_label = repmat(pixel_labels,[1,1,3]);
for k = 1:nColors
colors = I;
colors(rgb_label ~= k) = 0;
segmented_images{k} = colors;
end
mean_cluster_value = mean(cluster_center,2);
[~, idx] = max(mean_cluster_value);
seg_img = segmented_images{idx};
I am getting error in this code as
Error using applycform (line 62)
Cform structure is invalid for Named Color.
Error in SegmentImage (line 11)
lab_he = applycform(I,cform);
Answers (0)
Categories
Find more on Color in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!