ImageDev

- Getting Started
- ImageDev Python
- ImageDev C#
- ImageDev C++
- Licensing Information
- Redistributable Files
- Processing
- Image Manipulation
- - Synthetic Images
  - - RandomImage2d
    - RandomImage3d
    - RandomGaussianImage2d
    - RandomGaussianImage3d
    - RadialFunctionImage2d
    - RadialFunctionImage3d
    - OrientedLinesImage2d
    - OrientedLinesImage3d
    - RandomSphereImage3d
    - BoxGridImage2d
    - BoxGridImage3d
    - WedgeMaskImage3d
    - PointSpreadFunctionImage3d
  - Image Editing
  - - ConvertImage
    - ResetImage
    - CopyImage
    - PasteImage2d
    - PasteImage3d
    - CropImage2d
    - CropImage3d
    - SampleImage2d
    - SampleImage3d
    - InterlaceFrames2d
    - DeinterlaceFrames2d
  - Stack Operations
  - - SequenceConcatenation
    - SequenceToMultispectral
    - SequenceToVolume
    - VolumeToSequence
    - MultispectralToSequence
    - GetSliceFromVolume3d
    - SetSliceToVolume3d
    - GetObliqueSliceFromVolume3d
    - ImageStackProjection3d
    - VolumeProjection3d
- Geometry And Matching
- - Geometric Transforms
  - - Shearing3d
    - TranslateImage2d
    - TranslateImage3d
    - Flip2d
    - Flip3d
    - FlipImage2d
    - FlipImage3d
    - TransposeImage2d
    - TransposeImage3d
    - SwapQuadrants
    - Rotate2d
    - Rotate3d
    - RotationGenerator3d
    - Resize2d
    - Resize3d
    - RescaleByFactor
    - RescaleImageByFactor
    - ResampleAffine2d
    - ResampleAffine3d
    - ResampleElastic2d
    - SurfaceUnfolding3d
  - Pattern Recognition
  - - BinaryCorrelation2d
    - CrossCorrelation2d
    - CorrelationByDifference2d
    - CorrelationBySignChange2d
  - Registration
  - - ImagePrealignment3d
    - AffineRegistration
    - ElasticRegistration2d
- Arithmetic And Logic
- - Arithmetical Operations
  - - AbsoluteValue
    - AbsoluteMaximumWithImage
    - ArithmeticOperationWithImage
    - ArithmeticOperationWithValue
    - BlendWithImage
    - BlendWithValue
    - DirectionalBlending2d
    - CombineByMask
    - ImageFormula
    - EigenDecomposition2d
    - EigenDecomposition3d
  - Logical Operations
  - - MaskImage
    - LogicalOperationWithImage
    - LogicalOperationWithValue
    - LogicalNot
    - InvertImage
    - BitShift
- Image Filtering
- - Grayscale Transforms
  - - RescaleIntensity
    - StackRescaleIntensity
    - MatchContrast
    - HistogramEqualization
    - Clahe2d
    - Clahe3d
    - AdaptiveHistogramEqualization
    - ApplyGrayscaleLut
    - BackgroundImage2d
    - RadialBackgroundImage2d
    - ShadingCorrection
    - Exponential
    - Logarithm
    - Square
    - SquareRoot
    - RingArtifactRemoval3d
    - BeamHardeningCorrection3d
  - Color Transforms
  - - ColorToLightness
    - GetColorChannel
    - ColorToGrayscale
    - GrayscaleToColor
    - ColorSpaceConversion
    - ColorAntialiasing2d
    - BayerToRgb2d
    - DecorrelationStretch2d
    - BlendAlphaChannelWithImage
    - BlendAlphaChannelWithValue
  - Smoothing And Denoising
  - - BoxFilter2d
    - BoxFilter3d
    - MedianFilter2d
    - MedianFilter3d
    - GaussianFilter2d
    - GaussianFilter3d
    - ExponentialFilter2d
    - RecursiveExponentialFilter2d
    - RecursiveExponentialFilter3d
    - NonLocalMeansFilter2d
    - NonLocalMeansFilter3d
    - CurvatureDrivenDiffusion
    - BilateralFilter2d
    - BilateralFilter3d
    - MajorityFilter2d
    - MajorityFilter3d
    - SigmaFilter2d
    - SigmaFilter3d
    - Despeckle2d
    - Despeckle3d
    - NagaoFilter2d
    - NagaoFilter3d
    - SnnFilter2d
    - SnnFilter3d
    - FlowInpainting
  - Sharpening
  - - Deblurring2d
    - Delineate2d
    - Delineate3d
    - UnsharpMasking2d
    - UnsharpMasking3d
    - Shade2d
    - RichardsonLucyDeconvolution
  - Texture Filters
  - - MeanFilter2d
    - MeanFilter3d
    - VarianceFilter2d
    - VarianceFilter3d
    - SkewnessFilter2d
    - SkewnessFilter3d
    - KurtosisFilter2d
    - KurtosisFilter3d
    - ContrastFilter2d
    - ContrastFilter3d
    - VariationFilter2d
    - VariationFilter3d
    - EnergyFilter2d
    - EnergyFilter3d
    - EntropyFilter2d
    - EntropyFilter3d
    - AutocorrelationFilter
    - LocalAutocorrelationFilter2d
    - ImageCurvature2d
    - ImageCurvature3d
    - StructureEnhancementFilter2d
    - StructureEnhancementFilter3d
    - ScaleSpaceLogFilter2d
    - ScaleSpaceLogFilter3d
  - Frequency Domain
  - - ComplexFft
    - ComplexFftInverse
    - ComplexCenteredFft
    - ComplexCenteredFftInverse
    - CartesianToPolar2d
    - PolarToCartesian2d
    - ConvolutionWithImage
    - ConvolutionWithImage2d
    - RadialFrequencyFilter2d
    - GaborFiltering2d
