# Is there a way to find the contours of instances in a binary mask image by color?

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.

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)


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?