ClassesClassesClassesClasses | | | | Operators

prepare_direct_variation_modelprepare_direct_variation_modelPrepareDirectVariationModelprepare_direct_variation_modelPrepareDirectVariationModelPrepareDirectVariationModel (Operator)

Name

prepare_direct_variation_modelprepare_direct_variation_modelPrepareDirectVariationModelprepare_direct_variation_modelPrepareDirectVariationModelPrepareDirectVariationModel — Prepare a variation model for comparison with an image.

Signature

prepare_direct_variation_model(RefImage, VarImage : : ModelID, AbsThreshold, VarThreshold : )

Herror prepare_direct_variation_model(const Hobject RefImage, const Hobject VarImage, const Hlong ModelID, double AbsThreshold, double VarThreshold)

Herror T_prepare_direct_variation_model(const Hobject RefImage, const Hobject VarImage, const Htuple ModelID, const Htuple AbsThreshold, const Htuple VarThreshold)

Herror prepare_direct_variation_model(Hobject RefImage, Hobject VarImage, const HTuple& ModelID, const HTuple& AbsThreshold, const HTuple& VarThreshold)

void HVariationModel::PrepareDirectVariationModel(const HImage& RefImage, const HImage& VarImage, const HTuple& AbsThreshold, const HTuple& VarThreshold) const

void PrepareDirectVariationModel(const HObject& RefImage, const HObject& VarImage, const HTuple& ModelID, const HTuple& AbsThreshold, const HTuple& VarThreshold)

void HVariationModel::PrepareDirectVariationModel(const HImage& RefImage, const HImage& VarImage, const HTuple& AbsThreshold, const HTuple& VarThreshold) const

void HVariationModel::PrepareDirectVariationModel(const HImage& RefImage, const HImage& VarImage, double AbsThreshold, double VarThreshold) const

void HOperatorSetX.PrepareDirectVariationModel(
[in] IHUntypedObjectX* RefImage, [in] IHUntypedObjectX* VarImage, [in] VARIANT ModelID, [in] VARIANT AbsThreshold, [in] VARIANT VarThreshold)

void HVariationModelX.PrepareDirectVariationModel(
[in] IHImageX* RefImage, [in] IHImageX* VarImage, [in] VARIANT AbsThreshold, [in] VARIANT VarThreshold)

static void HOperatorSet.PrepareDirectVariationModel(HObject refImage, HObject varImage, HTuple modelID, HTuple absThreshold, HTuple varThreshold)

void HVariationModel.PrepareDirectVariationModel(HImage refImage, HImage varImage, HTuple absThreshold, HTuple varThreshold)

void HVariationModel.PrepareDirectVariationModel(HImage refImage, HImage varImage, double absThreshold, double varThreshold)

Description

prepare_direct_variation_modelprepare_direct_variation_modelPrepareDirectVariationModelprepare_direct_variation_modelPrepareDirectVariationModelPrepareDirectVariationModel prepares a variation model for the image comparison with compare_variation_modelcompare_variation_modelCompareVariationModelcompare_variation_modelCompareVariationModelCompareVariationModel or compare_ext_variation_modelcompare_ext_variation_modelCompareExtVariationModelcompare_ext_variation_modelCompareExtVariationModelCompareExtVariationModel. The variation model must have been created with Mode='direct'"direct""direct""direct""direct""direct" with create_variation_modelcreate_variation_modelCreateVariationModelcreate_variation_modelCreateVariationModelCreateVariationModel. In contrast to prepare_variation_modelprepare_variation_modelPrepareVariationModelprepare_variation_modelPrepareVariationModelPrepareVariationModel, the ideal image of the object and the corresponding variation image are not computed with train_variation_modeltrain_variation_modelTrainVariationModeltrain_variation_modelTrainVariationModelTrainVariationModel, but are specified directly in RefImageRefImageRefImageRefImageRefImagerefImage and VarImageVarImageVarImageVarImageVarImagevarImage. This is useful if the variation model should be created from a single image, as described with create_variation_modelcreate_variation_modelCreateVariationModelcreate_variation_modelCreateVariationModelCreateVariationModel. The variation image should typically be created with edge operators like sobel_ampsobel_ampSobelAmpsobel_ampSobelAmpSobelAmp, edges_imageedges_imageEdgesImageedges_imageEdgesImageEdgesImage, or gray_range_rectgray_range_rectGrayRangeRectgray_range_rectGrayRangeRectGrayRangeRect.

prepare_direct_variation_modelprepare_direct_variation_modelPrepareDirectVariationModelprepare_direct_variation_modelPrepareDirectVariationModelPrepareDirectVariationModel converts the ideal image RefImageRefImageRefImageRefImageRefImagerefImage and the variation image VarImageVarImageVarImageVarImageVarImagevarImage into two threshold images and stores them in the variation model. These threshold images are used in compare_variation_modelcompare_variation_modelCompareVariationModelcompare_variation_modelCompareVariationModelCompareVariationModel or compare_ext_variation_modelcompare_ext_variation_modelCompareExtVariationModelcompare_ext_variation_modelCompareExtVariationModelCompareExtVariationModel to perform the comparison of the current image to the variation model.

