MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Segmenatation for an image.

Asked by mecheal on 22 Jul 2013

how can i segment and count the number of non overlapping blood cells in this image :

http://i39.tinypic.com/2nw0guw.gif

i need a code for doing this...

## Products

Answer by Image Analyst on 22 Jul 2013

First of all, look over my image segmentation demo. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Then look at how I filter out coins based on size. You need to do the same thing. If they overlap the size will be a lot bigger than if they don't overlap. So you just need to tweak the area value in my code and it should work for you.

Matt Kindig on 23 Jul 2013

I'll let you figure out how to determine the overlapping cells, but to get you started, let's take a look at the area of each cell, i.e.,

```Centroids = cat(1, s.Centroid);
Area = cat(1, s.Area);
figure();
%draw circles whose color is proportional to cell area
scatter( Centroids(:,1), Centroids(:,2), Area, Area, 'filled');
colormap jet, colorbar, hold on;
title('Area of each region');
```

The color of each circle is proportional to the area of that region (see the colorbar on the right side of the plot-- this gives the area->color relationship).

Note that some of the cells have markedly higher areas than the others. Can you figure out how to threshold out these areas?

mecheal on 23 Jul 2013

great idea MR. matt ,, but i ran ur code , there was a small problem , u count a overlapped cells , i just want u to modify ur code to just count the UNOVERLAPPED CELLS ,,,WITH GREAT REGARDS,,,

Matt Kindig on 23 Jul 2013

See my comment immediately above. In general, I think it will be easier to count all cells (overlapped and non-overlapped alike), and remove the overlapping ones.

To identify the overlapping ones, you can (as Image Analyst stated) use an area criterion, removing all identified cells that exceed some threshold area. In my code above, I showed you how to visualize the areas of the various regions. I'll let you implement the logic about how to identify the overlapping cells.

Detecting and counting objects with circular features: http://imageprocessingblog.com/detecting-and-counting-objects-with-circular-features/