"Fill" Binary Image
显示 更早的评论
Hi,
Is there a way to "fill" a binary image such that textured regions become black? As an example, I would like to make this first image:
Look like this second image:
Note how the wall towards the left of the image appears mainly white in the first image. Is there a way to darken it so that it becomes more like that shown in the second image?
I have tried using morphological operators such as:
filled = bwmorph(img, 'fill', 100);
But this doesn't seem to have any affect. I am desperate to hear your thoughts.
Thanks for your help!
采纳的回答
更多回答(2 个)
Image Analyst
2011-6-3
1 个投票
You can try imopen if you want to maintain the size - this does an erosion (local min) followed by a dilation (local max). To enlarge the black area, just use imerode. To get rid of small things, use bwareaopen, which does labeling and regionprops internally like Walter said. But your images were not created by any morphological operation of the first one to produce the second one. I'm virtually certain that they were produced by thresholding with different threshold values, because there's no other way to produce the texture in the sky region of the second image - it simply isn't in the first image and there's no way to get that out of a uniform white area. I'd bet my next paycheck on it.
Philip
2011-6-2
0 个投票
16 个评论
Wolfgang Schwanghart
2011-6-3
Hi Philip, this book is excellent to dig deeper into morphological image processing.
Morphological Image Analysis; Principles and Applications by Pierre Soille, ISBN 3540-65671-5 (1999), 2nd edition (2003)
Cheers, W.
Philip
2011-6-3
Wolfgang Schwanghart
2011-6-3
If there is a connected, black outline around the building, you can use the imfill function to fill the building.
Philip
2011-6-3
Image Analyst
2011-6-3
Like I said in my answer, the two images were generated from thresholding a gray scale image, not from morphologically processing one to get the other. So your best bet is to begin with the original grayscale or color image. Are you not able to get that for some reason? If you can, you can do something like color segmentation or texture segmentation, though anything you do will probably be only applicable to that one image, not all images in the universe that you might possibly capture.
Philip
2011-6-3
Philip
2011-6-3
Sean de Wolski
2011-6-3
Can you show us the grayscale image?
Philip
2011-6-3
Walter Roberson
2011-6-3
That appears to be an image of something different. In the original two images, there is a brick wall going most of the way up the left side, but in this new image, the only brick wall is much smaller and only goes part way up.
Philip
2011-6-3
Walter Roberson
2011-6-3
I don't think I caught what the actual goal is? Is it to differentiate between sky and non-sky?
Philip
2011-6-3
Walter Roberson
2011-6-3
Longest straightest boundary, or longest straightest edge? An edge could, for example, be part of a texture. A band of ventilation grills running along a building that had an irregular rough could find the band to be the longest straight edge ?
Philip
2011-6-3
Image Analyst
2011-6-4
Have you considered using Hough or houghlines for finding lines? Like I said before your images were binarized from a gray scale image. I don't think they are the result of different exposures unless your gain is so incredibly high that the different exposures cause binarization in the first place. Why don't you post the original gray scale or color images and say what you are really trying to find instead of saying things like I want to find the longest line. If you want to find a horizon, say so. Because maybe the longest line won't get you that in all situations.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!