Hi Luis,<br><br>Thanks a lot for your answer. What I am trying to do is to implement a reconstruction algorithm. I haven&#39;t used any of the implemented ones because I need to use my own structuring element.<br>What I have to do is dilatation + intersection until the convergence, this is why I need to modify the output of the Dilate filter. Is possible to do it? This is the code I have:<br>
<br>&nbsp;&nbsp;&nbsp; InputImageType::Pointer marker = InputImageType::New();<br>&nbsp;&nbsp;&nbsp; InputImageType::Pointer markerDilated = InputImageType::New();<br>&nbsp;&nbsp;&nbsp; InputImageType::Pointer mask = InputImageType::New();<br><br>&nbsp;&nbsp;&nbsp; marker = readerMarker-&gt;GetOutput();&nbsp;&nbsp; //read the marker image<br>
&nbsp;&nbsp;&nbsp; markerDilated = grayscaleReconstruction-&gt;GetOutput();&nbsp;&nbsp; //read the dilated marker<br>&nbsp;&nbsp;&nbsp; mask = readerMask-&gt;GetOutput();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //read the mask image<br><br>&nbsp;&nbsp;&nbsp; // Next we create two iterators.&nbsp; The iterators are initialized over the same region.&nbsp; <br>
&nbsp;&nbsp;&nbsp; //The direction of iteration is set to 0, the $x$ dimension.<br>&nbsp;&nbsp;&nbsp; IteratorType markerDilatedIt( markerDilated, markerDilated-&gt;GetRequestedRegion() );&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; IteratorType maskIt( mask, mask-&gt;GetRequestedRegion() );<br>
&nbsp;&nbsp;&nbsp; markerDilatedIt.SetDirection(0);<br>&nbsp;&nbsp;&nbsp; maskIt.SetDirection(0);<br><br>&nbsp;&nbsp;&nbsp; grayscaleReconstruction-&gt;SetKernel( structuringElement );<br>&nbsp;&nbsp;&nbsp; WriterType::Pointer writerMarkerDilated = WriterType::New();<br><br>&nbsp;&nbsp;&nbsp; for (int i =0; i&lt;numberOfIterations; i++)<br>
&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; grayscaleReconstruction-&gt;SetInput( marker );&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; grayscaleReconstruction-&gt;Update();<br><br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for ( markerDilatedIt.GoToBegin(),&nbsp; maskIt.GoToBegin(); ! maskIt.IsAtEnd();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; markerDilatedIt.NextLine(),&nbsp; maskIt.NextLine())<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; markerDilatedIt.GoToBeginOfLine();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; maskIt.GoToBeginOfLine();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while ( ! markerDilatedIt.IsAtEndOfLine() )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if( maskIt.Get()==0 )<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; markerDilatedIt.Set( 0 );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ++markerDilatedIt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ++maskIt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ++markerDilatedIt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ++maskIt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; writerMarkerDilated-&gt;SetFileName( argv[2] );&nbsp; //overwrite the marker<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; writerMarkerDilated-&gt;SetInput(markerDilated);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; writerMarkerDilated-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; readerMarker-&gt;Update();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; marker-&gt;Update();<br><br><br>&nbsp;&nbsp;&nbsp; }<br><br>Thanks a lot for your reply<br>Best<br>Bert<br><br><br>