C ++ Biological cell counting using OpenCV

I am relatively new to OpenCV and I do not have strong image processing. I am currently working on a project to write a program to count all biological cells from a microscope in an image. I tried various methods from online sources to apply image counting, but none of them worked well as expected.

Some of the methods I use are:

  • Search for outlines of the filtered image. (does not work well with nearby cells)
  • Gaussian blur and detection of local maxima in the image. (same problem as 1)
  • Canny Edge Detection (output determines a non-segmented segment)

This is an example image in which 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 to each other. For example, for example:

enter image description here

However, the algorithm still does not separate 3 cells that stick together in the center of the image.

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

+7
c ++ opencv cell counting
source share
1 answer

Your approach is almost perfect. However, this requires additional steps. You need something called Morphological Surgery .

  • Filter your image the way you feel good.
  • Apply a threshold based on color or convert it to gray and then a threshold value. The postscript from the examples you cited seems like your cell color is too saturated. That way you can convert it to HSV Space and then install it on channel S (tell me if you need help here).
  • Apply Opening Morphological Operators on the Threshold Image. Postscript you can try several kernel sizes and choose the best.
  • Take the contours and do what you do.

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); 
+2
source share

All Articles