ITK  6.0.0
Insight Toolkit
SphinxExamples/src/Core/Common/DemonstrateAllOperators/Code.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#include <vector>
int
main()
{
using DerivativeOperatorType = itk::DerivativeOperator<float, 2>;
using ForwardDifferenceOperatorType = itk::ForwardDifferenceOperator<float, 2>;
using GaussianDerivativeOperatorType = itk::GaussianDerivativeOperator<float, 2>;
using GaussianOperatorType = itk::GaussianOperator<float, 2>;
using ImageKernelOperatorType = itk::ImageKernelOperator<float, 2>;
using LaplacianOperatorType = itk::LaplacianOperator<float, 2>;
using SobelOperatorType = itk::SobelOperator<float, 2>;
using AnnulusOperatorType = itk::AnnulusOperator<float, 2>;
using BackwardDifferenceOperatorType = itk::BackwardDifferenceOperator<float, 2>;
std::vector<itk::NeighborhoodOperator<float, 2> *> operators;
operators.push_back(new DerivativeOperatorType);
operators.push_back(new ForwardDifferenceOperatorType);
operators.push_back(new GaussianDerivativeOperatorType);
operators.push_back(new GaussianOperatorType);
operators.push_back(new ImageKernelOperatorType);
operators.push_back(new LaplacianOperatorType);
operators.push_back(new SobelOperatorType);
operators.push_back(new AnnulusOperatorType);
operators.push_back(new BackwardDifferenceOperatorType);
auto radius = itk::Size<2>::Filled(1);
for (auto & operatorId : operators)
{
operatorId->SetDirection(0); // Create the operator for the X axis derivative
operatorId->CreateToRadius(radius);
// std::cout << *(operators[operatorId]) << std::endl;
// operators[operatorId]->Print(std::cout);
// std::cout << operators[operatorId]->GetNameOfClass() << std::endl;
for (auto i = -operatorId->GetSize()[0] / 2; i <= operatorId->GetSize()[0] / 2; ++i)
{
for (auto j = -operatorId->GetSize()[1] / 2; j <= operatorId->GetSize()[1] / 2; ++j)
{
offset[0] = i;
offset[1] = j;
unsigned int neighborhoodIndex = operatorId->GetNeighborhoodIndex(offset);
std::cout << operatorId->GetElement(neighborhoodIndex) << " ";
}
std::cout << std::endl;
}
}
return EXIT_SUCCESS;
}
itk::SobelOperator
A NeighborhoodOperator for performing a directional Sobel edge-detection operation at a pixel locatio...
Definition: itkSobelOperator.h:97
itkLaplacianOperator.h
itk::ImageKernelOperator
A NeighborhoodOperator whose coefficients are from an image.
Definition: itkImageKernelOperator.h:49
itk::AnnulusOperator
A NeighborhoodOperator for performing a matched filtering with an annulus (two concentric circles,...
Definition: itkAnnulusOperator.h:72
itk::Size::Filled
static constexpr Self Filled(const SizeValueType value)
Definition: itkSize.h:434
itkNeighborhoodOperator.h
itkBackwardDifferenceOperator.h
itk::BackwardDifferenceOperator
Operator whose inner product with a neighborhood returns a "half" derivative at the center of the nei...
Definition: itkBackwardDifferenceOperator.h:48
itkGaussianDerivativeOperator.h
itkSobelOperator.h
itk::GaussianOperator
A NeighborhoodOperator whose coefficients are a one dimensional, discrete Gaussian kernel.
Definition: itkGaussianOperator.h:69
itkAnnulusOperator.h
itk::Offset
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.
Definition: itkOffset.h:66
itkForwardDifferenceOperator.h
itk::ForwardDifferenceOperator
Operator whose inner product with a neighborhood returns a "half" derivative at the center of the nei...
Definition: itkForwardDifferenceOperator.h:47
itk::DerivativeOperator
A NeighborhoodOperator for taking an n-th order derivative at a pixel.
Definition: itkDerivativeOperator.h:68
itk::Offset::GetElement
OffsetValueType GetElement(unsigned long element) const
Definition: itkOffset.h:215
itkImageKernelOperator.h
itkDerivativeOperator.h
itkGaussianOperator.h
itk::GaussianDerivativeOperator
A NeighborhoodOperator whose coefficients are a one dimensional, discrete derivative Gaussian kernel.
Definition: itkGaussianDerivativeOperator.h:105
itk::LaplacianOperator
A NeighborhoodOperator for use in calculating the Laplacian at a pixel.
Definition: itkLaplacianOperator.h:67