how to extract mean colour
1 次查看(过去 30 天)
显示 更早的评论
I have a image and code
HSV = rgb2hsv(I);
H = HSV(:,:,1); H = H(:);
S = HSV(:,:,2); S = S(:);
V = HSV(:,:,3); V = V(:);
idx = kmeans([H S V], 3);
cluster_idx=idx;
pixel_labels = reshape(cluster_idx,size(I,1),size(I,2));
figure,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:3
color = I;
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 2');
for each segmented image i want to compute mean colur
plz assist
2 个评论
采纳的回答
Walter Roberson
2013-3-22
Z = zeros(size(pixel_labels));
T = double(pixel_labels == 1);
segmented_image{1} = cat(3, T, Z, Z);
T = double(pixel_labels == 2);
segmented_image{2} = cat(3, Z, T, Z);
T = double(pixel_labels == 3);
segmented_image{3} = cat(3, Z, Z, T);
7 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!