Skip to content

create_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_modelT_create_aniso_shape_modelπŸ”—

Short descriptionπŸ”—

create_aniso_shape_modelCreateAnisoShapeModelCreateAnisoShapeModelcreate_aniso_shape_modelT_create_aniso_shape_model β€” Prepare an anisotropically scaled shape model for matching.

SignatureπŸ”—

create_aniso_shape_model( image Template, integer NumLevels, angle.rad AngleStart, angle.rad AngleExtent, angle.rad AngleStep, number ScaleRMin, number ScaleRMax, number ScaleRStep, number ScaleCMin, number ScaleCMax, number ScaleCStep, string Optimization, string Metric, number Contrast, number MinContrast, out shape_model ModelID )void CreateAnisoShapeModel( const HObject& Template, const HTuple& NumLevels, const HTuple& AngleStart, const HTuple& AngleExtent, const HTuple& AngleStep, const HTuple& ScaleRMin, const HTuple& ScaleRMax, const HTuple& ScaleRStep, const HTuple& ScaleCMin, const HTuple& ScaleCMax, const HTuple& ScaleCStep, const HTuple& Optimization, const HTuple& Metric, const HTuple& Contrast, const HTuple& MinContrast, HTuple* ModelID )static void HOperatorSet.CreateAnisoShapeModel( HObject template, HTuple numLevels, HTuple angleStart, HTuple angleExtent, HTuple angleStep, HTuple scaleRMin, HTuple scaleRMax, HTuple scaleRStep, HTuple scaleCMin, HTuple scaleCMax, HTuple scaleCStep, HTuple optimization, HTuple metric, HTuple contrast, HTuple minContrast, out HTuple modelID )def create_aniso_shape_model( template: HObject, num_levels: Union[int, str], angle_start: float, angle_extent: float, angle_step: Union[float, str], scale_rmin: float, scale_rmax: float, scale_rstep: Union[float, str], scale_cmin: float, scale_cmax: float, scale_cstep: Union[float, str], optimization: MaybeSequence[str], metric: str, contrast: MaybeSequence[Union[int, str]], min_contrast: Union[int, str] ) -> HHandle

Herror T_create_aniso_shape_model( const Hobject Template, const Htuple NumLevels, const Htuple AngleStart, const Htuple AngleExtent, const Htuple AngleStep, const Htuple ScaleRMin, const Htuple ScaleRMax, const Htuple ScaleRStep, const Htuple ScaleCMin, const Htuple ScaleCMax, const Htuple ScaleCStep, const Htuple Optimization, const Htuple Metric, const Htuple Contrast, const Htuple MinContrast, Htuple* ModelID )

void HShapeModel::HShapeModel( const HImage& Template, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, double ScaleRMin, double ScaleRMax, const HTuple& ScaleRStep, double ScaleCMin, double ScaleCMax, const HTuple& ScaleCStep, const HTuple& Optimization, const HString& Metric, const HTuple& Contrast, const HTuple& MinContrast )

void HShapeModel::HShapeModel( const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const HString& Optimization, const HString& Metric, Hlong Contrast, Hlong MinContrast )

void HShapeModel::HShapeModel( const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const char* Optimization, const char* Metric, Hlong Contrast, Hlong MinContrast )

void HShapeModel::HShapeModel( const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong Contrast, Hlong MinContrast ) (Windows only)

public HShapeModel( HImage template, HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, double scaleRMin, double scaleRMax, HTuple scaleRStep, double scaleCMin, double scaleCMax, HTuple scaleCStep, HTuple optimization, string metric, HTuple contrast, HTuple minContrast )

public HShapeModel( HImage template, int numLevels, double angleStart, double angleExtent, double angleStep, double scaleRMin, double scaleRMax, double scaleRStep, double scaleCMin, double scaleCMax, double scaleCStep, string optimization, string metric, int contrast, int minContrast )

void HShapeModel::CreateAnisoShapeModel( const HImage& Template, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, double ScaleRMin, double ScaleRMax, const HTuple& ScaleRStep, double ScaleCMin, double ScaleCMax, const HTuple& ScaleCStep, const HTuple& Optimization, const HString& Metric, const HTuple& Contrast, const HTuple& MinContrast )

void HShapeModel::CreateAnisoShapeModel( const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const HString& Optimization, const HString& Metric, Hlong Contrast, Hlong MinContrast )

void HShapeModel::CreateAnisoShapeModel( const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const char* Optimization, const char* Metric, Hlong Contrast, Hlong MinContrast )

