Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Biological Cell Counting with OpenCV

I'm relatively new to OpenCV and I do not have a strong image processing background. Currently I am working on a project to write a program to count all the biological cells from microscope in an image. I have tried various method from Internet sources to apply counting on the image, but none of them work well as expected.

Some of the methods I have used are:

  1. Finding contours of the filtered image. (does not work well with cells that are close together)
  2. Gaussian blur and find local maxima on the image. (same problem as 1)
  3. Canny Edge detection (output result detect non cells segment)

This is an example of the image I need to count the total number of cells.

enter image description here

My current counting algorithm works better if the cells are not close together. For example like this:

enter image description here

However, the algorithm still fail to split apart the 3 cells that are sticked together in the center of the image.

So what could I do to detect total number of cells in an image with least false negative/positive?

like image 638
Woody Avatar asked Nov 16 '15 06:11

Woody


1 Answers

Your approach is almost fine. However, it needs some additional steps. You need something called Morphological Operations.

  1. Filter your image in the way you thing is good.
  2. Apply a threshold depending on color or convert it to gray then threshold it. P.S. from the examples you provided, it seems that your cell color is too saturated. So, you may convert it to HSV Space and then threshold it using the S channel (tell me if you need help here).
  3. Apply the Opening Morphological Operators on the thresholded image. P.S. you may to try few kernal size and choose the best.
  4. Take contours and do what you were doing.

Opening:

cv::Mat element = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(5, 5), cv::Point(1, 1));
cv::morphologyEx(img, img, cv::MORPH_OPEN, element, cv::Point(-1, -1), 1);
like image 185
Humam Helfawi Avatar answered Sep 25 '22 01:09

Humam Helfawi