0
$\begingroup$

I need to find the contours for each of the instances of microscopic cells in a binary image mask of dimensions 256 x 256 shown below.

Microscopic image mask

My approach involves thresholding the image to get a binary mask (foreground = 1,background = 0) as follows and then finding the contours of each instance of cell.

ret, binary = cv2.threshold(mask,0,255,cv2.THRESH_BINARY_INV)
contours, hierarchy = cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

After binary thresholding

The instances that are very close to each other are combined resulting in a single contour which is undesirable. Is there a way to achieve separate contours for each mask based on color?

$\endgroup$
0
$\begingroup$

well you discard that information the moment you convert to binary (your input is not binary – it has more than 2 values). So, don't do that.

$\endgroup$

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.