- Edge Detection
- - Gradient
  - - GradientOperator2d
    - GradientOperator3d
    - VectorToMagnitude2d
    - VectorToMagnitude3d
    - GradientVector2d
    - GradientVector3d
    - GradientMagnitude2d
    - GradientMagnitude3d
    - MorphologicalGradient2d
    - MorphologicalGradient3d
    - RadialGradientCentered2d
    - RadialGradientCentered3d
    - RadialGradientContour2d
    - RadialGradientContour3d
    - RadialGradientLabel2d
    - RadialGradientLabel3d
  - Laplacian
  - - DobFilter2d
    - DobFilter3d
    - MorphologicalLaplacian
    - RecursiveLaplacian2d
    - RecursiveLaplacian3d
  - Other Derivatives
  - - GaussianDerivative2d
    - GaussianDerivative3d
    - GaussianHessianMatrix2d
    - GaussianHessianMatrix3d
    - GaussianGradientTensor2d
    - GaussianGradientTensor3d
  - Edge Marking
  - - ImageLocalMaxima2d
    - ImageLocalMaxima3d
    - RidgeDetection
    - ZeroCrossings2d
    - DijkstraShortestPath2d
    - EigenvaluesToStructureness2d
    - EigenvaluesToStructureness3d
    - TensorVoting2d
    - CannyEdgeDetector2d
    - CannyEdgeDetector3d
- Image Segmentation
- - Binarization
  - - Thresholding
    - ThresholdingByCriterion
    - AutoThresholdingBright
    - AutoThresholdingDark
    - ColorThresholding
    - TopHat
    - FeatureAdaptiveThresholding
    - AdaptiveThresholding2d
    - AdaptiveThresholding3d
    - HysteresisThresholding
  - Labeling
  - - Labeling2d
    - Labeling3d
    - ReorderLabels
    - AssignLabel
    - AddObjectToLabel
    - GroupCloseLabelsl2d
  - Feature Selection
  - - KillBorder2d
    - KillBorder3d
    - RemoveSmallSpots
    - ObjectBoundaries
    - BinarySmoothing2d
    - BinarySmoothing3d
    - LabelInterfaces
  - Separating And Filling
  - - FillHoles2d
    - FillHoles3d
    - RemoveSmallHoles
    - FillImageBorder3d
    - ExpandLabelBoundaries
    - SeparateObjects
    - HExtremaWatershed
    - SeparateObjectsByBlock
    - HExtremaWatershedByBlock
    - ConvexHull2d
  - Region Growing
  - - MarkerBasedWatershed2d
    - MarkerBasedWatershed3d
    - MarkerBasedWatershedByBlock
    - MarkerBasedWatershedBasinsByBlock
    - ExpandLabelsOnBackground
    - FloodFillThreshold2d
    - FloodFillThreshold3d
    - Waterpixel
  - Computational Geometry
  - - PolylineResampler2d
    - PolylineResampler3d
    - PolylineExtrusion3d
    - SurfaceFitting3d
