ITK/Examples/Broken/ImageProcessing/GradientOfVectorImage: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
No edit summary
(Deprecated content that is moved to sphinx)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Can't instantiate a GradientImageFilter with a vector image type?
{{warning|1=The media wiki content on this page is no longer maintained.  The examples presented on the https://itk.org/Wiki/*  pages likely require ITK version 4.13 or earlier releasesIn many cases, the examples on this page no longer conform to the best practices for modern ITK versions.}}
 
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>
 
{{ITKCMakeLists|GradientOfVectorImage}}

Latest revision as of 20:46, 7 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.