Two thresholds are used to compute the threshold images. The parameter AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold determines the minimum amount of gray levels by which the image of the current object must differ from the image of the ideal object. The parameter VarThresholdVarThresholdVarThresholdVarThresholdVarThresholdvarThreshold determines a factor relative to the variation image for the minimum difference of the current image and the ideal image. VarThresholdVarThresholdVarThresholdVarThresholdVarThresholdvarThreshold utilizes VarImageVarImageVarImageVarImageVarImagevarImage to define regions, in which differences in gray values may occur which should not be counted as errors. This allows variations for specific parts of the object to inspect. AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold and VarThresholdVarThresholdVarThresholdVarThresholdVarThresholdvarThreshold each can contain one or two values. If two values are specified, different thresholds can be determined for too bright and too dark pixels. In this mode, the first value refers to too bright pixels, while the second value refers to too dark pixels. If one value is specified, this value refers to both the too bright and too dark pixels. Let i(x,y) be the ideal image RefImageRefImageRefImageRefImageRefImagerefImage, v(x,y) the variation image VarImageVarImageVarImageVarImageVarImagevarImage, a{u}=AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold[0], a{l}=AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold[1], b{u}=VarThresholdVarThresholdVarThresholdVarThresholdVarThresholdvarThreshold[0], and b{l}=VarThresholdVarThresholdVarThresholdVarThresholdVarThresholdvarThreshold[1] (or a{u}=AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold, a{l}=AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold, b{u}=VarThresholdVarThresholdVarThresholdVarThresholdVarThresholdvarThreshold, and b{l}=VarThresholdVarThresholdVarThresholdVarThresholdVarThresholdvarThreshold, respectively). Then the two threshold images t{u,l} are computed as follows:

  t{u}(x,y) = i(x,y) + max{a{u},b{u}*v(x,y)}
  t{l}(x,y) = i(x,y) - max{a{l},b{l}*v(x,y)}

If the current image c(x,y) is compared to the variation model using compare_variation_modelcompare_variation_modelCompareVariationModelcompare_variation_modelCompareVariationModelCompareVariationModel, the output region contains all points that differ substantially from the model, i.e., that fulfill the following condition:

  c(x,y) > t{u}(x,y) or c(x,y) < t{l}(x,y) .

In compare_ext_variation_modelcompare_ext_variation_modelCompareExtVariationModelcompare_ext_variation_modelCompareExtVariationModelCompareExtVariationModel, extended comparison modes are available, which return only too bright errors, only too dark errors, or bright and dark errors as separate regions.

After the threshold images have been created they can be read out with get_thresh_images_variation_modelget_thresh_images_variation_modelGetThreshImagesVariationModelget_thresh_images_variation_modelGetThreshImagesVariationModelGetThreshImagesVariationModel.

It should be noted that RefImageRefImageRefImageRefImageRefImagerefImage and VarImageVarImageVarImageVarImageVarImagevarImage are not stored as the ideal and variation images in the model to save memory in the model.

Parallelization

Parameters

RefImageRefImageRefImageRefImageRefImagerefImage (input_object)  singlechannelimage objectHImageHImageHImageHImageXHobject (byte / int2 / uint2)

Reference image of the object.

VarImageVarImageVarImageVarImageVarImagevarImage (input_object)  singlechannelimage objectHImageHImageHImageHImageXHobject (byte / int2 / uint2)

Variation image of the object.

ModelIDModelIDModelIDModelIDModelIDmodelID (input_control)  variation_model HVariationModel, HTupleHTupleHVariationModel, HTupleHVariationModelX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong) (Hlong)

ID of the variation model.

AbsThresholdAbsThresholdAbsThresholdAbsThresholdAbsThresholdabsThreshold (input_control)  number(-array) HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Absolute minimum threshold for the differences between the image and the variation model.

Default value: 10

Suggested values: 0, 5, 10, 15, 20, 30, 40, 50

Restriction: AbsThreshold >= 0

VarThresholdVarThresholdVarThresholdVarThresholdVarThresholdvarThreshold (input_control)  number(-array) HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Threshold for the differences based on the variation of the variation model.

Default value: 2

Suggested values: 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5

Restriction: VarThreshold >= 0

Example (HDevelop)

read_image (Image, 'model')
sobel_amp (Image, VarImage, 'sum_abs', 3)
get_image_pointer1 (Image, Pointer, Type, Width, Height)
create_variation_model (Width, Height, Type, 'direct', ModelID)
prepare_direct_variation_model (Image, VarImage, ModelID, 20, 1)
write_variation_model (ModelID, 'model.var')
clear_variation_model (ModelID)

Result

prepare_direct_variation_modelprepare_direct_variation_modelPrepareDirectVariationModelprepare_direct_variation_modelPrepareDirectVariationModelPrepareDirectVariationModel returns 2 (H_MSG_TRUE) if all parameters are correct.

Possible Predecessors

sobel_ampsobel_ampSobelAmpsobel_ampSobelAmpSobelAmp, edges_imageedges_imageEdgesImageedges_imageEdgesImageEdgesImage, gray_range_rectgray_range_rectGrayRangeRectgray_range_rectGrayRangeRectGrayRangeRect

Possible Successors

compare_variation_modelcompare_variation_modelCompareVariationModelcompare_variation_modelCompareVariationModelCompareVariationModel, compare_ext_variation_modelcompare_ext_variation_modelCompareExtVariationModelcompare_ext_variation_modelCompareExtVariationModelCompareExtVariationModel, get_thresh_images_variation_modelget_thresh_images_variation_modelGetThreshImagesVariationModelget_thresh_images_variation_modelGetThreshImagesVariationModelGetThreshImagesVariationModel, write_variation_modelwrite_variation_modelWriteVariationModelwrite_variation_modelWriteVariationModelWriteVariationModel

Alternatives

prepare_variation_modelprepare_variation_modelPrepareVariationModelprepare_variation_modelPrepareVariationModelPrepareVariationModel

See also

create_variation_modelcreate_variation_modelCreateVariationModelcreate_variation_modelCreateVariationModelCreateVariationModel

Module

Matching


ClassesClassesClassesClasses | | | | Operators