Back to Aurora Vision Library website

You are here: Start » Function Reference » Image » Image Metrics » ImageDifference

ImageDifference


Header: AVL.h
Namespace: avl
Module: FoundationBasic

Measures dissimilarity between two images.

Syntax

C++
C#
 
void avl::ImageDifference
(
	const avl::Image& inImage,
	const avl::Image& inPatternImage,
	atl::Optional<const avl::Region&> inRoi,
	avl::DistanceMeasure::Type inDistanceMeasure,
	float& outDifference
)

Parameters

Name Type Default Description
Input value inImage const Image& Input image
Input value inPatternImage const Image& Pattern to be compared with input image
Input value inRoi Optional<const Region&> NIL Range of pixels to be processed
Input value inDistanceMeasure DistanceMeasure::Type Measure of distance
Output value outDifference float& Value of difference between pattern and image

Description

The operation computes the approximate difference between two images using the selected distance measure.

  • If the inDistanceMeasure is set to MeanError then the resulting outDifference is the average difference between corresponding pixel values of the images.
  • If the inDistanceMeasure is set to MeanSquaredError then the resulting outDifference is the average squared difference between corresponding pixel values of the images.

The operation requires that the images being processed have equal format and dimensions, otherwise an error with appropriate description occurs. To obtain an image of desired dimensions one can use ResizeImage or CropImage filter. To alter the format of an image one can use filters contained in Image Conversions category.

Examples

Mean error between the sample images equals 16.034.

Mean squared error between the sample images equals 2754.164.

Hardware Acceleration

This operation is optimized for SSE2 technology for pixels of types: UINT8 (for inDistanceMeasure = MeanError).

This operation is optimized for SSE3 technology for pixels of types: UINT16 (for inDistanceMeasure = MeanError), UINT8 (for inDistanceMeasure = MeanSquaredError), REAL.

This operation is optimized for SSE4 technology for pixels of types: INT16, UINT16 (for inDistanceMeasure = MeanSquaredError).

This operation is optimized for AVX2 technology for pixels of types: UINT8, INT16, UINT16, REAL.

This operation is optimized for NEON technology for pixels of types: UINT8, UINT16 (for inDistanceMeasure = MeanError), INT16 (for inDistanceMeasure = MeanError), REAL.

This operation supports automatic parallelization for multicore and multiprocessor systems.

Errors

List of possible exceptions:

Error type Description
DomainError Not supported distance measure in ImageDifference.

See Also

  • ImageDifferenceImage – Computes an image of differences between a moving pattern and the input image.
  • LocateMultipleObjects_SAD – Finds multiple occurrences of a predefined template on an image by analysing the Square Average Difference between pixel values.
  • DifferenceImage – Computes the non-negative distances between corresponding pixel values.