You are here: Start » Function Reference » Image » Image Local Transforms » GradientMagnitudeImage

Header: | FIL.h |
---|---|

Namespace: | fil |

Module: | FoundationLite |

Measures the strength of gradient at each pixel location.

### Syntax

void fil::GradientMagnitudeImage ( const fil::Image& inImage, ftl::Optional<const fil::Region&> inRoi, fil::GradientMaskOperator::Type inOperator, fil::MagnitudeMeasure::Type inMeasure, const int inScale, fil::Image& outValueImage )

### Parameters

Name | Type | Range | Default | Description | |
---|---|---|---|---|---|

inImage | const Image& | Input image | |||

inRoi | Optional<const Region&> | NIL | Range of output pixels to be computed | ||

inOperator | GradientMaskOperator::Type | Defines how the gradient is computed | |||

inMeasure | MagnitudeMeasure::Type | Hypot | Defines how the gradient magnitude is computed | ||

inScale | const int | 1 - 16 | 1 | Scales the resulting gradient magnitudes | |

outValueImage | Image& | Gradient magnitudes of the image |

### Description

The operation computes the magnitude of the intensity change at each pixel of the inImage. Firstly the selected inOperator is used to obtain two-dimensional gradient vector at each pixel. Then the magnitudes of the vectors are estimated using the inMeasure method.

Specified by inMeasure method computes magnitude (A) from horizontal gradient component (x) and vertical gradient component (y) using one of following formulas:

\[A_{Horizontal}=|x|\]
\[A_{Vertical}=|y|\]
\[A_{Average}=\frac{|x|+|y|}{2}\]
\[A_{Sum}=|x|+|y|\]
\[A_{Maximum}=Max(|x|,|y|)\]
\[A_{Hypot}=\sqrt{x^{2}+y^{2} }\]

The magnitudes are multiplied by inScale factor and saturated if they exceed the greatest value of their type.

### Examples

### Hardware Acceleration

This operation is optimized for SSSE3 technology for pixels of type: UINT8.

This operation is optimized for AVX2 technology for pixels of type: UINT8.

This operation is optimized for NEON technology for pixels of type: UINT8.

This operation supports automatic parallelization for multicore and multiprocessor systems.

### Errors

List of possible exceptions:

Error type | Description |
---|---|

DomainError |
Region exceeds an input image in GradientMagnitudeImage. |

### See Also

- GradientImage_Mask – Computes a gradient image with a Sobel or Prewitt operator.

- GradientImage – Computes a gradient image with smoothing operator of any size. The output pixels are signed.