Remark. This implementation is considered legacy code and is superseded by VLFeat.

This is a MEX implementation of the Maximally Stable Extremal Region (MSER) feature detector [1]. The C source code consists of a single MEX file and should be very easy to port to environments other than MATLAB.

Overview

The package provides a single MEX function mser that extracts the maximally stable extremal regions from a given gray-scale image. So for example (this code is part of the mser_demo2 M-file included in the package), lets load a test image

>> I = load('clown') ; I = uint8(I.X) ;
>> figure ; imagesc(I) ; colormap gray; hold on ;

This should result in the following picture:

clown

We run mser to extract regions r and fitted ellipses ell:

>> [r,ell] = mser(I,uint8(5)) ;
Sorting pixels ... done
Computing extremal regions ... done
Extremal regions: 3679
Maximally stable regions: 475 (12.9%)
Bad regions:        0
Small regions:      432
Big regions:        15
Duplicated regions: 8
Cleaned-up regions: 20 (0.5%)
Fitting ellipses...
mean 0
mean 1
corr (0,0)
corr (0,1)
corr (1,1)

Regions are represented as point of maximum intensity of the corresponding connected component level set. Let us visualize these points:

>> [i,j]=ind2sub(size(I),r) ;                    
>> plot(j,i,'r*') ;
clown

This is not really meaningful. It is much more interesting to have a look at the fitted ellipses (for this step you need the function plotframe that can be found as part of the VLUtil package):

>> ell = ell([2 1 5 4 3],:) ;
>> plotframe(ell);  
clown

In order to see what a maximally stable extremal region looks alike we need to compute a connected component of a level set. To this end we use the function erfill:

>> k = 1 ; % mser number
>> clf ;
>> sel = erfill(I,r(k)) ;
>> mask = zeros(M,N) ; mask(sel) =1 ;
>> imagesc(cat(3,I,255*uint8(mask),I)) ; colormap gray ; hold on ;
>> plot(j(k),i(k),'r*') ;
>> plotframe(ell(:,k),'color','r') ;

References

[1] Robust wide baseline stereo from maximally stable extremal regions, J. Matas, O. Chum, M. Urban, and T. Pajdla, in Proc. BMVC, 2002.