How can I merge different regions in a binary image?
조회 수: 10 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Image Analyst
2015년 8월 7일
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
Michael Hawks
2019년 5월 2일
My guess is the original image is an integer class (uint8 or uint16), so after dividing it rounds to the nearest integer.
Michael Hawks
2019년 5월 2일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!