Find large area of image, and draw boundaries

3 Ansichten (letzte 30 Tage)
Philip
Philip am 27 Mai 2011
Does anybody know of a way to identify a large area of an image (I have segmented the image first to make this easier), and then to draw around the edge of that object?
Here is an example of what I mean:
A large object in this image is the sky - so I would like to draw a boundary around it which will essentially show the horizon of the image.
Many thanks as always for all your help!

Antworten (1)

Walter Roberson
Walter Roberson am 27 Mai 2011
Threshold on the blue channel, label the resulting image, regionprops() and sort by area; if I recall, regionprops can return the boundary.
  2 Kommentare
Philip
Philip am 27 Mai 2011
Do you know if this is possible without having to threshold? I am hoping that the code can be applied to several images, and thresholds will introduce some error for certain images.
Here's another segmented example:
http://imageshack.us/photo/my-images/339/segmented2.png/
I have used "mode(mode(segmented_image))" to return the value of the most frequent pixel value. The value returned is 241, which corresponds to the top-most blue region of the sky. Now that I know this, is there a way to merge all of the "sky" segments, and set everything else to be another segment? I will therefore end up with a total of 2 segments...
Image Analyst
Image Analyst am 29 Mai 2011
No, there's no way to do it without thresholding. No matter what you call it - segmentation, classification, or whatever - eventually it all comes down to thresholding because you're going to have to say what's sky (foreground) and what's "not sky" (background), and that's thresholding. You may have to come up with an algorithm to find the threshold automatically though, as it may change from one image to the next. Your image has a bunch of colors that are adjacent to each other. Nobody and no computer knows what you consider to be blue unless you tell it how close it's allowed to be to another color - again, essentially that's thresholding.
You can get the sky from both your images from thresholding to get a binary image and then call bwboundaries().

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by