How can I create structuring element arbitrarily in marker control watershed?

8 views (last 30 days)
% here a sample code and I wolud like to set structuring element arbitrarily
.
.
.
se = strel('disk',10);
Io = imopen(I, se);
Ie = imerode(I, se);
Iobr = imreconstruct(Ie, I);
Ioc = imclose(Io, se);
Iobrd = imdilate(Iobr, se);
Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));
Iobrcbr = imcomplement(Iobrcbr);
fgm = imregionalmax(Iobrcbr);
I2 = I;
I2(fgm) = 255;
%clean the edges of the marker blobs
se2 = strel(ones(5,5));
fgm2 = imclose(fgm, se2);
fgm3 = imerode(fgm2, se2);
fgm4 = bwareaopen(fgm3,10); %shink them a bit e.g 20
.
.
.
%please help me ,how can i set arbitrarily
  2 Comments
Walter Roberson
Walter Roberson on 6 Jan 2014
In that previous one I already pointed out that strel() can take arbitrary neighbourhoods for the shape. Look at the documentation: it is the second sample syntax http://www.mathworks.com/help/images/ref/strel.html
kyawt kyawt
kyawt kyawt on 6 Jan 2014
Thank a lot, for your answers. Yes, you already pointed out that strel() can take arbitrary neighbourhoods for the shape. However I don't know that how to obtain for the value of (NHOOD) parameter. NHOOD=[100;100;101] is default for all type of images?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 6 Jan 2014
The example does not show [100;100;101] and instead shows [1 0 0; 1 0 0; 1 0 1] . The example is arbitrary and might not be useful in any real situation (but might be.)
If you want to understand what a particular structuring element will do for you, you need to study morphology; see http://en.wikipedia.org/wiki/Dilation_%28morphology%29
I am not able to explain this at the moment as it is too late at night for me to be able to understand the formulas on first reading.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!