<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">From: Christian Werner <<a ymailto="mailto:christian.werner@rwth-aachen.de" href="mailto:christian.werner@rwth-aachen.de">christian.werner@rwth-aachen.de</a>><br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div style="font-family: tahoma,new york,times,serif; font-size: 10pt;"><br>> I need a slightly modified version of the itkSubtractImageFilter that <br>> caps the result at 0, such that all negative values will become 0 <br>> instead. I know I could do that with the actual SubtractImageFilter <br>> followed by a ShiftScaleImageFilter, but it is important that this is a <br>> one-pass filter since we are working with extremely large (up to 1GB) data.<br><br>It would be easier to define your own function and re-use the BinaryFunctorImageFilter...example
code:<br><br>// A function (not templated at this point, but could be by replacing PixelType) that will calculate difference between two points.<br>//<br>class RealDifference<br>{<br> public:<br> RealDifference() {};<br> ~RealDifference() {};<br><br> bool operator!=( const RealDifference& ) const<br> {<br> return false;<br>
}<br><br> bool operator==( const RealDifference& other ) const<br> {<br> return !( *this != other );<br> }<br><br> inline PixelType operator()( const PixelType& A, const PixelType& B )<br> {<br> return vnl_max(
itk::NumericTraits< PixelType >::Zero, A - B );<br> }<br>};<br><br>typedef itk::BinaryFunctorImageFilter< ImageType, ImageType, ImageType, RealDifference > RealDifferenceFilter;<br><br>RealDifferenceFilter::Pointer differenceFilter = RealDifferenceFilter::New();<br>differenceFilter->InPlaceOff(); // will re-use first input buffer as output buffer if "on".<br>differenceFilter->SetInput1( image1Ptr ); // A<br>differenceFilter->SetInput2( image2Ptr ); // B<br>differenceFilter->Update();<br><br>differenceImage = differenceFilter->GetOutput( 0 );<br><br><br>Todd Jensen<br></div></div>
</div></body></html>