Herror ::check_difference (
    Hobject Image,
    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 HImageArray &Pattern,
    const HTuple &Mode,
    const HTuple &DiffLowerBound,
    const HTuple &DiffUpperBound,
    const HTuple &GrayOffset,
    const HTuple &AddRow,
    const HTuple &AddCol
) const
HRegionArray HImageArray::CheckDifference (
    const HImageArray &Pattern,
    const HTuple &Mode,
    const HTuple &DiffLowerBound,
    const HTuple &DiffUpperBound,
    const HTuple &GrayOffset,
    const HTuple &AddRow,
    const HTuple &AddCol
) const

Compare two images pixel by pixel.

::check_difference selects from the input image Image those pixels (g_{o} = g_{Image}), whose gray value difference to the corresponding pixels in Pattern is inside (outside) of the interval [DiffLowerBound,DiffLowerBound]. The pixels of Pattern are translated by (AddRow,AddCol) with respect to Image. Let g_{p} be the gray value from Pattern translated by (AddRow,AddCol) w.r.t. g_{o}.

If the selected mode Mode is 'diff_inside', a pixel g_{o} is selected if

       g_o - g_p - GrayOffset > DiffLowerBound   and
       g_o - g_p - GrayOffset < DiffUpperBound.
If the mode is set to '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 Image, intersected with the domain of the translated Pattern. All points fulfilling the above condition are aggregated in the output region. The two images may be of different size. Typically, Pattern is smaller than Image.


Parameters

Image (input_object)
image(-array) -> Hobject: HImage(Array) ( byte )
Image to be examined.

Pattern (input_object)
image(-array) -> Hobject: HImage(Array) ( byte )
Comparison image.

Selected (output_object)
region(-array) -> Hobject * : HRegion(Array)
Points in which the two images are similar/different.

Mode (input_control)
string -> HTuple.char *
Mode: return similar or different pixels.
Default value: 'diff_outside'
Suggested values: 'diff_inside', 'diff_outside'

DiffLowerBound (input_control)
number -> HTuple.long
Lower bound of the tolerated gray value difference.
Default value: -5
Suggested values: 0, -1, -2, -3, -5, -7, -10, -12, -15, -17, -20, -25, -30
Typical range of values: -255 <= DiffLowerBound <= 255 (lin)
Minimum increment: 1
Recommended increment: 2
Restriction: (-255 <= DiffLowerBound) && (DiffLowerBound <= 255)

DiffUpperBound (input_control)
number -> HTuple.long
Upper bound of the tolerated gray value difference.
Default value: 5
Suggested values: 0, 1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 30
Typical range of values: -255 <= DiffUpperBound <= 255 (lin)
Minimum increment: 1
Recommended increment: 2
Restriction: (-255 <= DiffUpperBound) && (DiffUpperBound <= 255)

GrayOffset (input_control)
number -> HTuple.long
Offset gray value subtracted from Image.
Default value: 0
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
Typical range of values: -255 <= GrayOffset <= 255 (lin)
Minimum increment: 1
Recommended increment: 2
Restriction: (-255 <= GrayOffset) && (GrayOffset <= 255)

AddRow (input_control)
point.y -> HTuple.long
Row coordinate, by which Pattern is translated.
Default value: 0
Suggested values: -200, -100, -20, -10, 0, 10, 20, 100, 200
Typical range of values: -32000 <= AddRow <= 32000 (lin)
Minimum increment: 1
Recommended increment: 1

AddCol (input_control)
point.x -> HTuple.long
Column coordinate, by which Pattern is translated.
Default value: 0
Suggested values: -200, -100, -20, -10, 0, 10, 20, 100, 200
Typical range of values: -32000 <= AddCol <= 32000 (lin)
Minimum increment: 1
Recommended increment: 1


Complexity

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


Result

::check_difference returns 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', 'empty_region_result', and 'store_empty_region' with ::set_system. If necessary, an exception is raised.


Possible Successors

::connection, ::select_shape, ::reduce_domain, ::select_gray, ::rank_region, ::dilation1, ::opening


Alternatives

::sub_image, ::dyn_threshold


Module

Region processing



Copyright © 1996-2002 MVTec Software GmbH