Merge regions
13 views (last 30 days)
Show older comments
Hi, I want to merge two regions if they are close to each other and their average intensity is similar.
if (| y1-y2 | <T & | M2-M1 |<t)
statement to merge
end
But I do not know how to write the statement for the merger of regions. Anyone know?
3 Comments
Walter Roberson
on 12 Jan 2012
Suppose you had two squares separated by a modest distance, with one of the two a bit up and to the right of the other. What would you like the merged region to look like in that case?
Answers (1)
Image Analyst
on 12 Jan 2012
Something like this perhaps???:
if (meanOfRegion1 - meanOfRegion2) < maxAllowableDifference
mergedMask = region1Mask & region2Mask; % Assumes binary images.
mergedImage = originalImage; % Initialize new image.
mergedImage(~mergedMask) = 0; % Zero out everything outside the merged region.
end
7 Comments
Image Analyst
on 13 Jan 2012
That's what we thought. So, yes, my code is essentially what you'd do and would "resolve the problem" if you choose to do it that way.
Walter Roberson
on 13 Jan 2012
Okay, so given that you have located two nearby regions that you want to merge, how do you want to merge them?
For example, suppose that one of the regions was a square, and three pixels to the right of it was the closest point of a circle of the same diameter. What should the merged region look like?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!