- Mathematical Morphology
- - Erosion And Dilation
  - - Erosion2d
    - Erosion3d
    - Dilation2d
    - Dilation3d
    - ErosionDisk2d
    - ErosionDisk3d
    - ErosionBall3d
    - DilationDisk2d
    - DilationDisk3d
    - DilationBall3d
    - ErosionLine2d
    - ErosionLine3d
    - DilationLine2d
    - DilationLine3d
    - ErosionColor2d
    - DilationColor2d
    - SelectiveErosion2d
    - SelectiveErosion3d
    - SelectiveDilation2d
    - SelectiveDilation3d
  - Opening And Closing
  - - Opening2d
    - Opening3d
    - Closing2d
    - Closing3d
    - OpeningDisk2d
    - OpeningDisk3d
    - OpeningBall3d
    - ClosingDisk2d
    - ClosingDisk3d
    - ClosingBall3d
    - OpeningLine2d
    - OpeningLine3d
    - ClosingLine2d
    - ClosingLine3d
    - OpeningLineMaximum
    - ClosingLineMinimum
    - OpeningColor2d
    - ClosingColor2d
    - OpeningByReconstruction2d
    - OpeningByReconstruction3d
    - ClosingByReconstruction2d
    - ClosingByReconstruction3d
    - OpeningDiskByReconstruction2d
    - OpeningBallByReconstruction3d
    - ClosingDiskByReconstruction2d
    - ClosingBallByReconstruction3d
    - SelectiveOpening2d
    - SelectiveOpening3d
    - SelectiveClosing2d
    - SelectiveClosing3d
  - Hit Or Miss And Skeleton
  - - Skeleton
    - Centerline3d
    - InfluenceZones
    - Centroid2d
    - EndPoints2d
    - EndPoints3d
    - Pruning2d
    - Pruning3d
    - IsolatedPoints2d
    - IsolatedPoints3d
    - TriplePoints2d
    - InteriorPoints2d
    - ApplyMorphologicalLut2d
    - ApplyMorphologicalLut3d
  - Geodesic Transformations
  - - ReconstructionFromMarkers2d
    - ReconstructionFromMarkers3d
    - GrayscaleReconstruction2d
    - GrayscaleReconstruction3d
    - GrayscaleFillHoles2d
    - GrayscaleFillHoles3d
    - HExtrema2d
    - HExtrema3d
    - RegionalExtrema2d
    - RegionalExtrema3d
    - UltimateErosion
  - Distance Maps
  - - DistanceMap2d
    - DistanceMap3d
    - EuclideanDistanceMap3d
    - EuclideanDistanceMap2d
    - GeodesicDistanceMap
    - ClosestBoundaryPoints2d
    - ClosestBoundaryPoints3d
    - TimeMap
    - LocalThicknessMap3d
    - GeodesicPropagation2d
    - GeodesicMaxima
    - GeodesicMinima
- Image Analysis
- - Image Measurements
  - - BinaryAnalysis
    - Area2d
    - Area3d
    - IntensityIntegral2d
    - IntensityIntegral3d
    - ObjectCount
    - DistanceMean2d
    - EulerNumber2d
    - EulerNumber3d
    - FractalDimension
    - CurvatureIntegrals3d
  - Image Statistics
  - - IntensityExtrema
    - IntensityStatistics
    - IntensityMaskedStatistics
    - IntensityHistogram
    - IntensityBinHistogram
    - AutoThresholdingValue
    - CompareImage
    - CompareValue
    - SimilarityMetricValue
    - SsimValue2d
    - SsimValue3d
    - RegionSimilarity
    - RadialIntensityProfile2d
    - RadialIntensityProfile3d
    - CylindricalIntensityProfile3d
    - RadialAutocorrelationProfile
    - Cooccurrence2d
    - MeasureGaussianNoise
    - LocalMaxima2d
    - LocalMaxima3d
    - PeakExtractor
    - LocalDensityMap2d
    - LocalDensityMap3d
    - SegmentationMetrics
  - Individual Measurements
  - - VolumeFractionByLabel
    - LabelCountByRegion
    - VolumeFractionByRegion
    - LabelAnalysis
    - LabelFiltering
    - LabelFilteringAnalysis
    - FilterAnalysis
    - MeasurementToImage
    - FilterByMeasurement
    - SieveLabeling
  - Moments And Orientations
  - - MomentsOfInertia2d
    - MomentsOfInertia3d
    - InertiaMoment2d
    - Eccentricity2d
    - OrientationMapFourier3d
    - OrientationMatchingFourier3d
  - Morphometry
  - - ObjectVolume
    - TotalImageVolume
    - ObjectBoundaryArea
    - TotalImageBoundaryArea
    - AverageObjectAreaPerSlice3d
    - AverageObjectCountPerSlice3d
    - ObjectImageRatio
    - ObjectSpecificSurface
    - ObjectSurfaceDensity
    - PorosityPercentage3d
    - FragmentationIndex
    - StructureModelIndex3d
    - AverageObjectThickness3d
    - AverageSpaceThickness3d
    - ObjectLinearDensity3d
    - DegreeOfAnisotropy
  - Propagation
  - - AxisPropagationBinary3d
    - AxisPropagationBinaryWithSeeds3d
    - AxisPropagationLabel3d
    - AxisPropagationLabelWithSeeds3d
    - AxisPropagationDistance3d
    - EstimateShortestPath3d
    - PercolationThreshold3d
    - AxisConnectivity3d
    - CentroidPathTortuosity3d
