Find large area of image, and draw boundaries

조회 수: 6 (최근 30일)
Philip
Philip 2011년 5월 27일
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!

답변 (1개)

Walter Roberson
Walter Roberson 2011년 5월 27일
Threshold on the blue channel, label the resulting image, regionprops() and sort by area; if I recall, regionprops can return the boundary.
  댓글 수: 2
Philip
Philip 2011년 5월 27일
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 2011년 5월 29일
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().

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by