Detecting red blood cells in image using opencv

I am trying to estimate the volume red blood cells in this microscope image.

How would u do it using python opencv if I know that the channel in which the red blood cells are in (distance between two thick red lines) is 50ym.

I am having trouble to properly detect the RBC because some are too near each other

meaning the right ~half of the image is not of interest?

if you’re planning to run this on a video, you’ll need some object tracking too. tracking by associating detections is simple enough.

I approached this with a lowpass (gaussian, sigma=5) and finding local maxima.

this finds 54 local maxima.

I used 10 px min dist between peaks, threshold of 0.3 between 1st and 99th percentile intensity, and before anything else I approximately undid the gamma mapping of the picture.

detections (local maxima) on the channel walls can be masked off trivially. cv.pointPolygonTest and a manually picked set of polygons for those two areas.

the non-maxima suppression (NMS) I typically do like so (“haystack” is usually template matching scores…):

radius = 10

localmax = cv.dilate(haystack, None, iterations=radius)
localmax = (haystack == localmax)

levelmask = (haystack >= 0.3)

candidates = levelmask & localmax

(nlabels, labels, stats, centroids) = cv.connectedComponentsWithStats(candidates.astype(np.uint8), connectivity=8)
print(nlabels-1, "found")

Thank you, would u mind sharing the whole code that u used?

^^ please dont talk like a moron, else people will take you for one …

sorry didn’t see the typos