Image Processing: Sky region in images

12 views (last 30 days)
Ning Wu
Ning Wu on 13 Aug 2015
Commented: Rena Berman on 24 Jan 2017
Does anyone have Matlab source code for detecting sky regions in images. I see many papers on this but could not find source code for this.
I see that there are multiple papers in literature which go for belief maps, and iterative solutions etc.
I am looking for simple code which may work in some color spaces only. If someone does not have code but can provide a reference to a good paper which is simple to implement, that would be much appreciated as well.
Thanks in advance.

Answers (1)

Image Analyst
Image Analyst on 14 Aug 2015
If you want to try simple color segmentation, to find the "sky blue" pixels, then adapt one of the color segmentation demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 It may do a decent job on most simple images, like a sky above a lawn or something, but may fail on some images where people recognize it as sky because it's not blue, like the sky is white or orange and it's showing through leaves of a tree or complex scenes like that.
  1 Comment
Image Analyst
Image Analyst on 14 Aug 2015
LAB color space is pretty simple, and the one you want to use if you're computing delta E color difference. LAB is kind of like a cartesian coordinate system version of HSV. So with LAB you could segment out a box and in HSV you'd segment out a pie-shaped sector since HSV is kind of like a cylindrical version of LAB. You most likely do not want to use YCbCr or RGB. So now think of LAB and HSV as just being different forms of a very similar color space (OK, not exactly mathematically but it's good for visualizing the gamut). So the Delta E method bascially carves out a ball in the color space, while segmentation in HSV color space basically carves out a pie-shaped sector. Whether one or the other is better depends on what your gamut looks like. With either one, you just have to specify the parameters. With Delta E, it's the center of the ball and it's radius. With HSV it's one or two radii, the two angles, and the upper and lower brightness values. The Delta E method is probably easiest if you want the user to draw an example first. With HSV you need to know in advance what color of sky you're looking for. You can determine the upper and lower limits for H, S, and V to get blue (instead of yellow) just as well as I can. Just look at the histograms and do a little trial and error with your own images (which I don't have).

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!