Skip to content

check_differenceCheckDifferenceCheckDifferencecheck_differencecheck_difference🔗

Short description🔗

check_differenceCheckDifferenceCheckDifferencecheck_differencecheck_difference — Compare two images pixel by pixel.

Signature🔗

check_difference( image Image, image Pattern, out region Selected, string Mode, number DiffLowerBound, number DiffUpperBound, number GrayOffset, point.y AddRow, point.x AddCol )void CheckDifference( const HObject& Image, const HObject& Pattern, HObject* Selected, const HTuple& Mode, const HTuple& DiffLowerBound, const HTuple& DiffUpperBound, const HTuple& GrayOffset, const HTuple& AddRow, const HTuple& AddCol )static void HOperatorSet.CheckDifference( HObject image, HObject pattern, out HObject selected, HTuple mode, HTuple diffLowerBound, HTuple diffUpperBound, HTuple grayOffset, HTuple addRow, HTuple addCol )def check_difference( image: HObject, pattern: HObject, mode: str, diff_lower_bound: int, diff_upper_bound: int, gray_offset: int, add_row: int, add_col: int ) -> HObject

Herror check_difference( const Hobject Image, const Hobject Pattern, Hobject* Selected, const char* Mode, const Hlong DiffLowerBound, const Hlong DiffUpperBound, const Hlong GrayOffset, const Hlong AddRow, const Hlong AddCol )

Herror T_check_difference( const Hobject Image, const Hobject Pattern, Hobject* Selected, const Htuple Mode, const Htuple DiffLowerBound, const Htuple DiffUpperBound, const Htuple GrayOffset, const Htuple AddRow, const Htuple AddCol )

HRegion HImage::CheckDifference( const HImage& Pattern, const HString& Mode, Hlong DiffLowerBound, Hlong DiffUpperBound, Hlong GrayOffset, Hlong AddRow, Hlong AddCol ) const

HRegion HImage::CheckDifference( const HImage& Pattern, const char* Mode, Hlong DiffLowerBound, Hlong DiffUpperBound, Hlong GrayOffset, Hlong AddRow, Hlong AddCol ) const

HRegion HImage::CheckDifference( const HImage& Pattern, const wchar_t* Mode, Hlong DiffLowerBound, Hlong DiffUpperBound, Hlong GrayOffset, Hlong AddRow, Hlong AddCol ) const (Windows only)

HRegion HImage.CheckDifference( HImage pattern, string mode, int diffLowerBound, int diffUpperBound, int grayOffset, int addRow, int addCol )

Description🔗

check_differenceCheckDifference selects from the input image Imageimageimage those pixels (\(g_{o} = g_{\textrm{Image}}\)), whose gray value difference to the corresponding pixels in Patternpatternpattern is inside (outside) of the interval \([\textrm{DiffLowerBound}, \textrm{DiffUpperBound}]\). The pixels of Patternpatternpattern are translated by \((\textrm{AddRow},\textrm{AddCol})\) with respect to Imageimageimage. Let \(g_{p}\) be the gray value from Patternpatternpattern translated by \((\textrm{AddRow},\textrm{AddCol})\) with respect to \(g_{o}\).

If the selected mode Modemodemode is 'diff_inside'"diff_inside", a pixel \(g_{o}\) is selected if

\[\begin{eqnarray*} g_o - g_p - \textrm{GrayOffset} \ge \textrm{DiffLowerBound} & & \mbox{\rm and} \\ g_o - g_p - \textrm{GrayOffset} \le \textrm{DiffUpperBound}. & & \end{eqnarray*}\]

If the mode is set to 'diff_outside'"diff_outside", a pixel \(g_{o}\) is selected if

         g_o - g_p - GrayOffset < DiffLowerBound   or
         g_o - g_p - GrayOffset > DiffUpperBound.

This test is performed for all points of the domain (region) of Imageimageimage, intersected with the domain of the translated Patternpatternpattern. All points fulfilling the above condition are aggregated in the output region. The two images may be of different size. Typically, Patternpatternpattern is smaller than Imageimageimage.

Execution information🔗

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

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

Parameters🔗

Imageimageimage (input_object) singlechannelimage(-array) → object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject (byte)

Input image.

Patternpatternpattern (input_object) singlechannelimage(-array) → object (byte)HObject (byte)HImage (byte)HObject (byte)Hobject (byte)

Comparison image.

Selectedselectedselected (output_object) region(-array) → objectHObjectHRegionHObjectHobject *

Points in which the two images are similar/different.

Modemodemode (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Mode: return similar or different pixels.

Default: 'diff_outside'"diff_outside"
Suggested values: 'diff_inside', 'diff_outside'"diff_inside", "diff_outside"

DiffLowerBounddiffLowerBounddiff_lower_bound (input_control) number → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Lower bound of the tolerated gray value difference.

Default: -5-5
Suggested values: 0, -1, -2, -3, -5, -7, -10, -12, -15, -17, -20, -25, -300, -1, -2, -3, -5, -7, -10, -12, -15, -17, -20, -25, -30
Value range: -255 ≤ DiffLowerBound ≤ 255 (lin)
Minimum increment: 1
Recommended increment: 2

DiffUpperBounddiffUpperBounddiff_upper_bound (input_control) number → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Upper bound of the tolerated gray value difference.

Default: 55
Suggested values: 0, 1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 300, 1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 30
Value range: -255 ≤ DiffUpperBound ≤ 255 (lin)
Minimum increment: 1
Recommended increment: 2

GrayOffsetgrayOffsetgray_offset (input_control) number → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Offset gray value subtracted from the input image.

Default: 00
Suggested values: -30, -25, -20, -17, -15, -12, -10, -7, -5, -3, -2, -1, 0, 1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 30-30, -25, -20, -17, -15, -12, -10, -7, -5, -3, -2, -1, 0, 1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 30
Value range: -255 ≤ GrayOffset ≤ 255 (lin)
Minimum increment: 1
Recommended increment: 2

AddRowaddRowadd_row (input_control) point.y → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Row coordinate by which the comparison image is translated.

Default: 00
Suggested values: -200, -100, -20, -10, 0, 10, 20, 100, 200-200, -100, -20, -10, 0, 10, 20, 100, 200
Value range: -32000 ≤ AddRow ≤ 32000 (lin)
Minimum increment: 1
Recommended increment: 1

AddColaddColadd_col (input_control) point.x → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Column coordinate by which the comparison image is translated.

Default: 00
Suggested values: -200, -100, -20, -10, 0, 10, 20, 100, 200-200, -100, -20, -10, 0, 10, 20, 100, 200
Value range: -32000 ≤ AddCol ≤ 32000 (lin)
Minimum increment: 1
Recommended increment: 1

Complexity🔗

Let \(A\) be the number of valid pixels. Then the runtime complexity is \(O(A)\).

Result🔗

check_differenceCheckDifference returns 2 (H_MSG_TRUE) if all parameters are correct. The behavior with respect to the input images and output regions can be determined by setting the values of the flags 'no_object_result'"no_object_result", 'empty_region_result'"empty_region_result", and 'store_empty_region'"store_empty_region" with set_systemSetSystem. If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible successors

connectionConnection, select_shapeSelectShape, reduce_domainReduceDomain, select_graySelectGray, rank_regionRankRegion, dilation1Dilation1, openingOpening

Alternatives

sub_imageSubImage, dyn_thresholdDynThreshold

Module🔗

Foundation