How can I merge different regions in a binary image?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi Everyone,
is there a possibility to merge different regions in a binary image that are not attached to each other?
From my experiments I get the first image which shows the intensity of each pixel in the x-y-plane. From this I calculate the binary image by dividing the intensity of each pixel by "max(max(image))". The binary is shown in the second image. There, I now have the problem that from the big region of the first image, only several smaller regions remain, which are no longer attached to each other. Since this is physically incorrect, I need to merge those regions again to get one which is similar to the big one in the first image.
-> How can I merge those regions in MATLAb again? I need the entire region for further analysis and up to now MATLAB only recognises the lower left part (red marker) as the entire region of the binary.
I am using MATLAB Version: 8.3.0.532 (R2014a) and the image processing toolbox.
I hope you can help me, thank you very much for your help, Markus
0 comentarios
Respuestas (2)
Image Analyst
el 7 de Ag. de 2015
Dividing a grayscale image by the max intensity will not product a binary (logical) image. It sonly produces a normalized image in the range 0 to 1. So I have no idea how you got the second image. Perhaps you want to threshold the image instead.
1 comentario
Michael Hawks
el 2 de Mayo de 2019
My guess is the original image is an integer class (uint8 or uint16), so after dividing it rounds to the nearest integer.
Michael Hawks
el 2 de Mayo de 2019
I think you want to first create a binary image using a threshold test. If your image is named Image, then
th = 128;
bin = (Image > th);
You'll need to experiment a little to find the threshold value that works best for your data -- I threw 128 in there as an example.
Then you can use some morphological processes to merge the regions of interest. This will also require experimentation, but have a look at these commands:
bwmorph
imerode
imdilate
I've had good luck on similar tasks using the combination:
a = imdilate( bin, se );
b = bwmorph( a, 'bridge');
c = imerode( b, se );
where se is a structuring element ( the output image is the input image convolved by the structuring element), which you could create using the strel command, or just something like se = ones(5).
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!