Merge regions

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
Walter Roberson on 12 Jan 2012
How are the regions represented?
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

Marlene
Marlene on 12 Jan 2012
yes, but the regions are in the same binary image. are regions that are next to each other, but can only be re merged if (meanOfRegion1 - meanOfRegion2) < maxAllowableDifference.
So, these steps resolved the problem?
Image Analyst
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
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
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
Marlene on 13 Jan 2012
Yes, I have a binary image with many separate regions, but some of these regions are part of the same object but is fragmented with segmentation. So I go to grayscale image and calculate the average intensity of each of these regions. Then I wanted to merge the regions that are close to each other and have similar average intensity.
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

Asked:

on 12 Jan 2012

Community Treasure Hunt

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

Start Hunting!