pairwiseseq
pairwiseseq

Reputation: 333

Cluster/blob detection

I come from cell biology world so please excuse my lack of knowledge beforehand.

I primarily use ImageJ for image processing in which we fit a 2D-Gaussian to detect clusters/blobs/puncta. See image below, for example.

enter image description here

I am trying to implement a similar pipeline in python and came across opencv. I'm using simple blob detector and it works well for nicely isolated clusters and not so well where multiple clusters are clustered together. Below, left image is raw image and right is after tresholding.

enter image description here

My detector is contouring a "multi-cluster" cluster as a single cluster. Is there a way to segment these multi-cluster clusters more intelligently? Ideally, I'd like to use the same 2D-Gaussian, but am open to anything at this point?

Upvotes: 1

Views: 657

Answers (1)

Mercury
Mercury

Reputation: 4171

Try contour detection and see if it works.

contours, hierarchy = cv2.findContours(image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
out = image.copy()
out = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB)

for c in contours:
    cv2.polylines(out,[c],True,(255,0,0),1)

enter image description here

Upvotes: 1

Related Questions