Maximally Stable Extremal Regions (MSER) is a feature
detector; Like the SIFT detector, the
MSER algorithm extracts from an image I
a number of
co-variant regions, called MSERs. An MSER is a stable
connected component of some level sets of the
image I
. Optionally, elliptical frames are attached to
the MSERs by fitting ellipses to the regions. For a more in-depth explanation
of the MSER detector, see our API reference for MSER
Extracting MSERs
Each MSERs can be identified uniquely by (at least) one of its
pixels x
, as the connected component of the level set at
level I(x)
which contains x
. Such a pixel is
called seed of the region.
To demonstrate the usage of the MATLAB command vl_mser
we open MATLAB and load a test image
pfx = fullfile(vl_root,'data','spots.jpg') ;
I = imread(pfx) ;
image(I) ;
We then convert the image to a format that is suitable for the
vl_mser
command.
I = uint8(rgb2gray(I)) ;
We compute the region seeds and the elliptical frames by
[r,f] = vl_mser(I,'MinDiversity',0.7,...
'MaxVariation',0.2,...
'Delta',10) ;
We plot the region frames by
f = vl_ertr(f) ;
vl_plotframe(f) ;
vl_ertr
transposes the elliptical frame and is
required here because the vl_mser
code assumes that the row index
is the first index, but the normal image convention assumes that this is the
x
(column) index.
Plotting the MSERs themselves is a bit more involved as they have
arbitrary shape. To this end, we exploit two
functions: vl_erfill
, which, given an image and a region
seed, returns a list of the pixels belonging to that region, and
the MATLAB built-in contour
, which draws the contour lines
of a function. We start by
M = zeros(size(I)) ;
for x=r'
s = vl_erfill(I,x) ;
M(s) = M(s) + 1;
end
which computes a matrix M
whose value are equal to the
number of overlapping extremal regions. Next, we use M
and contour
to display the region boundaries:
figure(2) ;
clf ; imagesc(I) ; hold on ; axis equal off; colormap gray ;
[c,h]=contour(M,(0:max(M(:)))+.5) ;
set(h,'color','y','linewidth',3) ;
MSER parameters
In the original formulation, MSERs are controlled by a single
parameter Δ
, which controls how the stability is
calculated. Its effect is shown in the figure below.
Δ
. We start with a synthetic
image which has an intensity profile as shown. The bumps have
heights equal to 32, 64, 96, 128 and 160. As we increase
Δ
, fewer and fewer regions are detected until
finally at Δ=160
there is no region
R
which is stable at R(+Δ)
.
The stability of an extremal region R
is the inverse
of the relative area variation of the region R
when the
intensity level is increased by Δ
. Formally, the
variation is defined as: