Merge regions

13 views (last 30 days)
Marlene
Marlene on 12 Jan 2012
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
Marlene
Marlene on 12 Jan 2012
regions are white in a binary image representing objects.
Walter Roberson
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?

Sign in to comment.

Answers (1)

Image Analyst
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
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
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?

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!