Merge regions
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
How are the regions represented?
Marlene
on 12 Jan 2012
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
Marlene
on 12 Jan 2012
Image Analyst
on 12 Jan 2012
OK, but what do you think the mean of the binary regions is? I'll bet my next year's salary that they'll all be 1 (since logical true = 1). So what's the point? If all your regions are 1 (because they're from a binary image), then how can you decide whether to merge or not merge regions?
Walter Roberson
on 12 Jan 2012
Presumably the selected areas mask an image which is not binary, and it is the average magnitude of the active parts of the second image which is being considered.
But still I don't know how Marlene would like the connection to be made between the two regions. Smallest box that encloses both regions? Just label both regions the same and let them continue to be disjoint? Figure out the closest approach of the two objects and create a 1-wide 8-connected path between the two ? My Magic 8-Ball says "The situation is clouded".
Image Analyst
on 12 Jan 2012
I agree Walter, that's why my suggestion had both a binary image and an original grayscale image. In cases like these there is usually some sort of heirarchy that keeps track of what regions are adjacent to what other regions. Otherwise you can play tricks with binary or integer images to keep track. I don't know how she's keeping track. Adjacent regions are have the potential to be merged.
Marlene
on 13 Jan 2012
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?
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!