<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>You have created a loop in the ITK pipeline as you are reusing the output of the mean as the input of the dilate filter. It's likely easiest to just do the following for each filter:</div><div><br></div><div>img = prevfilter-&gt;GetOutput();</div><div>img-&gt;DisconnectPipeline()</div><div>filter-&gt;SetInput(img)</div><div>filter-&gt;Update()</div><div><br></div><div>The above approach will allow you to execute each filter in isolation, however I am not sure what your goals of your pipeline are. If you need to stream, then you need to create a separate filter of each execution as you initially did. If you are trying to minimize memory, then you will need to look into grafting images, and which filter can run in-place.</div><div><br></div><div>Brad</div><div><br><div><div>On Jul 19, 2013, at 4:37 AM, Jesse Ross-Jones &lt;<a href="mailto:jesse.rj@gmail.com">jesse.rj@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><div dir="ltr"><div><div><div>Hello,<br><br></div>I am using ITK to write a method which requires the repeated use of a couple filters. Instead of having to repeat code, is it possible for the filters to work within a loop instead? <br>

<br></div><b>A simplified example of the working code is here:</b><br><br>&nbsp; dilateFilter-&gt;SetInput(this-&gt;GetInput());<br>&nbsp; dilateFilter-&gt;SetKernel(structuringElement);<br><br>&nbsp; meanFilter-&gt;SetRadius(2);<br>&nbsp; meanFilter-&gt;SetInput(dilateFilter-&gt;GetOutput());<br>

<br>&nbsp; dilateFilter2-&gt;SetInput(meanFilter-&gt;GetOutput());<br>&nbsp; dilateFilter2-&gt;SetKernel(structuringElement);<br><br>&nbsp; meanFilter2-&gt;SetRadius(2);<br>&nbsp; meanFilter2-&gt;SetInput(dilateFilter-&gt;GetOutput());<br><br>

&nbsp; dilateFilter3-&gt;SetInput(meanFilter2-&gt;GetOutput());<br>&nbsp; dilateFilter3-&gt;SetKernel(structuringElement);<br><br>&nbsp; meanFilter3-&gt;SetRadius(2);<br>&nbsp; meanFilter3-&gt;SetInput(dilateFilter3-&gt;GetOutput());<br><br>

<br></div><b>I tried to replace the previous code with something the following, but the result produced only a black image. <br><br></b><br>&nbsp; dilateFilter-&gt;SetInput(this-&gt;GetInput());<br>&nbsp; dilateFilter-&gt;SetKernel(structuringElement);<br>

<br>&nbsp; meanFilter-&gt;SetRadius(2);<br>&nbsp; meanFilter-&gt;SetInput(dilateFilter-&gt;GetOutput());<div><br>&nbsp; for ( int j = 0 ; j &lt; 3 ; j = j + 1 ){<br>&nbsp;&nbsp;&nbsp; &nbsp;dilateFilter-&gt;SetInput(meanFilter-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; &nbsp;meanFilter-&gt;SetInput(dilateFilter-&gt;GetOutput());<br>

&nbsp;&nbsp;&nbsp; &nbsp;meanFilter-&gt;Update();<br>&nbsp; }<br><br><br></div><div>Best Regards,<br></div><div>Jesse<br></div><div><br><br></div></div>
_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote></div><br></div></body></html>