Borrar filtros
Borrar filtros

Segmenting Colors in an RBG image

1 visualización (últimos 30 días)
Kate Heinzman
Kate Heinzman el 12 de Feb. de 2020
Editada: KSSV el 13 de Feb. de 2020
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.

Respuestas (0)

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by