Gradient of Vector Image#
Warning
Fix Problem Contains problems not fixed from original wiki.
Synopsis#
Compute the gradient of a vector image.
Results#
Note
Help Wanted Implementation of Results for sphinx examples containing this message. Reconfiguration of CMakeList.txt may be necessary. Write An Example <https://itk.org/ITKExamples/Documentation/Contribute/WriteANewExample.html>
Code#
C++#
#include "itkImage.h"
#include "itkCovariantVector.h"
#include "itkGradientImageFilter.h"
#include "itkImageRegionIterator.h"
int
main(int argc, char * argv[])
{
// Setup types
using VectorType = itk::CovariantVector<float, 2>;
using VectorImageType = itk::Image<VectorType, 2>;
auto 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
using GradientFilterType = itk::GradientImageFilter<VectorImageType, VectorType>;
auto gradientFilter = GradientFilterType::New();
gradientFilter->SetInput(image);
gradientFilter->Update();
return EXIT_SUCCESS;
}
Classes demonstrated#
-
template<typename TInputImage, typename TOperatorValueType = float, typename TOutputValueType = float, typename TOutputImageType = Image<CovariantVector<TOutputValueType, TInputImage::ImageDimension>, TInputImage::ImageDimension>>
class GradientImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImageType> Computes the gradient of an image using directional derivatives.
Computes the gradient of an image using directional derivatives. The directional derivative at each pixel location is computed by convolution with a first-order derivative operator.
The second template parameter defines the value type used in the derivative operator (defaults to float). The third template parameter defines the value type used for output image (defaults to float). The output image is defined as a covariant vector image whose value type is specified as this third template parameter.
- See
Image
- See
Neighborhood
- See
NeighborhoodOperator
- See
NeighborhoodIterator
- ITK Sphinx Examples: