How to distinguish different color cells in the image?

1 次查看(过去 30 天)
I have an image with two different color cells like below shows
and I need to claasify it and count how much cells like below shows red and yellow
how can I do that?
I have tried edge detection but it seems doesnt work.

采纳的回答

Image Analyst
Image Analyst 2021-6-23
They don't look very different to me. I'd try the Color Thresholder on the Apps tab of the tool ribbon. Try HSV and RGB color spaces and see if you can get differentiation.
  2 个评论
larry liu
larry liu 2021-6-23
if I got the image like this, then how can I count the number of circles?
Image Analyst
Image Analyst 2021-6-23
You can first get rid of the grid with imclearborder(). That might get rid of some blobs that are connected to it though. If you don't want to lose them, then don't use a grid.
Then you can find round particles by looking at their circularity.
mask = imclearborder(mask); % Get rid of grid and blobs touching it.
mask = imfill(mask, 'holes');
props = regionprops(mask, 'BoundingBox', 'Area', 'Perimeter');
bb = vertcat(props.BoundingBox);
widths = bb(:, 3);
heights = bb(:, 4);
aspectRatios = widths ./ heights;
allAreas = [props.Area];
allPerimeters = [props.Perimeter];
circularities = allPerimeters .^ 2 ./ (4 * pi * allAreas);
% Get indexes of blobs where aspect ratio is less than about 3 and
% circularities less than about 5. Adjsut as needed.
keeperIndexes = (circularities < 5) & ...
(aspectRatios < 3) & ...
(1./aspectRatios < 3)
[labeledImage, numInitialBlobs] = bwlabel(mask);
fprintf('Before shape filtering, found %d blobs.\n', numInitialBlobs);
mask = ismember(labeledImage, find(keeperIndexes));
imshow(mask);
% Remeasure with the filtered set of blobs.
props = regionprops(mask, 'BoundingBox', 'Area', 'Perimeter');
numFinalBlobs = length(props);
fprintf('After filtering, found %d blobs.\n', numFinalBlobs);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by