void HShapeModel::CreateAnisoShapeModel( const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong Contrast, Hlong MinContrast ) (Windows only)

HShapeModel HImage::CreateAnisoShapeModel( const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, double ScaleRMin, double ScaleRMax, const HTuple& ScaleRStep, double ScaleCMin, double ScaleCMax, const HTuple& ScaleCStep, const HTuple& Optimization, const HString& Metric, const HTuple& Contrast, const HTuple& MinContrast ) const

HShapeModel HImage::CreateAnisoShapeModel( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const HString& Optimization, const HString& Metric, Hlong Contrast, Hlong MinContrast ) const

HShapeModel HImage::CreateAnisoShapeModel( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const char* Optimization, const char* Metric, Hlong Contrast, Hlong MinContrast ) const

HShapeModel HImage::CreateAnisoShapeModel( Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, double ScaleRMin, double ScaleRMax, double ScaleRStep, double ScaleCMin, double ScaleCMax, double ScaleCStep, const wchar_t* Optimization, const wchar_t* Metric, Hlong Contrast, Hlong MinContrast ) const (Windows only)

void HShapeModel.CreateAnisoShapeModel( HImage template, HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, double scaleRMin, double scaleRMax, HTuple scaleRStep, double scaleCMin, double scaleCMax, HTuple scaleCStep, HTuple optimization, string metric, HTuple contrast, HTuple minContrast )

void HShapeModel.CreateAnisoShapeModel( HImage template, int numLevels, double angleStart, double angleExtent, double angleStep, double scaleRMin, double scaleRMax, double scaleRStep, double scaleCMin, double scaleCMax, double scaleCStep, string optimization, string metric, int contrast, int minContrast )

HShapeModel HImage.CreateAnisoShapeModel( HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, double scaleRMin, double scaleRMax, HTuple scaleRStep, double scaleCMin, double scaleCMax, HTuple scaleCStep, HTuple optimization, string metric, HTuple contrast, HTuple minContrast )

HShapeModel HImage.CreateAnisoShapeModel( int numLevels, double angleStart, double angleExtent, double angleStep, double scaleRMin, double scaleRMax, double scaleRStep, double scaleCMin, double scaleCMax, double scaleCStep, string optimization, string metric, int contrast, int minContrast )

DescriptionπŸ”—

The operator create_aniso_shape_modelCreateAnisoShapeModel prepares a template, which is passed in the image Templatetemplatetemplate, as an anisotropically scaled shape model used for matching. The ROI of the model is passed as the domain of Templatetemplatetemplate.

The output parameter ModelIDmodelIDmodel_id is a handle for this model, which is used in subsequent calls to find_aniso_shape_modelFindAnisoShapeModel. The center of gravity of the domain (region) of the model image Templatetemplatetemplate is used as the origin (reference point) of the model. A different origin can be set with set_shape_model_originSetShapeModelOrigin. The model is generated using multiple image pyramid levels and is stored in memory. If a complete pregeneration of the model is selected (see below), the model is generated at multiple rotations and anisotropic scales (i.e., independent scales in the row and column direction) on each level. The model can be extended by clutter parameters with set_shape_model_clutterSetShapeModelClutter.

Input parameters in detailπŸ”—

Complete pregeneration of the modelπŸ”—

Optionally, a second value can be passed in Optimizationoptimizationoptimization. This value determines whether the model is pregenerated completely or not. To do so, the second value of Optimizationoptimizationoptimization must be set to either 'pregeneration'"pregeneration" or 'no_pregeneration'"no_pregeneration". If the second value is not used (i.e., if only one value is passed), the mode that is set with set_system('pregenerate_shape_models',...) is used. With the default value ('pregenerate_shape_models'"pregenerate_shape_models" \(=\) 'false'"false"), the model is not pregenerated completely. The complete pregeneration of the model normally leads to slightly lower runtimes because the model does not need to be transformed at runtime. However, in this case, the memory requirements and the time required to create the model are significantly higher. It should also be noted that it cannot be expected that the two modes return exactly identical results because transforming the model at runtime necessarily leads to different internal data for the transformed models than pregenerating the transformed models. For example, if the model is not pregenerated completely, find_aniso_shape_modelFindAnisoShapeModel typically returns slightly lower scores, which may require setting a slightly lower value for MinScoreminScoremin_score than for a completely pregenerated model. Furthermore, the poses obtained by interpolation may differ slightly in the two modes. If maximum accuracy is desired, the pose of the model should be determined by least-squares adjustment.

