SimpleCV - detect bright spots in an image

1.1k Views Asked by At

So, I need to detect bright spots in an image using SimpleCV and python. I already have the image acquisition sorted out, my only problem is finding the bright spot(s). Any idea how can I do this? (got gaussian blur already, for spot-to-area conversion)

1

There are 1 best solutions below

4
shish023 On BEST ANSWER

You can use the findBlobs function in SimpleCV.

#find the green ball
green_channel = Camera().getImage().splitChannels[1]

green_blobs = green_channel.findBlobs()
#blobs are returned in order of area, largest first

print "largest green blob at " + str(green_blobs[0].x) + ", " + str(green_blobs[0].y)

Example from: http://simplecv.readthedocs.io/en/1.0/cookbook/#blob-detection

Some more documentation of related concepts: http://simplecv.sourceforge.net/doc/SimpleCV.Features.html#module-SimpleCV.Features.BlobMaker

EDIT: To get blobs sorted from brightest to darkest you use the sortColorDistance() method:

blurred = camera.applyGaussianFilter(grayscale=True)
#find them blobs
blobs = blurred.findBlobs()
#draw their outlines
blobs.draw(autocolor=True)
#sort them from brightest to darkest and get center of the brightest one
brightest = blobs.sortColorDistance((255, 255, 255))[0].coordinates()