How to count blood cells in opencv? The problem is that they stick together.

The example picture :

enter image description here

Maybe pairwise geometric histogram (Geometric Histograms) suitable for matching partial circle shape?

  • $\begingroup$ I suggest you the reading "Microscope Image Processing", from Academic Press. I've heard there is an ebook "circulating" online. $\endgroup$ – heltonbiker Aug 9 '12 at 1:55
  • $\begingroup$ @heltonbiker I didn't find there algorithm for my task just standard watershed algorithm. $\endgroup$ – mrgloom Aug 9 '12 at 6:50
  • $\begingroup$ very similar: dsp.stackexchange.com/q/2516/29 $\endgroup$ – endolith Aug 27 '12 at 21:52
  • $\begingroup$ @endolith but I have not separable blobs. $\endgroup$ – mrgloom Aug 28 '12 at 7:15
  • $\begingroup$ @mrgloom: What? You want to count the individual circles, right? Not the blobs? $\endgroup$ – endolith Aug 28 '12 at 14:28

Just an idea with no guarantee of success:

  1. isolate the red blobs (e.g. mark them as white, the rest of the image as black)
  2. perform a distance transform for the white blobs (every pixel indicates the distance to the nearest black pixel)
  3. perform a non-maxima-suppression (ideally only the centers of the circles remain)
  4. deal with non ideal conditions (filter out small peaks from artifacts)
| improve this answer | |
  • $\begingroup$ looks like watershed algorithm works imagejdocu.tudor.lu/… the problem is that distance map can't handle with objects that are overlap a lot.I think I need to use circle shape somehow. dl.dropbox.com/u/8841028/blood%20cells/watershed.png dl.dropbox.com/u/8841028/blood%20cells/distance_map.png $\endgroup$ – mrgloom Aug 8 '12 at 10:53
  • $\begingroup$ @mrgloom: The "circle" geometry aspect is between steps 2 and 3. For a circle, the point of maximum distance to the edges is the centre. This property holds very well even if circles overlap. You get two maxima for the combined blob. The value of each maximum corresponds to the corresponding radius, so that's one easy check in step 4: draw the circles that you expect, and measure the overlap between the circle and the blood cell. $\endgroup$ – MSalters Aug 13 '12 at 13:41

Similarly to @SalemMansour's suggestion it is also an area based approach.

A really rough estimation can be calculated if we can assume

  • that the cell sizes (in pixels) are not differ very much in all the images,
  • that the cell colors are not differ very much in all the images.

Then you can premeasure the average size of a cell and calculate a cheap mask for the cells like this:

from SimpleCV import *
im = Image("s58Hl.jpg")
r,g,b = im.splitChannels()
cellmask = g.equalize().threshold(90).invert()
masksize = cellmask.getGrayNumpy().sum()/255.
cellsize = 27*27 # premeasured cell size
cellnum = masksize/cellsize

It gives me ~211 for the cell count.

The mask image is like this: enter image description here

For this smaller image I would manually count 9 cells:

enter image description here

The solution gives the result of 9.46502057613.

Of course, if any of the assumptions are invalid then this approach is useless. It is also sensitive to the hard color threshold and the cell size constant. Because of the color equalization, it can totally fail if no cell is present in the image.

But it is really simple and cheap :)

| improve this answer | |

First you have to change the image to binary image by using threshold, otsu method. You can seperate the cells( overlapped cells) by using mathematical morphology such as erosion, opening. Estimate the area.

| improve this answer | |
  • 1
    $\begingroup$ I quite like this answer and it is pretty much what I would recommend, but it is a bit unclear. If you could edit it a bit to improve clarity I would definitely up-vote it. $\endgroup$ – nivag Apr 28 '14 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.