If a complete pregeneration of the model is selected, the model is pregenerated for the selected angle and scale range and stored in memory. The memory required to store the model is proportional to the number of angle steps, the number of scale steps, and the number of points in the model. Hence, if AngleStepangleStepangle_step, ScaleRStepscaleRStepscale_rstep, or ScaleCStepscaleCStepscale_cstep are too small or AngleExtentangleExtentangle_extent or the range of scales are too big, it may happen that the model no longer fits into the (virtual) memory. In this case, AngleStepangleStepangle_step, ScaleRStepscaleRStepscale_rstep, or ScaleCStepscaleCStepscale_cstep must be enlarged or AngleExtentangleExtentangle_extent or the range of scales must be reduced. In any case, it is desirable that the model completely fits into the main memory, because this avoids paging by the operating system, and hence the time to find the object will be much smaller. Since angles can be determined with subpixel resolution by find_aniso_shape_modelFindAnisoShapeModel, AngleStep >= 1Β° and ScaleRStep, ScaleCStep >= 0.02 can be selected for models of a diameter smaller than about 200 pixels.

If AngleStep = β€˜auto’ or ScaleRStep, ScaleCStep = β€˜auto’ (or 00 for backwards compatibility in both cases) is selected, create_aniso_shape_modelCreateAnisoShapeModel automatically determines a suitable angle or scale step length, respectively, based on the size of the model. The automatically computed angle and scale step lengths can be queried using get_shape_model_paramsGetShapeModelParams.

If a complete pregeneration of the model is not selected, the model is only created in a reference pose on each pyramid level. In this case, the model must be transformed to the different angles and scales at runtime in find_aniso_shape_modelFindAnisoShapeModel. Because of this, the recognition of the model might require slightly more time.

Note that pregenerated shape models are tailored to a specific image size. For runtime reasons using images of different sizes during the search with the same model in parallel is not supported. In this case, copies of the same model must be used, otherwise the program may crash!

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 returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

ParametersπŸ”—

Templatetemplatetemplate (input_object) (multichannel-)image β†’ object (byte / uint2)HObject (byte / uint2)HImage (byte / uint2)HObject (byte / uint2)Hobject (byte / uint2)

Input image whose domain will be used to create the model.

NumLevelsnumLevelsnum_levels (input_control) integer β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Maximum number of pyramid levels.

Default: 'auto'"auto"
List of values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'auto'0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "auto"

AngleStartangleStartangle_start (input_control) angle.rad β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Smallest rotation of the pattern.

Default: -0.39-0.39
Suggested values: -3.14, -1.57, -0.79, -0.39, -0.20, 0.0-3.14, -1.57, -0.79, -0.39, -0.20, 0.0

AngleExtentangleExtentangle_extent (input_control) angle.rad β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Extent of the rotation angles.

Default: 0.790.79
Suggested values: 6.29, 3.14, 1.57, 0.79, 0.396.29, 3.14, 1.57, 0.79, 0.39
Restriction: AngleExtent >= 0

AngleStepangleStepangle_step (input_control) angle.rad β†’ (real / string)HTuple (double / HString)HTuple (double / string)Union[float, str]Htuple (double / char*)

Step length of the angles (resolution).

Default: 'auto'"auto"
Suggested values: 'auto', 0.0175, 0.0349, 0.0524, 0.0698, 0.0873"auto", 0.0175, 0.0349, 0.0524, 0.0698, 0.0873
Restriction: AngleStep >= 0 && AngleStep <= pi/2

ScaleRMinscaleRMinscale_rmin (input_control) number β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Minimum scale of the pattern in the row direction.

Default: 0.90.9
Suggested values: 0.5, 0.6, 0.7, 0.8, 0.9, 1.00.5, 0.6, 0.7, 0.8, 0.9, 1.0
Restriction: ScaleRMin > 0

ScaleRMaxscaleRMaxscale_rmax (input_control) number β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum scale of the pattern in the row direction.

Default: 1.11.1
Suggested values: 1.0, 1.1, 1.2, 1.3, 1.4, 1.51.0, 1.1, 1.2, 1.3, 1.4, 1.5
Restriction: ScaleRMax >= ScaleRMin

ScaleRStepscaleRStepscale_rstep (input_control) number β†’ (real / string)HTuple (double / HString)HTuple (double / string)Union[float, str]Htuple (double / char*)

Scale step length (resolution) in the row direction.

