Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Is it possible to separate R portion, G portion, B portion of an RGB image?
1 回表示 (過去 30 日間)
古いコメントを表示
a = imread('eye.jpg');
imshow(a);title('H&E image');
text(size(a,2),size(a,1)+15,...
'Image Courtesy of Alen Partin,Johns Hopkins University',...
'FontSize',7,'HorizontalAlignment','right');
cform = makecform('srgb2lab');
lab_i = applycform(a,cform);
ab = double(lab_i(:,:,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',3);
pixel_labels = reshape(cluster_idx,nrows,ncols);
imshow(pixel_labels,[]),title('image labeled by clusterindex');
segmented_images = cell(1,3);
rgb_label = repmat(pixel_labels,[1 1 3]);
for k = 1:nColors
color = a;
color(rgb_label~=k) = 0;
segmented_images{k} = color;
end
imshow(segmented_images{1}),title('objects in cluster 1');
imshow(segmented_images{2}),title('objects in cluster 2');
If anyone knew some other program like this please post here..:)
1 件のコメント
jonas
2018 年 3 月 1 日
This is the third time I have seen you post this code in the last 24h. I suggest you read up on Imread and how images are described by pixels.
回答 (0 件)
この質問は閉じられています。
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!