Skip to content

abs_diff_imageAbsDiffImageAbsDiffImageabs_diff_imageabs_diff_imagešŸ”—

Short descriptionšŸ”—

abs_diff_imageAbsDiffImageAbsDiffImageabs_diff_imageabs_diff_image — Calculate the absolute difference of two images.

SignaturešŸ”—

abs_diff_image( image Image1, image Image2, out image ImageAbsDiff, number Mult )void AbsDiffImage( const HObject& Image1, const HObject& Image2, HObject* ImageAbsDiff, const HTuple& Mult )static void HOperatorSet.AbsDiffImage( HObject image1, HObject image2, out HObject imageAbsDiff, HTuple mult )def abs_diff_image( image_1: HObject, image_2: HObject, mult: Union[int, float] ) -> HObject

Herror abs_diff_image( const Hobject Image1, const Hobject Image2, Hobject* ImageAbsDiff, double Mult )

Herror T_abs_diff_image( const Hobject Image1, const Hobject Image2, Hobject* ImageAbsDiff, const Htuple Mult )

HImage HImage::AbsDiffImage( const HImage& Image2, const HTuple& Mult ) const

HImage HImage::AbsDiffImage( const HImage& Image2, double Mult ) const

HImage HImage.AbsDiffImage( HImage image2, HTuple mult )

HImage HImage.AbsDiffImage( HImage image2, double mult )

DescriptionšŸ”—

abs_diff_imageAbsDiffImage calculates the absolute difference between two images. The gray values \(g'\) of the output image ImageAbsDiffimageAbsDiffimage_abs_diff are calculated from the gray values \((g1,g2)\) of the input images (Image1image1image_1 and Image2image2image_2) as follows: g’ = |(g1 - g2)| * Mult If an overflow or an underflow occurs the resulting values are clipped.

Several images can be processed in one call. In this case, both input parameters contain the same number of images which are then processed in pairs. An output image is generated for every pair.

Please note that the runtime of the operator depends on the value of Multmultmult. For \(\textrm{Mult} = 1\), a special optimization is used. Since values of Multmultmult different from 1 cannot yield additional information, \(\textrm{Mult} = 1\) should be used in applications. All other values of Multmultmult should only be used for visualization purposes. Additionally, for byte, int1, int2, and uint2 images special optimizations are implemented for \(\textrm{Mult} = 1\) that use SIMD technology. The actual application of these special optimizations is controlled by the system parameter 'mmx_enable'"mmx_enable" (see set_systemSetSystem). If 'mmx_enable'"mmx_enable" is set to 'true'"true" (and the SIMD instruction set is available), the internal calculations are performed using SIMD technology.

abs_diff_imageAbsDiffImage can be executed on an OpenCL device for byte, int1, int2, uint2, int4, and real images. However, since for OpenCL 1.0 only single precision floating point is supported for all devices, and not all rounding modes are supported, the OpenCL implementation can produce slightly different results from the scalar or SIMD implementations.

AttentionšŸ”—

Note that the acceleration gained by SIMD technology is highest on large, compact input regions. However, in rare cases, the execution of abs_diff_imageAbsDiffImage might take significantly longer with SIMD technology than without, depending on the input region and the capabilities of the hardware. In these cases, the use of SIMD technology can be avoided by set_system(::'mmx_enable','false':).

Execution informationšŸ”—

Execution information
  • Supports OpenCL compute devices.

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on domain level.

ParametersšŸ”—

Image1image1image_1 (input_object) (multichannel-)image(-array) → object (byte* / int1* / int2* / uint2* / int4* / int8 / real*)HObject (byte* / int1* / int2* / uint2* / int4* / int8 / real*)HImage (byte* / int1* / int2* / uint2* / int4* / int8 / real*)HObject (byte* / int1* / int2* / uint2* / int4* / int8 / real*)Hobject (byte* / int1* / int2* / uint2* / int4* / int8 / real*) *allowed for compute devices

Input image 1.

Image2image2image_2 (input_object) (multichannel-)image(-array) → object (byte* / int1* / int2* / uint2* / int4* / int8 / real*)HObject (byte* / int1* / int2* / uint2* / int4* / int8 / real*)HImage (byte* / int1* / int2* / uint2* / int4* / int8 / real*)HObject (byte* / int1* / int2* / uint2* / int4* / int8 / real*)Hobject (byte* / int1* / int2* / uint2* / int4* / int8 / real*) *allowed for compute devices

Input image 2.

ImageAbsDiffimageAbsDiffimage_abs_diff (output_object) (multichannel-)image(-array) → object (byte / int1 / int2 / uint2 / int4 / int8 / real)HObject (byte / int1 / int2 / uint2 / int4 / int8 / real)HImage (byte / int1 / int2 / uint2 / int4 / int8 / real)HObject (byte / int1 / int2 / uint2 / int4 / int8 / real)Hobject * (byte / int1 / int2 / uint2 / int4 / int8 / real)

Absolute value of the difference of the input images.

Multmultmult (input_control) number → (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Union[int, float]Htuple (double / Hlong)

Scale factor.

Default: 1.01.0
Suggested values: 1.0, 2.0, 3.0, 4.01.0, 2.0, 3.0, 4.0
Restriction: Mult > 0

ResultšŸ”—

The operator abs_diff_imageAbsDiffImage returns the value 2 (H_MSG_TRUE) if the parameters are correct. The behavior in case of empty input (no input images available) is set via the operator set_system(::'no_object_result',<Result>:). If necessary an exception is raised.

Combinations with other operatorsšŸ”—

Combinations

Possible successors

thresholdThreshold

Alternatives

sub_imageSubImage

See also

add_imageAddImage, scale_imageScaleImage, dyn_thresholdDynThreshold

ModulešŸ”—

Foundation