[Insight-users] SubtractImageFilter - Modification

Christian Werner christian.werner at rwth-aachen.de
Sat May 1 17:14:51 EDT 2010


Hi!

I need a slightly modified version of the itkSubtractImageFilter that 
caps the result at 0, such that all negative values will become 0 
instead. I know I could do that with the actual SubtractImageFilter 
followed by a ShiftScaleImageFilter, but it is important that this is a 
one-pass filter since we are working with extremely large (up to 1GB) data.

I usually program in vtk and from time to time need some itk filters, so 
I don't have much clue about how to do that. Since this tiny little itzy 
bitzy special subtraction is the only thing I need and I don't have the 
time to really dive into "How to program ITK Filters that rock", I just 
looked at the code of the itkSubtractImageFilter. It seemed as if I 
could achieve what I want with changing a single line. I did that and 
replaced every occurence of "SubtractImageFilter" with 
"SubtractImageFilter2" (where the '2' denotes that this is a specially 
tailored, next-generation filter).

Then the time came to test out that new filter. I included it just like 
any other itk filter:

#include "itkSubtractImageFilter2.h".

The compiler had no problem with that (it finds this header). But when 
trying to instantiate a SubtractImageFilter2:

130 typedef itk::SubtractImageFilter2<ImageType, ImageType, ImageType> 
SubtractFilterType;
131 typename SubtractFilterType::Pointer subtractFilter = 
SubtractFilterType::New();

I get:

/home/christian/programming/pv-plugins/IO/vtkMeasureObjects.cxx:130: 
error: expected initializer before ‘<’ token
/home/christian/programming/pv-plugins/IO/vtkMeasureObjects.cxx:131: 
error: ‘SubtractFilterType’ has not been declared

which indicates that there is no SubtractImageFilter2. If I simply 
remove the "2" in the include and in line 130, everything is compiled 
just fine.

It seems more has to be done to announce a new itk Filter. I have 
attached the filter.

Any ideas?


Best regards,
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkSubtractImageFilter2.h
Type: text/x-chdr
Size: 3363 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100501/b0a9501e/attachment.h>


More information about the Insight-users mailing list