Hi,
I have a filter that uses the itk::GradientImageFilter for regularization. It is templated over its input image type, and works correctly when that type is itk::Image<float, n>. I am trying to make that filter able to process multi-channel images, and in this process the current roadblock is the itk::GradientImageFilter. Is there a way to have the itk::GradientImageFilter process images of itk::Vector<float, 3> instead of plain floats ? The calculations only involve multiplications by scalars, sums and differences, which are all defined on itk::Vector<float, 3>.
I have tried the following, which fails to compile (error message below):
#include <itkGradientImageFilter.h>
#include <itkImageFileReader.h>
int main(){
typedef itk::Vector<float, 3> VectorPixelType;
typedef itk::Image<VectorPixelType, 2> VectorImageType;
typedef itk::Image<itk::CovariantVector<VectorPixelType, 2>, 2> GradientOfVectorImageType;
typedef itk::ImageFileReader<VectorImageType> VectorImageReaderType;
VectorImageReaderType::Pointer imageReader = VectorImageReaderType::New();
imageReader->SetFileName("image.mha");
imageReader->Update();
typedef itk::GradientImageFilter<VectorImageType, float, VectorPixelType, GradientOfVectorImageType> GradientFilterType;
GradientFilterType::Pointer gradientFilter = GradientFilterType::New();
gradientFilter->SetInput(imageReader->GetOutput());
gradientFilter->Update();
return EXIT_SUCCESS;
}
The error message: /home/mory/sources/itk/ITK/Modules/Core/Common/include/itkNeighborhoodInnerProduct.hxx:51: error: no match for ‘operator*’ (operand types are ‘float’ and ‘InputPixelRealType {aka itk::Vector<double, 3u>}’)
static_cast< OutputPixelValueType >( *o_it ) *
I am wondering if I am instantiating the itk::GradientImageFilter with the correct template arguments. Can anyone help ?