7

I'm trying to isolate the sky region from a series of grayscale images in OpenCV. All of the images are fairly similar: the top of the image is always a sky region, and is always a bright, gray-white colour. I've attempted contour-based approaches, and written my own algorithm to extract the line of the horizon and divide the image into two masks accordingly. However, I've noticed that the reliability of the magic wand tool in Photoshop on this image set is MUCH more accurate.

Here's the image that I'm processing:

enter image description here

and the result that I hope to achieve:

enter image description here

How can this be imitated in OpenCV?

Chris Abbott
  • 316
  • 3
  • 9

1 Answers1

12

I think what you're looking for is the grabcut algorithm

BPL
  • 9,632
  • 9
  • 59
  • 117
  • 1
    ...and, for users who land here while searching for a way to do something like "grabcut the image, then magic wand various bits of the image within regions it got wrong, then flood-fill the corresponding parts of grabcut's mask before running another iteration", [`cv::floodFill` can be configured to modify its input mask without actually modifying the image](https://stackoverflow.com/questions/16705721/opencv-floodfill-with-mask). – ssokolow Apr 17 '17 at 03:06