ITK/Examples/Broken/ImageProcessing/GradientOfVectorImage
Can't instantiate a GradientImageFilter with a vector image type?
The compiler errors are: /home/doriad/src/ITK/Code/Common/itkConceptChecking.h: In member function ‘void itk::Concept::Convertible<T1, T2>::Constraints::constraints() [with T1 = itk::CovariantVector<float, 2u>, T2 = float]’: /home/doriad/src/ITK/Code/Common/itkConceptChecking.h:192: instantiated from ‘itk::Concept::Convertible<itk::CovariantVector<float, 2u>, float>’ /home/doriad/src/ITK/Code/BasicFilters/itkGradientImageFilter.h:119: instantiated from ‘itk::GradientImageFilter<itk::Image<itk::CovariantVector<float, 2u>, 2u>, itk::CovariantVector<float, 2u>, float>’ /media/portable/Examples/c++/src/ITK/GradientOfVectorImage/GradientOfVectorImage.cxx:37: instantiated from here /home/doriad/src/ITK/Code/Common/itkConceptChecking.h:185: error: invalid static_cast from type ‘itk::CovariantVector<float, 2u>’ to type ‘float’
GradientOfVectorImage.cxx
<source lang="cpp">
- include "itkImage.h"
- include "itkCovariantVector.h"
- include "itkGradientImageFilter.h"
- include "itkImageRegionIterator.h"
int main(int argc, char * argv[]) {
// Setup types typedef itk::CovariantVector<float, 2> VectorType; typedef itk::Image<VectorType, 2> VectorImageType; VectorImageType::Pointer image = VectorImageType::New();
itk::Size<2> size; size[0] = 5; size[1] = 5;
itk::Index<2> index; index[0] = 0; index[1] = 0;
VectorImageType::RegionType region; region.SetSize(size); region.SetIndex(index);
image->SetRegions(region); image->Allocate();
itk::ImageRegionIterator<VectorImageType> iterator(image, region);
while(!iterator.IsAtEnd()) { } // Create and setup a gradient filter typedef itk::GradientImageFilter< VectorImageType, VectorType> GradientFilterType; GradientFilterType::Pointer gradientFilter = GradientFilterType::New(); gradientFilter->SetInput(image); gradientFilter->Update();
return EXIT_SUCCESS;
}
</source>
CMakeLists.txt
<source lang="cmake"> cmake_minimum_required(VERSION 2.6)
PROJECT(GradientOfVectorImage)
FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})
ADD_EXECUTABLE(GradientOfVectorImage GradientOfVectorImage.cxx) TARGET_LINK_LIBRARIES(GradientOfVectorImage ITKBasicFilters ITKIO ITKCommon)
</source>