On Monday, April 18, 2011 06:37:51 pm Chris Weisiger wrote:
I can hack something together to do this easily enough, where I find a pixel in one of the islands, flood-fill out to get all connected pixels, calculate the centroid, flip the pixels to 0, and repeat until all islands are gone. This isn't exactly very speedy though. What's the efficient way to do this? Is there one? Is there a better approach I should be taking? The image processing class I dimly remember taking years ago didn't cover this kind of thing, so I'm lacking even the basic vocabulary needed to search for algorithms.
You can probably do it in one go: 1) convolve with a Gaussian of roughly the size you expect the PFS of the beads to be. 2) threshold to get the beads. You can probably use a method like mahotas.threshold.otsu to do this automatically 3) scipy.ndimage.label to label the binary image 4, optional) remove noise by removing detections that are too small 5) find centroids of the remaining areas. HTH Luis