- Machine Learning
- - Classification
  - - AutoSegmentation3Phases
    - AutoIntensityClassification
    - SupervisedTextureClassification2d
    - SupervisedTextureClassification3d
    - TextureClassificationCreate
    - TextureClassificationTrain
    - TextureClassificationApply
  - Deep learning
  - - OnnxPredictionFiltering2d
    - OnnxPredictionFiltering3d
    - OnnxPredictionSegmentation2d
    - OnnxPredictionSegmentation3d
    - OnnxPredictionTwoOutputs2d
    - OnnxPredictionTwoOutputs3d
- Business Application
- - Dental
  - - DentalWallSegmentation3d
    - DentalMeshExtraction3d
    - DentalUnfolding3d
- IO
- - Image Data
  - - ReadVipImage
    - WriteVipImage
  - Algebraic Data
  - - ReadArrayXd
    - ReadArrayXi64
    - WriteArrayXd
    - WriteArrayXi64
  - Model
  - - ReadOnnxModel
- CUDA
- - Geometry And Matching
  - - CudaCrossCorrelation2d
    - CudaTemplateMatching3d
  - Image Filtering
  - - CudaBoxFilter2d
    - CudaMedianFilter2d
    - CudaGaussianFilter3d
    - CudaAdaptiveManifoldNlmFilter
  - Mathematical Morphology
  - - CudaErosion2d
    - CudaDilation2d
    - CudaOpening2d
    - CudaClosing2d
- Utilities
- Initialization
- Processing
- Syntax Check
- Visualization
- Data Object
- Image Data
- Kernels
- - MorphologicalKernel2d
  - MorphologicalKernel3d
  - MorphologicalLut2d
  - MorphologicalLut3d
- Model
- - TextureClassificationModel
  - OnnxModel
- Global Measurements
- - Image Measurements
  - - Area2dMsr
    - Area3dMsr
    - IntensityIntegral2dMsr
    - IntensityIntegral3dMsr
    - ObjectCountMsr
    - DistanceMeanMsr
    - Euler2dMsr
    - Euler3dMsr
    - FractalMsr
    - CurvatureIntegralsMsr
  - Image Statistics
  - - IntensityExtremaMsr
    - StatisticsMsr
    - IntensityHistogramMsr
    - IntensityBinHistogramMsr
    - CompareMsr
    - SimilarityMetricValueMsr
    - SsimValueMsr
    - RegionSimilarityMsr
    - SegmentationMetricsObjectMsr
    - SegmentationMetricsImageMsr
    - CylindricalIntensityProfileMsr
    - RadialIntensityProfileMsr
    - CorrelationMsr
    - CoocurrrenceMsr
    - GaussianNoiseMsr
    - LocalMaximaMsr
    - PeakExtractorMsr
  - Individual Measurements
  - - VolumeFractionByLabelMsr
    - LabelCountByRegionMsr
    - VolumeFractionByRegionMsr
  - Moments And Orientations
  - - MomentsOfInertia2dMsr
    - MomentsOfInertia3dMsr
    - MeanInertiaMomentMsr
    - Eccentricity2dMsr
    - LocalOrientation3dMsr
  - Morphometry
  - - ObjectVolumeMsr
    - ImageVolumeMsr
    - ObjectBoundaryAreaMsr
    - ImageBoundaryAreaMsr
    - AverageObjectAreaPerSliceMsr
    - AverageObjectCountPerSliceMsr
    - ObjectImageRatioMsr
    - ObjectSpecificSurfaceMsr
    - ObjectSurfaceDensityMsr
    - PorosityPercentageMsr
    - FragmentationMsr
    - StructureModelIndexMsr
    - AverageObjectThicknessMsr
    - AverageSpaceThicknessMsr
    - ObjectLinearDensityMsr
    - AnisotropyDegreeMsr
  - Propagation
  - - AxisPropagationBinary3dMsr
    - AxisPropagationLabel3dMsr
    - AxisPropagationDistance3dMsr
    - PercolationThreshold3dMsr
    - CentroidTortuosity3dMsr
  - Geometry And Matching
  - - CrossCorrelation2dMsr
  - Edge Detection
  - - CannyEdgeDetectorMsr
  - Image Segmentation
  - - AutoThresholdingMsr
    - AutoSegmentation3PhasesMsr
  - Mathematical Morphology
  - - ApplyMorphologicalLutMsr
