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)
Asked
Active
Viewed 1,133 times
-1
-
http://www.pyimagesearch.com/2016/10/31/detecting-multiple-bright-spots-in-an-image-with-python-and-opencv/ seems to be what you desire -- EDIT: Ohp, simpleCV, not opencv. My bad. Would you be averse to using opencv? – Marviel Feb 23 '17 at 17:29
-
@Marviel I mean, I can use it. The only reason I use SimpleCV is because it doesn't hurt my eyes and make me dizzy as much as the non-cleaned up and sometimes very chaotic OpenCV. Sidenote: I can do most of that what is described in the tutorial with just two calls using SimpleCV, that's the reason why i use it instead of OpenCV. – Jan Novák Feb 23 '17 at 17:50
-
Also, may I politely ask who downvoted this question and why? I know that just 1 point down doesn't seem like much, but it comes as a punch to the gut to a user, such as me. – Jan Novák Feb 23 '17 at 17:53
1 Answers
0
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()
-
While it might actually end up being helpful, that I can use colour channels and blob detection, the problem is I am not after the largest blob, but after the brightest blob. – Jan Novák Feb 23 '17 at 18:00
-
Returning the largest blob first is just how the function has been implemented. If you want the brightest blob then you will have to find the average pixel intensity in each blob manually. – shish023 Feb 23 '17 at 18:11
-
Another method (and maybe closer to what you want) is using BlobMaker in SimpleCV. That's the second link in my answer. It allows you to set a threshold and only blobs with intensities greater than that threshold will be selected. You can also specify limits on the blob size. – shish023 Feb 23 '17 at 18:14
-
yeah, I just tried mixing SimpleCV and OpenCV, didn't work out well for finding the brightest spot. I'll check out how does it end up, and then depending on the result will mark your answwer. – Jan Novák Feb 23 '17 at 18:19