the detectMSERFeatures method yields several msers which overlap. Is there a way to remove overlapping regions? Thanks
-
The actual regions are given as a list of pixels. I believe you mean that the overlap occurs between the ellipses described by the Location and Axes properties of the MSERRegions object? – Franz Hahn Dec 08 '16 at 10:40
-
yes. i want to remove all the ellipses contained within a bigger ellipse. – Nikhil Harsoor Dec 08 '16 at 12:28
-
Contained or overlapping? What if small portions of two regions overlap? – Franz Hahn Dec 08 '16 at 13:03
-
small portion overlapping is fine. if more than 70% of area overlap then i want to keep the bigger of the two and discard smaller one. – Nikhil Harsoor Dec 08 '16 at 14:59
1 Answers
There's an implementation that allows you to retrieve a plotted area under an ellipse in the FileExchange.
I looked into it briefly and you may have to adjust it slightly, or use it in a slightly funky way:
I = imread('cameraman.tif');
regions = detectMSERFeatures(I);
imshow(I)
hold on;
plot(regions);
[~,idx] = sort(sum(regions.Axes,2),'descend');
sortedAxes = regions.Axes(idx,:)/2; %division for later use in ellipseMatrix
sortedLocations = regions.Location(idx,:);
sortedOrientations = rad2deg(regions.Orientation(idx,:)); %degree for later use in ellipseMatrix
With the regions now sorted according to the sum of the axes which is more or less proportional to the size they take up, you could iterate over them, and use the code from the FileExchange to retrieve their respective binary maps. You'd have to alter the code so that it doesn't return the image with it, but that should be rather simple. One example of how to call it:
i=1;
x0 = sortedLocations(i,1);
y0 = sortedLocations(i,2);
a = sortedAxes(i,1);
b = sortedAxes(i,2);
theta = sortedOrientations(i);
I2 = ellipseMatrix(x0,y0,a,b,theta,I',128,128,2)';
figure;
subplot(1,2,1);
imshow(I2);
subplot(1,2,2);
imshow(I2);
hold on;
plot(regions);
If you do this for the remaining ellipses of smaller size (assuming you have adjusted the method not to include the image content in the return values), and compare the sizes of the intersections quite easily to the size of the smaller Ellipse:
intersection = EllipseMap1 & EllipseMap2;
sizeOfIntersection = sum(intersetion(:));
sizeOfSmallerEllipse = sum(EllipseMap2(:));
It's not a nice approach, but it should do the trick.

- 332
- 1
- 10