Default: 'auto'"auto"
Suggested values: 'auto', 0.01, 0.02, 0.05, 0.1, 0.15, 0.2"auto", 0.01, 0.02, 0.05, 0.1, 0.15, 0.2
Restriction: ScaleRStep >= 0

ScaleCMinscaleCMinscale_cmin (input_control) number β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Minimum scale of the pattern in the column direction.

Default: 0.90.9
Suggested values: 0.5, 0.6, 0.7, 0.8, 0.9, 1.00.5, 0.6, 0.7, 0.8, 0.9, 1.0
Restriction: ScaleCMin > 0

ScaleCMaxscaleCMaxscale_cmax (input_control) number β†’ (real)HTuple (double)HTuple (double)floatHtuple (double)

Maximum scale of the pattern in the column direction.

Default: 1.11.1
Suggested values: 1.0, 1.1, 1.2, 1.3, 1.4, 1.51.0, 1.1, 1.2, 1.3, 1.4, 1.5
Restriction: ScaleCMax >= ScaleCMin

ScaleCStepscaleCStepscale_cstep (input_control) number β†’ (real / string)HTuple (double / HString)HTuple (double / string)Union[float, str]Htuple (double / char*)

Scale step length (resolution) in the column direction.

Default: 'auto'"auto"
Suggested values: 'auto', 0.01, 0.02, 0.05, 0.1, 0.15, 0.2"auto", 0.01, 0.02, 0.05, 0.1, 0.15, 0.2
Restriction: ScaleCStep >= 0

Optimizationoptimizationoptimization (input_control) string(-array) β†’ (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Kind of optimization and optionally method used for generating the model.

Default: 'auto'"auto"
List of values: 'auto', 'no_pregeneration', 'none', 'point_reduction_high', 'point_reduction_low', 'point_reduction_medium', 'pregeneration'"auto", "no_pregeneration", "none", "point_reduction_high", "point_reduction_low", "point_reduction_medium", "pregeneration"

Metricmetricmetric (input_control) string β†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Match metric.

Default: 'use_polarity'"use_polarity"
List of values: 'ignore_color_polarity', 'ignore_global_polarity', 'ignore_local_polarity', 'use_polarity'"ignore_color_polarity", "ignore_global_polarity", "ignore_local_polarity", "use_polarity"

Contrastcontrastcontrast (input_control) number(-array) β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)MaybeSequence[Union[int, str]]Htuple (Hlong / char*)

Threshold or hysteresis thresholds for the contrast of the object in the template image and optionally minimum size of the object parts.

Default: 'auto'"auto"
Suggested values: 'auto', 'auto_contrast', 'auto_contrast_hyst', 'auto_min_size', 10, 20, 30, 40, 60, 80, 100, 120, 140, 160"auto", "auto_contrast", "auto_contrast_hyst", "auto_min_size", 10, 20, 30, 40, 60, 80, 100, 120, 140, 160

MinContrastminContrastmin_contrast (input_control) number β†’ (integer / string)HTuple (Hlong / HString)HTuple (int / long / string)Union[int, str]Htuple (Hlong / char*)

Minimum contrast of the objects in the search images.

Default: 'auto'"auto"
Suggested values: 'auto', 1, 2, 3, 5, 7, 10, 20, 30, 40"auto", 1, 2, 3, 5, 7, 10, 20, 30, 40
Restriction: MinContrast < Contrast

ModelIDmodelIDmodel_id (output_control) shape_model β†’ (handle)HTuple (HHandle)HShapeModel, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the model.

ResultπŸ”—

If the parameters are valid, the operator create_aniso_shape_modelCreateAnisoShapeModel returns the value 2 (H_MSG_TRUE). If necessary an exception is raised. If the parameters NumLevelsnumLevelsnum_levels and Contrastcontrastcontrast are chosen such that the model contains too few points, the error 8510 is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

draw_regionDrawRegion, reduce_domainReduceDomain, thresholdThreshold

Possible successors

find_aniso_shape_modelFindAnisoShapeModel, find_aniso_shape_modelsFindAnisoShapeModels, get_shape_model_paramsGetShapeModelParams, clear_shape_modelClearShapeModel, write_shape_modelWriteShapeModel, set_shape_model_originSetShapeModelOrigin, set_shape_model_clutterSetShapeModelClutter

Alternatives

create_generic_shape_modelCreateGenericShapeModel

See also

set_systemSetSystem, get_systemGetSystem

ModuleπŸ”—

Matching