Skip to content

train_variation_modelTrainVariationModelTrainVariationModeltrain_variation_modelT_train_variation_model🔗

Short description🔗

train_variation_modelTrainVariationModelTrainVariationModeltrain_variation_modelT_train_variation_model — Train a variation model.

Signature🔗

train_variation_model( image Images, variation_model ModelID )void TrainVariationModel( const HObject& Images, const HTuple& ModelID )static void HOperatorSet.TrainVariationModel( HObject images, HTuple modelID )def train_variation_model( images: HObject, model_id: HHandle ) -> None

Herror T_train_variation_model( const Hobject Images, const Htuple ModelID )

void HVariationModel::TrainVariationModel( const HImage& Images ) const

void HImage::TrainVariationModel( const HVariationModel& ModelID ) const

void HVariationModel.TrainVariationModel( HImage images )

void HImage.TrainVariationModel( HVariationModel modelID )

Description🔗

train_variation_modelTrainVariationModel trains the variation model that is passed in ModelIDmodelIDmodel_id with one or more images, which are passed in Imagesimagesimages.

As described for create_variation_modelCreateVariationModel, a variation model that has been created using the mode 'standard'"standard" can be trained iteratively, i.e., as soon as images of good objects become available, they can be trained with train_variation_modelTrainVariationModel. The ideal image of the object is computed as the mean of all previous training images and the images that are passed in Imagesimagesimages. The corresponding variation image is computed as the standard deviation of the training images and the images that are passed in Imagesimagesimages.

If the variation model has been created using the mode 'robust'"robust", the model cannot be trained iteratively, i.e., all training images must be accumulated using concat_objConcatObj and be trained with train_variation_modelTrainVariationModel in a single call. If any images have been trained previously, the training information of the previous call is discarded. The image of the ideal object is computed as the median of all training images passed in Imagesimagesimages. The corresponding variation image is computed as a suitably scaled median absolute deviation of the training images and the median image.

Attention🔗

At most 65535 training images can be trained.

Execution information🔗

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

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

  • Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters🔗

Imagesimagesimages (input_object) singlechannelimage(-array) → object (byte / int2 / uint2)HObject (byte / int2 / uint2)HImage (byte / int2 / uint2)HObject (byte / int2 / uint2)Hobject (byte / int2 / uint2)

Images of the object to be trained.

ModelIDmodelIDmodel_id (input_control, state is modified) variation_model → (handle)HTuple (HHandle)HVariationModel, HTuple (IntPtr)HHandleHtuple (handle)

ID of the variation model.

Example🔗

(HDevelop)

create_variation_model (Width, Height, Type, 'standard', ModelID)
for K := 1 to 10 by 1
    read_image (Image, 'pen-' + K$'02')
    find_generic_shape_model (Image, TemplateID, MatchResultID, \
                              NumMatchResult)
    get_generic_shape_model_result (MatchResultID, 'all', 'hom_mat_2d', \
                                    HomMat2D)
    if (NumMatchResult == 1)
        affine_trans_image (Image, ImageTrans, HomMat2D, 'constant', \
                            'false')
        train_variation_model (ImageTrans, ModelID)
    endif
endfor
prepare_variation_model (ModelID, 10, 4)

Result🔗

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

Combinations with other operators🔗

Combinations

Possible predecessors

create_variation_modelCreateVariationModel, find_generic_shape_modelFindGenericShapeModel, affine_trans_imageAffineTransImage, concat_objConcatObj

Possible successors

prepare_variation_modelPrepareVariationModel

See also

prepare_variation_modelPrepareVariationModel, compare_variation_modelCompareVariationModel, compare_ext_variation_modelCompareExtVariationModel, clear_variation_modelClearVariationModel

Module🔗

Matching