Search code examples
pythonopencvcomputer-visionsimplecv

How to detect a black lake on a white snowy background in an aerial image?


Here is a sample aerial image: ![aerial image of some unfrozen lakes][1]

How do I automatically detect and extract parameters of the black unfrozen lake from the image? I'm primarily using Python.

EDIT: see my answer below; I think I've found the solution.


Solution

  • Here is the quick way to do it in SimpleCV:

    from SimpleCV import *
    
    lakeimg = Image('https://i.sstatic.net/ku8F8.jpg') #load this image from web, or could be locally if you wanted.
    invimg = lakeimg.invert() #we invert because blobs looks for white blobs, not black
    lakes = invimg.findBlobs() # you can always change parameters to find different sized blobs
    if lakes: lakes.draw() #if it finds blobs then draw around them
    invimg.show() #display the image
    

    If you wanted you can always play with parameters, typically we use ratios to image size if you wanted it to be fairly robust. There are also a bunch of options in the Features class for drawing bounding boxes on a few blobs, etc.