Behavior of imclose() function

9 Ansichten (letzte 30 Tage)
Holmes Queen
Holmes Queen am 14 Dez. 2020
Kommentiert: Image Analyst am 14 Dez. 2020
The morphological close operation is a dilation followed by an erosion, using the same structuring element for both operations. Using a logical matrix a as input with a square structure element,
a = [0 0 1 0 0;
1 1 1 1 1;
0 1 0 1 0;
1 0 0 0 1;
0 0 0 0 0];
se = strel('square', 3);
The result I obtained after performing a dilation, imdilate() followed by an erosion, imerode() on a:
a = imdilate(a, se);
a = imerode(a, se);
% output
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 0 0 0 1
1 0 0 0 1
The result I obtained when applying imclose() directly on a:
a = imclose(a, se);
% output
0 0 1 0 0
1 1 1 1 1
1 1 1 1 1
1 0 0 0 1
0 0 0 0 0
Did I miss out something? Why the outputs are different?

Akzeptierte Antwort

Image Analyst
Image Analyst am 14 Dez. 2020
Looks like imclose() assumes that the "missing" pixels outside the image are 0 while imerode() assumes they're 1.
  2 Kommentare
Holmes Queen
Holmes Queen am 14 Dez. 2020
I know MATLAB performs border padding for both dilation and erosion according to Border Padding for Morphology. It seems like the underlying implementation of imclose() is not merely calling imdilate() followed by imerode(). From my observation, maybe imclose() did not perform border padding, or had added some additional steps, and I couldn't reproduce the result. Seems weird to me.
Image Analyst
Image Analyst am 14 Dez. 2020
If you edit the source code:
>> edit imclose.m
you'll see this line:
Bp = imerode(imdilate(inputImage,se,packopt,M),se,packopt,M);
but there's a whole bunch of stuff other than that so it's not as simple as a simple dilation follwed by a simple erosion. They usually give reference papers for algorithms so check the documentation or the source code or call them and ask.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by