2016-12-08 69 views
0

detectMSERFeatures方法產生幾個重疊的Mser。有沒有辦法去除重疊區域?謝謝刪除重疊的MSER-matlab

+0

實際區域以像素列表形式給出。我相信你的意思是重疊發生在MSERRegions對象的Location和Axes屬性描述的橢圓之間? –

+0

是的。我想刪除一個更大的橢圓中包含的所有橢圓。 –

+0

包含或重疊?如果兩個區域的小部分重疊會怎樣? –

回答

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 

Ellipses

隨着現在根據的總和排序的地區與它們佔用的大小成正比的軸,您可以遍歷它們,並使用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); 

First Ellipse

如果您對更小尺寸的剩餘省略號(假設你已經調整的方法不包括在返回值的圖像內容)做到這一點,並比較交叉口的大小很容易與較小的橢圓的大小:

intersection = EllipseMap1 & EllipseMap2; 
sizeOfIntersection = sum(intersetion(:)); 
sizeOfSmallerEllipse = sum(EllipseMap2(:)); 

這不是一個好方法,但它應該做的伎倆。