www.gusucode.com > vision 源码程序 matlab案例代码 > vision/FindCircularMSERRegionsExample.m

    %% Find circular MSER regions
% 
%%
% Detect MSER regions.
I = imread('coins.png');
[regions,mserCC] = detectMSERFeatures(I);
%%
% Show all detected MSER Regions.
figure
imshow(I)
hold on
plot(regions,'showPixelList',true,'showEllipses',false)
%%
% Measure the MSER region eccentricity to gauge region circularity.
stats = regionprops('table',mserCC,'Eccentricity');
%%
% Threshold eccentricity values to only keep the circular regions. (Circular regions have low eccentricity.)
eccentricityIdx = stats.Eccentricity < 0.55;
circularRegions = regions(eccentricityIdx);
%%
% Show the circular regions.
figure
imshow(I)
hold on
plot(circularRegions,'showPixelList',true,'showEllipses',false)