<div class="gmail_quote">On Mon, Oct 25, 2010 at 3:49 AM, David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com">daviddoria@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>I don't believe the following will work. The idea is to pass an image to a function and smooth it "in place".</div><div><br></div><div>ImageType::Pointer image = get image from somewhere...</div>
<div>SmoothImage(image);</div><div><br></div><div>where:</div><div><br></div><div>void SmoothImage(ImageType::Pointer image)</div><div>{</div><div> // Create and setup a mean filter</div>
<div> typedef itk::MeanImageFilter<</div><div><span style="white-space: pre-wrap;">                </span> ImageType, ImageType > filterType;</div><div> </div><div> filterType::Pointer meanFilter = filterType::New();</div>
<div> meanFilter->SetInput(image);</div><div> meanFilter->Update();</div><div><br></div><div> image = meanFilter->GetOutput();</div><div>}</div><div><br></div><div>Of course you can do this:</div><div><br></div>
<div><div>ImageType::Pointer image = get image from somewhere...</div><div>ImageType::Pointer output = ImageType::Pointer::New();</div>
<div>SmoothImage(image, output);</div></div><div><br></div><div>void SmoothImage(ImageType::Pointer image, ImageType::Pointer output)</div><div><div>{</div><div> // Create and setup a mean filter</div><div> typedef itk::MeanImageFilter<</div>
<div><span style="white-space: pre-wrap;">                </span> ImageType, ImageType > filterType;</div><div> </div><div> filterType::Pointer meanFilter = filterType::New();</div><div> meanFilter->SetInput(image);</div>
<div> meanFilter->Update();</div><div><br></div><div> output = meanFilter->GetOutput();</div><div>}</div></div></blockquote><div><br><br>That's not an inplace processing of the data. What is being done above is to allocate the output buffer, in addition to the input buffer - executing the filter - and then taking a reference the newly created output buffer into the variable "output".<br>
<br>You might as well just set ReleaseDataFlagOn() on the meanFilter. That way, the memory footprint remains the same as above, and the code is cleaner. Its input gets released after a downstream filter has consumed its output.<br>
<br>A in-place filter overwrites its input buffer. The snippet below should do that<br><br> meanFilter->SetInput(image);<br> meanFilter->GraftOutput(image);<br> meanFilter->Update();<br><br><br>Filters that derive from itk::InPlaceImageFilter do this automatically bypassing the usual AllocateOutputs prior to execution.<br>
<br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><br></div><div>but that seems a bit awkward.</div><div><br>Is there a pattern that makes sense for this "in place filtering" style function?</div>
<div><br></div>Thanks,<br><font color="#888888"><br>David<br>
</font><br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>