- Analysis Measurements
- - AnalysisMsr
  - Measurement
  - Native Measurements
  - - Geometry
    - Feret
    - Intensity
    - Histogram
    - Inertia
    - Locate
    - Segment
    - Cooccurrence
  - CustomMeasurement
  - MeasurementAttributes
  - - Quantile
    - Histogram
    - Feret2d
    - Feret3d
    - NeighborCount
    - Cooccurrence
    - Breadth3d
  - MeasurementGroup
- Measurement Information
- - FieldInformation
  - CustomMeasurementInfo
- CUDA
- - CudaContext
- User Guide
- First Steps
- - Hello ImageDev
  - Initialize ImageDev
- Image Management
- - Create 2D Image
  - Create 3D Image
  - Data Transfer
- Standard Processing
- - Denoising
  - Thresholding
- Image Analysis
- - Global Analysis
  - Label Analysis
  - Measurement Browsing
  - Measurement Group
  - Custom Analysis
- Advanced Processing
- - Algorithm Tracking
- Typical Use Cases
- - Particle Analysis
  - Pore Analysis

# GradientMagnitude2d

Provides different algorithms to perform an edge detection based on the first derivative of a two-dimensional image.
Access to parameter description
For an introduction:

- section Edge Detection
- section Gradient
- section Images Filters

GradientMagnitude2d computes a first order derivative in each image axis direction and then computes the magnitude of the gradient vectors by selecting its maximum component or its Euclidean norm.
The following algorithms are proposed to extract the edges of an image:

- Gaussian: It performs a convolution with the derivatives of a Gaussian function along each image axis.
- Sobel: It performs a convolution with the normalized Sobel Kernel: $$ \mathbf{G_x} = \frac{1}{8}\begin{bmatrix} -1 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1 \end{bmatrix} \quad \mbox{and} \quad \mathbf{G_y} = \frac{1}{8}\begin{bmatrix} -1 & -2 & -1 \\ 0 & 0 & 0 \\ 1 & 2 & 1 \end{bmatrix} $$
- Prewitt: It performs a convolution with the normalized Prewitt Kernel: $$ \mathbf{G_x} = \frac{1}{6}\begin{bmatrix} -1 & 0 & 1 \\ -1 & 0 & 1 \\ -1 & 0 & 1 \end{bmatrix} \quad \mbox{and} \quad \mathbf{G_y} = \frac{1}{6}\begin{bmatrix} -1 & -1 & -1 \\ 0 & 0 & 0 \\ 1 & 1 & 1 \end{bmatrix} $$

See also

- VectorToMagnitude2d
- GradientOperator3d
- MorphologicalGradient2d
- GradientVector2d

##
Function Syntax

This function returns outputImage.

    // Function prototype
    std::shared_ptr< iolink::ImageView >
    gradientMagnitude2d( std::shared_ptr< iolink::ImageView > inputImage,
                         GradientMagnitude2d::GradientOperator gradientOperator,
                         const iolink::Vector2d& standardDeviation,
                         GradientMagnitude2d::FilterMode filterMode,
                         GradientMagnitude2d::OutputType outputType,
                         GradientMagnitude2d::GradientMode gradientMode,
                         std::shared_ptr< iolink::ImageView > outputImage = nullptr );

This function returns outputImage.

    // Function prototype.
    gradient_magnitude_2d(input_image: idt.ImageType,
                          gradient_operator: GradientMagnitude2d.GradientOperator = GradientMagnitude2d.GradientOperator.GAUSSIAN,
                          standard_deviation: Union[Iterable[int], Iterable[float]] = [1, 1],
                          filter_mode: GradientMagnitude2d.FilterMode = GradientMagnitude2d.FilterMode.RECURSIVE,
                          output_type: GradientMagnitude2d.OutputType = GradientMagnitude2d.OutputType.SAME_AS_INPUT,
                          gradient_mode: GradientMagnitude2d.GradientMode = GradientMagnitude2d.GradientMode.AMPLITUDE_EUCLIDEAN,
                          output_image: idt.ImageType = None) -> idt.ImageType

