how to perform closing by reconstruction followed by opening by reconstruction

Sukuchha · Feb 15, 2022 · 1.9K views
Question
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 ? ;  
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 13, 2026
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.
 
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!