MATLAB Answers


how to perform closing by reconstruction followed by opening by reconstruction

Asked by Sukuchha
on 9 Feb 2012
Latest activity Edited by John Kelly
on 22 Aug 2014

In image processing demo(watershed segmentation) following codes were used for opening by reconstruction follwed by closing by reconstruction

Ie = imerode(I, se);
Iobr = imreconstruct(Ie, I);
figure, imshow(Iobr), title('Opening-by-reconstruction (Iobr)')
Iobrd = imdilate(Iobr, se);
Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));
Iobrcbr = imcomplement(Iobrcbr);
figure, imshow(Iobrcbr), title('Opening-closing by reconstruction (Iobrcbr)')

For closing by reconstruction followed by opening by reconstruction can i follow the same sequence but interchanging imerode and imdilate positioning in above code ? ;



No products are associated with this question.

1 Answer

Answer by Jeff EA
on 9 Feb 2012
Edited by John Kelly
on 22 Aug 2014
 Accepted answer

No, you cannot. Notice the multiple imcomplement calls after the imdilate step. These are necessary in the closing by reconstruction to make the mask and marker image fit the required inputs of imreconstruct. These imcomplement calls are not necessary for the opening by reconstruction.

In order to reverse the operations, you would need to take lines 4 through 6 in the code you pasted, and put them above lines 1 through 3, AND rename the variables accordingly.

  1 Comment

on 10 Feb 2012

Thanks Jeff for your input! the link you provided helped me a lot !

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!