This function returns outputImage.

    // Function prototype.
    public static IOLink.ImageView
    GradientMagnitude2d( IOLink.ImageView inputImage,
                         GradientMagnitude2d.GradientOperator gradientOperator = ImageDev.GradientMagnitude2d.GradientOperator.GAUSSIAN,
                         double[] standardDeviation = null,
                         GradientMagnitude2d.FilterMode filterMode = ImageDev.GradientMagnitude2d.FilterMode.RECURSIVE,
                         GradientMagnitude2d.OutputType outputType = ImageDev.GradientMagnitude2d.OutputType.SAME_AS_INPUT,
                         GradientMagnitude2d.GradientMode gradientMode = ImageDev.GradientMagnitude2d.GradientMode.AMPLITUDE_EUCLIDEAN,
                         IOLink.ImageView outputImage = null );

##
Class Syntax

    // Command constructor.
    GradientMagnitude2d();

    /// Gets the inputImage parameter.
    /// The input image.
    std::shared_ptr< iolink::ImageView > inputImage() const;
    /// Sets the inputImage parameter.
    /// The input image.
    void setInputImage( std::shared_ptr< iolink::ImageView > inputImage );

    /// Gets the gradientOperator parameter.
    /// The gradient operator to apply.
    GradientMagnitude2d::GradientOperator gradientOperator() const;
    /// Sets the gradientOperator parameter.
    /// The gradient operator to apply.
    void setGradientOperator( const GradientMagnitude2d::GradientOperator& gradientOperator );

    /// Gets the standardDeviation parameter.
    /// The standard deviation of the gaussian operator defines the gradient sharpness. Low values provide sharp gradient.
    iolink::Vector2d standardDeviation() const;
    /// Sets the standardDeviation parameter.
    /// The standard deviation of the gaussian operator defines the gradient sharpness. Low values provide sharp gradient.
    void setStandardDeviation( const iolink::Vector2d& standardDeviation );

    /// Gets the filterMode parameter.
    /// The gradient operator to apply.
    GradientMagnitude2d::FilterMode filterMode() const;
    /// Sets the filterMode parameter.
    /// The gradient operator to apply.
    void setFilterMode( const GradientMagnitude2d::FilterMode& filterMode );

    /// Gets the outputType parameter.
    /// The output image type to provide.
    GradientMagnitude2d::OutputType outputType() const;
    /// Sets the outputType parameter.
    /// The output image type to provide.
    void setOutputType( const GradientMagnitude2d::OutputType& outputType );

    /// Gets the gradientMode parameter.
    /// The output image to compute.
    GradientMagnitude2d::GradientMode gradientMode() const;
    /// Sets the gradientMode parameter.
    /// The output image to compute.
    void setGradientMode( const GradientMagnitude2d::GradientMode& gradientMode );

    /// Gets the outputImage parameter.
    /// The gradient amplitude output image.
    std::shared_ptr< iolink::ImageView > outputImage() const;
    /// Sets the outputImage parameter.
    /// The gradient amplitude output image.
    void setOutputImage( std::shared_ptr< iolink::ImageView > outputImage );

    // Method to launch the command.
    void execute();

    # Property of the inputImage parameter.
    GradientMagnitude2d.input_image
    # Property of the gradientOperator parameter.
    GradientMagnitude2d.gradient_operator
    # Property of the standardDeviation parameter.
    GradientMagnitude2d.standard_deviation
    # Property of the filterMode parameter.
    GradientMagnitude2d.filter_mode
    # Property of the outputType parameter.
    GradientMagnitude2d.output_type
    # Property of the gradientMode parameter.
    GradientMagnitude2d.gradient_mode
    # Property of the outputImage parameter.
    GradientMagnitude2d.output_image

    // Method to launch the command.
    execute()

    // Command constructor.
    GradientMagnitude2d()

    // Property of the inputImage parameter.
    GradientMagnitude2d.inputImage
    // Property of the gradientOperator parameter.
    GradientMagnitude2d.gradientOperator
    // Property of the standardDeviation parameter.
    GradientMagnitude2d.standardDeviation
    // Property of the filterMode parameter.
    GradientMagnitude2d.filterMode
    // Property of the outputType parameter.
    GradientMagnitude2d.outputType
    // Property of the gradientMode parameter.
    GradientMagnitude2d.gradientMode
    // Property of the outputImage parameter.
    GradientMagnitude2d.outputImage

    // Method to launch the command.
    Execute()

## Parameters

