フィルターのクリア

Segmenting Colors in an RBG image

1 回表示 (過去 30 日間)
Kate Heinzman
Kate Heinzman 2020 年 2 月 12 日
編集済み: KSSV 2020 年 2 月 13 日
I originally used color segmentation using kmeans clustering to try to isolate the specific cell colors I'm trying to get out of the code.
My code looks like this:
i
mage = imread('cells.jpg');
image = image(:,:,1:3);
% Convert image from rbg to L*a*b* color space
lab_image = rgb2lab(image);
%% K-Means Clustering
% Since the color information exists in the 'a*b*' color space,
% your objects are pixels with 'a*' and 'b*' values.
ab = lab_image(:,:,2:3);
% Convert the data to data type single for use with imsegkmeans.
ab = im2single(ab);
pixel_labels = imsegkmeans(ab,2);
% For every object in your input, imsegkmeans returns an index, or a label,
% corresponding to a cluster.
% Using pixel_labels, you can separate objects in image by color
mask1 = pixel_labels == 1;
cluster1 = Ki67 .* uint8(mask1);
imshow(cluster1,[]);
cluster_mask = bwareaopen(cluster1,300); %removing noise pixels
noise_cluster = Ki67 .* uint8(cluster_mask);
imshow(noise_cluster);
imshowpair(cluster1,noise_cluster,'montage');
The image above is the original image. The image below is what I get after using the code. I only want the dark brown cells, so how do I isolate the dark brown cells? Also if you know how to be able to count the dark brown cells once they're isolated that would be great.

回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by