"Fill" Binary Image
Mostrar comentarios más antiguos
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!
Respuesta aceptada
Más respuestas (2)
Image Analyst
el 3 de Jun. de 2011
1 voto
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
el 2 de Jun. de 2011
0 votos
16 comentarios
Wolfgang Schwanghart
el 3 de Jun. de 2011
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
el 3 de Jun. de 2011
Wolfgang Schwanghart
el 3 de Jun. de 2011
If there is a connected, black outline around the building, you can use the imfill function to fill the building.
Philip
el 3 de Jun. de 2011
Image Analyst
el 3 de Jun. de 2011
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
el 3 de Jun. de 2011
Philip
el 3 de Jun. de 2011
Sean de Wolski
el 3 de Jun. de 2011
Can you show us the grayscale image?
Philip
el 3 de Jun. de 2011
Walter Roberson
el 3 de Jun. de 2011
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
el 3 de Jun. de 2011
Walter Roberson
el 3 de Jun. de 2011
I don't think I caught what the actual goal is? Is it to differentiate between sky and non-sky?
Philip
el 3 de Jun. de 2011
Walter Roberson
el 3 de Jun. de 2011
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
el 3 de Jun. de 2011
Image Analyst
el 4 de Jun. de 2011
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.
Categorías
Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!