ClassesClassesClassesClasses | | | | Operators

create_variation_modelcreate_variation_modelCreateVariationModelcreate_variation_modelCreateVariationModelCreateVariationModel (Operator)


create_variation_modelcreate_variation_modelCreateVariationModelcreate_variation_modelCreateVariationModelCreateVariationModel — Create a variation model for image comparison.


create_variation_model( : : Width, Height, Type, Mode : ModelID)

Herror create_variation_model(const Hlong Width, const Hlong Height, const char* Type, const char* Mode, Hlong* ModelID)

Herror T_create_variation_model(const Htuple Width, const Htuple Height, const Htuple Type, const Htuple Mode, Htuple* ModelID)

Herror create_variation_model(const HTuple& Width, const HTuple& Height, const HTuple& Type, const HTuple& Mode, Hlong* ModelID)

void HVariationModel::CreateVariationModel(const HTuple& Width, const HTuple& Height, const HTuple& Type, const HTuple& Mode)

void CreateVariationModel(const HTuple& Width, const HTuple& Height, const HTuple& Type, const HTuple& Mode, HTuple* ModelID)

void HVariationModel::HVariationModel(Hlong Width, Hlong Height, const HString& Type, const HString& Mode)

void HVariationModel::HVariationModel(Hlong Width, Hlong Height, const char* Type, const char* Mode)

void HVariationModel::CreateVariationModel(Hlong Width, Hlong Height, const HString& Type, const HString& Mode)

void HVariationModel::CreateVariationModel(Hlong Width, Hlong Height, const char* Type, const char* Mode)

void HOperatorSetX.CreateVariationModel(
[in] VARIANT Width, [in] VARIANT Height, [in] VARIANT Type, [in] VARIANT Mode, [out] VARIANT* ModelID)

void HVariationModelX.CreateVariationModel(
[in] Hlong Width, [in] Hlong Height, [in] BSTR Type, [in] BSTR Mode)

static void HOperatorSet.CreateVariationModel(HTuple width, HTuple height, HTuple type, HTuple mode, out HTuple modelID)

public HVariationModel(int width, int height, string type, string mode)

void HVariationModel.CreateVariationModel(int width, int height, string type, string mode)


create_variation_modelcreate_variation_modelCreateVariationModelcreate_variation_modelCreateVariationModelCreateVariationModel creates a variation model that can be used for image comparison. The handle for the variation model is returned in ModelIDModelIDModelIDModelIDModelIDmodelID.

Typically, the variation model is used to discriminate correctly manufactured objects (“good objects”) from incorrectly manufactured objects (“bad objects”). It is assumed that the discrimination can be done solely based on the gray values of the object.

The variation model consists of an ideal image of the object to which the images of the objects to be tested are compared later on with compare_variation_modelcompare_variation_modelCompareVariationModelcompare_variation_modelCompareVariationModelCompareVariationModel or compare_ext_variation_modelcompare_ext_variation_modelCompareExtVariationModelcompare_ext_variation_modelCompareExtVariationModelCompareExtVariationModel, and an image that represents the amount of gray value variation at every point of the object. The size of the images with which the object model is trained and with which the model is compared later on is passed in WidthWidthWidthWidthWidthwidth and HeightHeightHeightHeightHeightheight, respectively. The image type of the images used for training and comparison is passed in TypeTypeTypeTypeTypetype.

The variation model is trained using multiple images of good objects. Therefore, it is essential that the training images show the objects in the same position and rotation. If this cannot be guarateed by external means, the pose of the object can, for example, be determined by using matching (see find_shape_modelfind_shape_modelFindShapeModelfind_shape_modelFindShapeModelFindShapeModel). The image can then be transformed to a reference pose with affine_trans_imageaffine_trans_imageAffineTransImageaffine_trans_imageAffineTransImageAffineTransImage.

The parameter ModeModeModeModeModemode is used to determine how the image of the ideal object and the corresponding variation image are computed. For ModeModeModeModeModemode='standard'"standard""standard""standard""standard""standard", the ideal image of the object is computed as the mean of all training images at the respective image positions. The corresponding variation image is computed as the standard deviation of the training images at the respective image positions. This mode has the advantage that the variation model can be trained iteratively, i.e., as soon as an image of a good object becomes available, it can be trained with train_variation_modeltrain_variation_modelTrainVariationModeltrain_variation_modelTrainVariationModelTrainVariationModel. The disadvantage of this mode is that great care must be taken to ensure that only images of good objects are trained, because the mean and standard deviation are not robust against outliers, i.e., if an image of a bad object is trained inadvertently, the accuracy of the ideal object image and that of the variation image might be degraded.

If it cannot be avoided that the variation model is trained with some images of objects that can contain errors, ModeModeModeModeModemode can be set to 'robust'"robust""robust""robust""robust""robust". In this mode, the image of the ideal object is computed as the median of all training images at the respective image positions. The corresponding variation image is computed as a suitably scaled median absolute deviation of the training images and the median image at the respective image positions. This mode has the advantage that it is robust against outliers. It has the disadvantage that it cannot be trained iteratively, i.e., all training images must be accumulated using concat_objconcat_objConcatObjconcat_objConcatObjConcatObj and be trained with train_variation_modeltrain_variation_modelTrainVariationModeltrain_variation_modelTrainVariationModelTrainVariationModel in a single call.

