detectMSERFeatures 方法产生几个重叠的 mser。有没有办法去除重叠区域?谢谢
问问题
325 次
1 回答
0
有一个实现允许您检索FileExchange中椭圆下的绘图区域。
我简要地研究了它,你可能需要稍微调整它,或者以一种有点时髦的方式使用它:
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
现在根据轴的总和对区域进行排序,轴的总和与它们占用的大小成正比,您可以遍历它们,并使用 FileExchange 中的代码来检索它们各自的二进制映射。您必须更改代码以使其不返回图像,但这应该相当简单。如何调用它的一个示例:
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);
如果您对剩余的较小尺寸的椭圆执行此操作(假设您已调整方法以不将图像内容包含在返回值中),并且很容易将交点的大小与较小椭圆的大小进行比较:
intersection = EllipseMap1 & EllipseMap2;
sizeOfIntersection = sum(intersetion(:));
sizeOfSmallerEllipse = sum(EllipseMap2(:));
这不是一个好方法,但它应该可以解决问题。
于 2016-12-08T17:09:10.853 回答