[ITK] [ITK-users] Setting constants in ternary functor filters
    jmerkow 
    jmerkow at gmail.com
       
    Thu Jan 15 17:09:20 EST 2015
    
    
  
Hello,
I am writing a ternary functor filter and I want to allow constants to be
set for inputs 2 and 3 (1 and 2 in SetNthInput).
I believe I followed the example in BinaryFunctor but when I set them I get
NULL pointers for the inputs:
"At least one input is missing. Input1 is 0xb212190,  Input2 is 0,  Input3
is 0"
My filter looks something like this (I trimmed it down to just the relevant
parts):
...
class MyTernaryFunctorImageFilter:
		public itk::TernaryFunctorImageFilter< TInputImage1, TInputImage2,
TInputImage3, TOutputImage,
		MyTernaryFunctor<
		typename TInputImage1::PixelType,
		typename TInputImage2::PixelType,
		typename TInputImage3::PixelType,
		typename TOutputImage::PixelType >   >
{
...
//Common Typedefs are here
...
typedef TInputImage2                           Input2ImageType;
typedef typename Input2ImageType::ConstPointer Input2ImagePointer;
typedef typename Input2ImageType::RegionType   Input2ImageRegionType;
typedef typename Input2ImageType::PixelType    Input2ImagePixelType;
typedef itk::SimpleDataObjectDecorator<Input2ImagePixelType>
DecoratedInput2ImagePixelType;
typedef TInputImage3                           Input3ImageType;
typedef typename Input3ImageType::ConstPointer Input3ImagePointer;
typedef typename Input3ImageType::RegionType   Input3ImageRegionType;
typedef typename Input3ImageType::PixelType    Input3ImagePixelType;
typedef itk::SimpleDataObjectDecorator<Input3ImagePixelType>
DecoratedInput3ImagePixelType;
virtual void SetConstant2(const Input2ImagePixelType &input);
virtual void SetConstant2(const DecoratedInput2ImagePixelType *input);	
/** Set the Third operand as a constant */
virtual void SetConstant3(const Input3ImagePixelType &input);
virtual void SetConstant3(const DecoratedInput3ImagePixelType *input);
};
template<...>
void
MyTernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3,
TOutputImage>
::SetConstant2(const Input2ImagePixelType &input)
{
	 itkDebugMacro("setting SetConstant2 to " << input);
	 typename DecoratedInput2ImagePixelType::Pointer newInput =
DecoratedInput2ImagePixelType::New();
	 newInput->Set(input);
	 this->SetConstant2(newInput);
}
template<...>
void
MyTernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3,
TOutputImage>
::SetConstant2(const DecoratedInput2ImagePixelType *input)
{
	this->SetNthInput( 1,const_cast<DecoratedInput2ImagePixelType*>(input));
}
template<...>
void
MyTernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3,
TOutputImage>
::SetConstant3(const Input3ImagePixelType &input)
{
	 itkDebugMacro("setting SetConstant3 to " << input);
	 typename DecoratedInput3ImagePixelType::Pointer newInput =
DecoratedInput3ImagePixelType::New();
	 newInput->Set(input);
	 this->SetConstant3(newInput);
}
template<...>
void
MyTernaryFunctorImageFilter< TInputImage1, TInputImage2, TInputImage3,
TOutputImage>
::SetConstant3(const DecoratedInput3ImagePixelType *input)
{
	this->SetNthInput( 2,const_cast<DecoratedInput3ImagePixelType*>(input));
}
I pass this function an image for input1, then floats for other two inputs.
Am I missing an ingredient here?
-Jameson
--
View this message in context: http://itk-users.7.n7.nabble.com/Setting-constants-in-ternary-functor-filters-tp35125.html
Sent from the ITK - Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
    
    
More information about the Community
mailing list