Parameter Name | Description | Type | Supported Values | Default Value
--- | --- | --- | --- | ---
| inputImage | The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr
| gradientOperator | The gradient operator to apply.
GAUSSIAN | The gradient is computed by convolution with the derivative of a Gaussian filter.
SOBEL | The gradient is computed using the Sobel algorithm.
PREWITT | The gradient is computed using the Prewitt algorithm.
| Enumeration |  | GAUSSIAN
| standardDeviation | The standard deviation of the gaussian operator defines the gradient sharpness. Low values provide sharp gradient. This parameter is ignored with the Sobel and Prewitt gradient operators. | Vector2d | >=0.1 | {1.f, 1.f}
| filterMode | The gradient operator to apply.
FINITE | This mode uses a Finite Impulse Response algorithm on the X and Y directions. This mode is faster for small standard deviation values. The kernel size value is four times the standard deviation and cannot be smaller than 5.
RECURSIVE | This mode uses an Infinite Impulse Response algorithm on the X and Y directions. The computation time is constant with this implementation. This mode is more precise for computing the Gaussian filter.
| Enumeration |  | RECURSIVE
| outputType | The output image type to provide.
SAME_AS_INPUT | The output image has same type as the input image. In the case of integer images, this mode can lead to a loss of precision.
FLOAT_32_BIT | The output image type is forced to floating point.
| Enumeration |  | SAME_AS_INPUT
| gradientMode | The output image to compute.
AMPLITUDE_MAXIMUM | This option computes the amplitude as the maximum between the X and Y components.
AMPLITUDE_EUCLIDEAN | This option computes the Euclidean norm of the vector.
| Enumeration |  | AMPLITUDE_EUCLIDEAN
| outputImage | The gradient amplitude output image. Dimensions, calibration, and interpretation of the output image are forced to the same values as the input. | Image |  | nullptr

Parameter Name | Description | Type | Supported Values | Default Value
--- | --- | --- | --- | ---
| input_image | The input image. | image | Binary, Label, Grayscale or Multispectral | None
| gradient_operator | The gradient operator to apply.
GAUSSIAN | The gradient is computed by convolution with the derivative of a Gaussian filter.
SOBEL | The gradient is computed using the Sobel algorithm.
PREWITT | The gradient is computed using the Prewitt algorithm.
| enumeration |  | GAUSSIAN
| standard_deviation | The standard deviation of the gaussian operator defines the gradient sharpness. Low values provide sharp gradient. This parameter is ignored with the Sobel and Prewitt gradient operators. | vector2d | >=0.1 | [1, 1]
| filter_mode | The gradient operator to apply.
FINITE | This mode uses a Finite Impulse Response algorithm on the X and Y directions. This mode is faster for small standard deviation values. The kernel size value is four times the standard deviation and cannot be smaller than 5.
RECURSIVE | This mode uses an Infinite Impulse Response algorithm on the X and Y directions. The computation time is constant with this implementation. This mode is more precise for computing the Gaussian filter.
| enumeration |  | RECURSIVE
| output_type | The output image type to provide.
SAME_AS_INPUT | The output image has same type as the input image. In the case of integer images, this mode can lead to a loss of precision.
FLOAT_32_BIT | The output image type is forced to floating point.
| enumeration |  | SAME_AS_INPUT
| gradient_mode | The output image to compute.
AMPLITUDE_MAXIMUM | This option computes the amplitude as the maximum between the X and Y components.
AMPLITUDE_EUCLIDEAN | This option computes the Euclidean norm of the vector.
| enumeration |  | AMPLITUDE_EUCLIDEAN
| output_image | The gradient amplitude output image. Dimensions, calibration, and interpretation of the output image are forced to the same values as the input. | image |  | None

Parameter Name | Description | Type | Supported Values | Default Value
--- | --- | --- | --- | ---
| inputImage | The input image. | Image | Binary, Label, Grayscale or Multispectral | null
| gradientOperator | The gradient operator to apply.
GAUSSIAN | The gradient is computed by convolution with the derivative of a Gaussian filter.
SOBEL | The gradient is computed using the Sobel algorithm.
PREWITT | The gradient is computed using the Prewitt algorithm.
| Enumeration |  | GAUSSIAN
| standardDeviation | The standard deviation of the gaussian operator defines the gradient sharpness. Low values provide sharp gradient. This parameter is ignored with the Sobel and Prewitt gradient operators. | Vector2d | >=0.1 | {1f, 1f}
| filterMode | The gradient operator to apply.
FINITE | This mode uses a Finite Impulse Response algorithm on the X and Y directions. This mode is faster for small standard deviation values. The kernel size value is four times the standard deviation and cannot be smaller than 5.
RECURSIVE | This mode uses an Infinite Impulse Response algorithm on the X and Y directions. The computation time is constant with this implementation. This mode is more precise for computing the Gaussian filter.
| Enumeration |  | RECURSIVE
| outputType | The output image type to provide.
SAME_AS_INPUT | The output image has same type as the input image. In the case of integer images, this mode can lead to a loss of precision.
FLOAT_32_BIT | The output image type is forced to floating point.
| Enumeration |  | SAME_AS_INPUT
| gradientMode | The output image to compute.
AMPLITUDE_MAXIMUM | This option computes the amplitude as the maximum between the X and Y components.
AMPLITUDE_EUCLIDEAN | This option computes the Euclidean norm of the vector.
| Enumeration |  | AMPLITUDE_EUCLIDEAN
| outputImage | The gradient amplitude output image. Dimensions, calibration, and interpretation of the output image are forced to the same values as the input. | Image |  | null