In some cases, it is impossible to acquire multiple training images. In this case, a useful variation image cannot be trained from the single training image. To solve this problem, variations of the training image can be created synthetically, e.g., by shifting the training image by +/- 1 pixel in the row and column directions or by using gray value morphology (e.g., gray_erosion_shapegray_erosion_shapeGrayErosionShapegray_erosion_shapeGrayErosionShapeGrayErosionShape and gray_dilation_shapegray_dilation_shapeGrayDilationShapegray_dilation_shapeGrayDilationShapeGrayDilationShape), and then training the synthetically modified images. A different possibility to create the variation model from a single image is to create the model with ModeModeModeModeModemode='direct'"direct""direct""direct""direct""direct". In this case, the variation model can only be trained by specifying the ideal image and the variation image directly with prepare_direct_variation_modelprepare_direct_variation_modelPrepareDirectVariationModelprepare_direct_variation_modelPrepareDirectVariationModelPrepareDirectVariationModel. Since the variation typically is large at the edges of the object, edge operators like sobel_ampsobel_ampSobelAmpsobel_ampSobelAmpSobelAmp, edges_imageedges_imageEdgesImageedges_imageEdgesImageEdgesImage, or gray_range_rectgray_range_rectGrayRangeRectgray_range_rectGrayRangeRectGrayRangeRect should be used to create the variation image.



WidthWidthWidthWidthWidthwidth (input_control)  extent.x HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Width of the images to be compared.

Default value: 640

Suggested values: 160, 192, 320, 384, 640, 768

HeightHeightHeightHeightHeightheight (input_control)  extent.y HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Height of the images to be compared.

Default value: 480

Suggested values: 120, 144, 240, 288, 480, 576

TypeTypeTypeTypeTypetype (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Type of the images to be compared.

Default value: 'byte' "byte" "byte" "byte" "byte" "byte"

Suggested values: 'byte'"byte""byte""byte""byte""byte", 'int2'"int2""int2""int2""int2""int2", 'uint2'"uint2""uint2""uint2""uint2""uint2"

ModeModeModeModeModemode (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Method used for computing the variation model.

Default value: 'standard' "standard" "standard" "standard" "standard" "standard"

Suggested values: 'standard'"standard""standard""standard""standard""standard", 'robust'"robust""robust""robust""robust""robust", 'direct'"direct""direct""direct""direct""direct"

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

ID of the variation model.


A variation model created with create_variation_modelcreate_variation_modelCreateVariationModelcreate_variation_modelCreateVariationModelCreateVariationModel requires 12*WidthWidthWidthWidthWidthwidth*HeightHeightHeightHeightHeightheight bytes of memory for ModeModeModeModeModemode = 'standard'"standard""standard""standard""standard""standard" and ModeModeModeModeModemode = 'robust'"robust""robust""robust""robust""robust" for TypeTypeTypeTypeTypetype = 'byte'"byte""byte""byte""byte""byte". For TypeTypeTypeTypeTypetype = 'uint2'"uint2""uint2""uint2""uint2""uint2" and TypeTypeTypeTypeTypetype = 'int2'"int2""int2""int2""int2""int2", 14*WidthWidthWidthWidthWidthwidth*HeightHeightHeightHeightHeightheight are required. For ModeModeModeModeModemode = 'direct'"direct""direct""direct""direct""direct" and after the training data has been cleared with clear_train_data_variation_modelclear_train_data_variation_modelClearTrainDataVariationModelclear_train_data_variation_modelClearTrainDataVariationModelClearTrainDataVariationModel, 2*WidthWidthWidthWidthWidthwidth*HeightHeightHeightHeightHeightheight bytes are required for TypeTypeTypeTypeTypetype = 'byte'"byte""byte""byte""byte""byte" and 4*WidthWidthWidthWidthWidthwidth*HeightHeightHeightHeightHeightheight for the other image types.


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

Possible Successors

train_variation_modeltrain_variation_modelTrainVariationModeltrain_variation_modelTrainVariationModelTrainVariationModel, prepare_direct_variation_modelprepare_direct_variation_modelPrepareDirectVariationModelprepare_direct_variation_modelPrepareDirectVariationModelPrepareDirectVariationModel

See also

prepare_variation_modelprepare_variation_modelPrepareVariationModelprepare_variation_modelPrepareVariationModelPrepareVariationModel, clear_variation_modelclear_variation_modelClearVariationModelclear_variation_modelClearVariationModelClearVariationModel, clear_train_data_variation_modelclear_train_data_variation_modelClearTrainDataVariationModelclear_train_data_variation_modelClearTrainDataVariationModelClearTrainDataVariationModel, find_shape_modelfind_shape_modelFindShapeModelfind_shape_modelFindShapeModelFindShapeModel, affine_trans_imageaffine_trans_imageAffineTransImageaffine_trans_imageAffineTransImageAffineTransImage



ClassesClassesClassesClasses | | | | Operators