set_local_deformable_model_metricT_set_local_deformable_model_metricSetLocalDeformableModelMetricSetLocalDeformableModelMetricset_local_deformable_model_metric (Operator)

Name

set_local_deformable_model_metricT_set_local_deformable_model_metricSetLocalDeformableModelMetricSetLocalDeformableModelMetricset_local_deformable_model_metric — Set the metric of a local deformable model that was created from XLD contours.

Signature

set_local_deformable_model_metric(Image, VectorField : : ModelID, Metric : )

Herror T_set_local_deformable_model_metric(const Hobject Image, const Hobject VectorField, const Htuple ModelID, const Htuple Metric)

void SetLocalDeformableModelMetric(const HObject& Image, const HObject& VectorField, const HTuple& ModelID, const HTuple& Metric)

void HDeformableModel::SetLocalDeformableModelMetric(const HImage& Image, const HImage& VectorField, const HString& Metric) const

void HDeformableModel::SetLocalDeformableModelMetric(const HImage& Image, const HImage& VectorField, const char* Metric) const

void HDeformableModel::SetLocalDeformableModelMetric(const HImage& Image, const HImage& VectorField, const wchar_t* Metric) const   ( Windows only)

void HImage::SetLocalDeformableModelMetric(const HImage& VectorField, const HDeformableModel& ModelID, const HString& Metric) const

void HImage::SetLocalDeformableModelMetric(const HImage& VectorField, const HDeformableModel& ModelID, const char* Metric) const

void HImage::SetLocalDeformableModelMetric(const HImage& VectorField, const HDeformableModel& ModelID, const wchar_t* Metric) const   ( Windows only)

static void HOperatorSet.SetLocalDeformableModelMetric(HObject image, HObject vectorField, HTuple modelID, HTuple metric)

void HDeformableModel.SetLocalDeformableModelMetric(HImage image, HImage vectorField, string metric)

void HImage.SetLocalDeformableModelMetric(HImage vectorField, HDeformableModel modelID, string metric)

def set_local_deformable_model_metric(image: HObject, vector_field: HObject, model_id: HHandle, metric: str) -> None

Description

set_local_deformable_model_metricset_local_deformable_model_metricSetLocalDeformableModelMetricSetLocalDeformableModelMetricset_local_deformable_model_metric changes the value of the parameter MetricMetricMetricmetricmetric that was selected during the creation of the deformable model ModelIDModelIDModelIDmodelIDmodel_id from XLD contours. Because no information about the polarity of the model contours is available for XLD contours, the polarity is determined based on a representative ImageImageImageimageimage. For this, the model contours are mapped to the respective position where the object appears in the ImageImageImageimageimage, which is done with the VectorFieldVectorFieldVectorFieldvectorFieldvector_field which must be of the semantic type 'vector_field_absolute' and which can be obtained by a previous call to find_local_deformable_modelfind_local_deformable_modelFindLocalDeformableModelFindLocalDeformableModelfind_local_deformable_model. Here, the returned VectorFieldVectorFieldVectorFieldvectorFieldvector_field is used for the deformable transformation. Note, that the 'expand_border'"expand_border""expand_border""expand_border""expand_border" option should not be used in find_local_deformable_modelfind_local_deformable_modelFindLocalDeformableModelFindLocalDeformableModelfind_local_deformable_model, because then the returned VectorFieldVectorFieldVectorFieldvectorFieldvector_field has the wrong image size.

The parameter MetricMetricMetricmetricmetric then determines the conditions under which the model is recognized later in the search image. If MetricMetricMetricmetricmetric = 'use_polarity'"use_polarity""use_polarity""use_polarity""use_polarity", the object in the image and the model must have the same contrast. If, e.g., the model is a bright object on a dark background, the object is found only if it is also brighter than the background. If MetricMetricMetricmetricmetric = 'ignore_global_polarity'"ignore_global_polarity""ignore_global_polarity""ignore_global_polarity""ignore_global_polarity", the object is found in the image also if the contrast reverses globally. In the above example, the object hence is also found if it is darker than the background. The runtime of find_local_deformable_modelfind_local_deformable_modelFindLocalDeformableModelFindLocalDeformableModelfind_local_deformable_model will increase slightly in this case.

It must be ensured that the object contours in the ImageImageImageimageimage have the same (or inverse) polarity as the object contours in the image in which the object must be searched later. Especially, the object must not be occluded in the ImageImageImageimageimage and the background must be either brighter than the object or darker. Otherwise, the determined polarity of the model contour will not represent the polarity of the object contour during the search. Note that only the polarity of the contours is determined, not their contrast. Note also that the polarity is determined from a single-channel image, only. If a multi-channel image is passed in ImageImageImageimageimage, only the first channel will be used (and no error message will be returned).

A typical proceeding is to read the XLD contours from file. Since these XLD contours do not provide polarity information, the model must be created from the XLD contours by setting the parameter MetricMetricMetricmetricmetric to 'ignore_local_polarity'"ignore_local_polarity""ignore_local_polarity""ignore_local_polarity""ignore_local_polarity". Then, in a first search image the model is recognized. The transformation that maps the model contours to the position of the object in the search image is provided in VectorFieldVectorFieldVectorFieldvectorFieldvector_field, which is of the semantic type 'vector_field_absolute'. If the matching result is correct, the value of the parameter MetricMetricMetricmetricmetric can be changed, e.g., to 'use_polarity'"use_polarity""use_polarity""use_polarity""use_polarity". This leads to a faster and more robust recognition in the following images.

Attention

set_local_deformable_model_metricset_local_deformable_model_metricSetLocalDeformableModelMetricSetLocalDeformableModelMetricset_local_deformable_model_metric can only be used with deformable models that were created from XLD contours.

Execution Information

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

ImageImageImageimageimage (input_object)  singlechannelimage objectHImageHObjectHObjectHobject (byte / uint2)

Input image used for the determination of the polarity.

VectorFieldVectorFieldVectorFieldvectorFieldvector_field (input_object)  singlechannelimage objectHImageHObjectHObjectHobject (vector_field)

Vector field of the local deformation.

ModelIDModelIDModelIDmodelIDmodel_id (input_control, state is modified)  deformable_model HDeformableModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the model.

MetricMetricMetricmetricmetric (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Match metric.

Default: 'use_polarity' "use_polarity" "use_polarity" "use_polarity" "use_polarity"

List of values: 'ignore_global_polarity'"ignore_global_polarity""ignore_global_polarity""ignore_global_polarity""ignore_global_polarity", 'use_polarity'"use_polarity""use_polarity""use_polarity""use_polarity"

Result

If the parameters are valid, the operator set_local_deformable_model_metricset_local_deformable_model_metricSetLocalDeformableModelMetricSetLocalDeformableModelMetricset_local_deformable_model_metric returns the value 2 ( H_MSG_TRUE) . If necessary, an exception is raised.

Possible Predecessors

create_local_deformable_model_xldcreate_local_deformable_model_xldCreateLocalDeformableModelXldCreateLocalDeformableModelXldcreate_local_deformable_model_xld, find_local_deformable_modelfind_local_deformable_modelFindLocalDeformableModelFindLocalDeformableModelfind_local_deformable_model

Possible Successors

find_local_deformable_modelfind_local_deformable_modelFindLocalDeformableModelFindLocalDeformableModelfind_local_deformable_model

See also

create_local_deformable_model_xldcreate_local_deformable_model_xldCreateLocalDeformableModelXldCreateLocalDeformableModelXldcreate_local_deformable_model_xld

Module

Matching