## Object Examples

    auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

    GradientMagnitude2d gradientMagnitude2dAlgo;
    gradientMagnitude2dAlgo.setInputImage( polystyrene );
    gradientMagnitude2dAlgo.setGradientOperator( GradientMagnitude2d::GradientOperator::GAUSSIAN );
    gradientMagnitude2dAlgo.setStandardDeviation( {1, 1} );
    gradientMagnitude2dAlgo.setFilterMode( GradientMagnitude2d::FilterMode::RECURSIVE );
    gradientMagnitude2dAlgo.setOutputType( GradientMagnitude2d::OutputType::SAME_AS_INPUT );
    gradientMagnitude2dAlgo.setGradientMode( GradientMagnitude2d::GradientMode::AMPLITUDE_EUCLIDEAN );
    gradientMagnitude2dAlgo.execute();

    std::cout << "outputImage:" << gradientMagnitude2dAlgo.outputImage()->toString();

    polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

    gradient_magnitude_2d_algo = imagedev.GradientMagnitude2d()
    gradient_magnitude_2d_algo.input_image = polystyrene
    gradient_magnitude_2d_algo.gradient_operator = imagedev.GradientMagnitude2d.GAUSSIAN
    gradient_magnitude_2d_algo.standard_deviation = [1, 1]
    gradient_magnitude_2d_algo.filter_mode = imagedev.GradientMagnitude2d.RECURSIVE
    gradient_magnitude_2d_algo.output_type = imagedev.GradientMagnitude2d.SAME_AS_INPUT
    gradient_magnitude_2d_algo.gradient_mode = imagedev.GradientMagnitude2d.AMPLITUDE_EUCLIDEAN
    gradient_magnitude_2d_algo.execute()

    print("output_image:", str(gradient_magnitude_2d_algo.output_image))

    ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

    GradientMagnitude2d gradientMagnitude2dAlgo = new GradientMagnitude2d
    {
        inputImage = polystyrene,
        gradientOperator = GradientMagnitude2d.GradientOperator.GAUSSIAN,
        standardDeviation = new double[]{1, 1},
        filterMode = GradientMagnitude2d.FilterMode.RECURSIVE,
        outputType = GradientMagnitude2d.OutputType.SAME_AS_INPUT,
        gradientMode = GradientMagnitude2d.GradientMode.AMPLITUDE_EUCLIDEAN
    };
    gradientMagnitude2dAlgo.Execute();

    Console.WriteLine( "outputImage:" + gradientMagnitude2dAlgo.outputImage.ToString() );

## Function Examples

    auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

    auto result = gradientMagnitude2d( polystyrene, GradientMagnitude2d::GradientOperator::GAUSSIAN, {1, 1}, GradientMagnitude2d::FilterMode::RECURSIVE, GradientMagnitude2d::OutputType::SAME_AS_INPUT, GradientMagnitude2d::GradientMode::AMPLITUDE_EUCLIDEAN );

    std::cout << "outputImage:" << result->toString();

    polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

    result = imagedev.gradient_magnitude_2d(polystyrene, imagedev.GradientMagnitude2d.GAUSSIAN, [1, 1], imagedev.GradientMagnitude2d.RECURSIVE, imagedev.GradientMagnitude2d.SAME_AS_INPUT, imagedev.GradientMagnitude2d.AMPLITUDE_EUCLIDEAN)

    print("output_image:", str(result))

    ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

    IOLink.ImageView result = Processing.GradientMagnitude2d( polystyrene, GradientMagnitude2d.GradientOperator.GAUSSIAN, new double[]{1, 1}, GradientMagnitude2d.FilterMode.RECURSIVE, GradientMagnitude2d.OutputType.SAME_AS_INPUT, GradientMagnitude2d.GradientMode.AMPLITUDE_EUCLIDEAN );

    Console.WriteLine( "outputImage:" + result.ToString() );

© 2025 Thermo Fisher Scientific Inc. All rights reserved.