create_ncc_modelT_create_ncc_modelCreateNccModelCreateNccModelcreate_ncc_model (Operator)
Name
create_ncc_modelT_create_ncc_modelCreateNccModelCreateNccModelcreate_ncc_model
— Prepare an NCC model for matching.
Signature
void CreateNccModel(const HObject& Template, const HTuple& NumLevels, const HTuple& AngleStart, const HTuple& AngleExtent, const HTuple& AngleStep, const HTuple& Metric, HTuple* ModelID)
void HNCCModel::HNCCModel(const HImage& Template, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, const HString& Metric)
void HNCCModel::HNCCModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const HString& Metric)
void HNCCModel::HNCCModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const char* Metric)
void HNCCModel::HNCCModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const wchar_t* Metric)
(
Windows only)
void HNCCModel::CreateNccModel(const HImage& Template, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, const HString& Metric)
void HNCCModel::CreateNccModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const HString& Metric)
void HNCCModel::CreateNccModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const char* Metric)
void HNCCModel::CreateNccModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const wchar_t* Metric)
(
Windows only)
HNCCModel HImage::CreateNccModel(const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, const HString& Metric) const
HNCCModel HImage::CreateNccModel(Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const HString& Metric) const
HNCCModel HImage::CreateNccModel(Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const char* Metric) const
HNCCModel HImage::CreateNccModel(Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const wchar_t* Metric) const
(
Windows only)
static void HOperatorSet.CreateNccModel(HObject template, HTuple numLevels, HTuple angleStart, HTuple angleExtent, HTuple angleStep, HTuple metric, out HTuple modelID)
public HNCCModel(HImage template, HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, string metric)
public HNCCModel(HImage template, int numLevels, double angleStart, double angleExtent, double angleStep, string metric)
void HNCCModel.CreateNccModel(HImage template, HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, string metric)
void HNCCModel.CreateNccModel(HImage template, int numLevels, double angleStart, double angleExtent, double angleStep, string metric)
HNCCModel HImage.CreateNccModel(HTuple numLevels, double angleStart, double angleExtent, HTuple angleStep, string metric)
HNCCModel HImage.CreateNccModel(int numLevels, double angleStart, double angleExtent, double angleStep, string metric)
Description
The operator create_ncc_modelcreate_ncc_modelCreateNccModelCreateNccModelCreateNccModelcreate_ncc_model
prepares a template, which is
passed in the image TemplateTemplateTemplateTemplatetemplatetemplate
, as an NCC model used for
matching using the normalized cross correlation (NCC). The ROI of
the model is passed as the domain of TemplateTemplateTemplateTemplatetemplatetemplate
.
The model is generated using multiple image pyramid levels at
multiple rotations on each level and is stored in memory. The
output parameter ModelIDModelIDModelIDModelIDmodelIDmodel_id
is a handle for this model, which
is used in subsequent calls to find_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
.
The number of pyramid levels is determined with the parameter
NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels
. It should be chosen as large as possible
because by this the time necessary to find the object is
significantly reduced. On the other hand, NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels
must
be chosen such that the model is still recognizable and contains a
sufficient number of points (at least eight) on the highest pyramid
level. This can be checked using the domains of the output images
of gen_gauss_pyramidgen_gauss_pyramidGenGaussPyramidGenGaussPyramidGenGaussPyramidgen_gauss_pyramid
. If not enough model points are
generated, the number of pyramid levels is reduced internally until
enough model points are found on the highest pyramid level. If this
procedure would lead to a model with no pyramid levels, i.e., if the
number of model points is already too small on the lowest pyramid
level, create_ncc_modelcreate_ncc_modelCreateNccModelCreateNccModelCreateNccModelcreate_ncc_model
returns an error message. If
NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels
is set to 'auto'"auto""auto""auto""auto""auto" or 0,
create_ncc_modelcreate_ncc_modelCreateNccModelCreateNccModelCreateNccModelcreate_ncc_model
determines the number of pyramid levels
automatically. The automatically computed number of pyramid levels
can be queried using get_ncc_model_paramsget_ncc_model_paramsGetNccModelParamsGetNccModelParamsGetNccModelParamsget_ncc_model_params
. In rare cases,
it might happen that create_ncc_modelcreate_ncc_modelCreateNccModelCreateNccModelCreateNccModelcreate_ncc_model
determines a value for
the number of pyramid levels that is too large or too small. If the
number of pyramid levels is chosen too large, the model may not be
recognized in the image or it may be necessary to select very low
parameters for MinScoreMinScoreMinScoreMinScoreminScoremin_score
in find_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
in order
to find the model. If the number of pyramid levels is chosen too
small, the time required to find the model in find_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
may increase. In these cases, the number of pyramid levels should
be selected by inspecting the output of gen_gauss_pyramidgen_gauss_pyramidGenGaussPyramidGenGaussPyramidGenGaussPyramidgen_gauss_pyramid
.
Here, ModeModeModeModemodemode
= 'constant'"constant""constant""constant""constant""constant" and
ScaleScaleScaleScalescalescale
= 0.5 should be used.
The parameters AngleStartAngleStartAngleStartAngleStartangleStartangle_start
and AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent
determine the range of possible rotations, in which the model can
occur in the image. Note that the model can only be found in this
range of angles by find_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
. The parameter
AngleStepAngleStepAngleStepAngleStepangleStepangle_step
determines the step length within the selected
range of angles. Hence, if subpixel accuracy is not specified in
find_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
, this parameter specifies the accuracy that
is achievable for the angles in find_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
.
AngleStepAngleStepAngleStepAngleStepangleStepangle_step
should be chosen based on the size of the object.
Smaller models do not possess many different discrete rotations in
the image, and hence AngleStepAngleStepAngleStepAngleStepangleStepangle_step
should be chosen larger for
smaller models. If AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent
is not an integer multiple
of AngleStepAngleStepAngleStepAngleStepangleStepangle_step
, AngleStepAngleStepAngleStepAngleStepangleStepangle_step
is modified accordingly.
To ensure a sampling of the range of possible rotations that is
independent of the given AngleStartAngleStartAngleStartAngleStartangleStartangle_start
, the range of possible
rotations is modified as follows: If there is no positive integer
value n such that AngleStartAngleStartAngleStartAngleStartangleStartangle_start
plus n times
AngleStepAngleStepAngleStepAngleStepangleStepangle_step
is exactly 0.0, AngleStartAngleStartAngleStartAngleStartangleStartangle_start
is decreased
by up to AngleStepAngleStepAngleStepAngleStepangleStepangle_step
and AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent
is increased by
AngleStepAngleStepAngleStepAngleStepangleStepangle_step
.
The model is pre-generated for the selected angle range and stored
in memory. The memory required to store the model is proportional
to the number of angle steps and the number of points in the model.
Hence, if AngleStepAngleStepAngleStepAngleStepangleStepangle_step
is too small or AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent
too big, it may happen that the model no longer fits into the
(virtual) memory. In this case, either AngleStepAngleStepAngleStepAngleStepangleStepangle_step
must be
enlarged or AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent
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_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
,
AngleStepAngleStepAngleStepAngleStepangleStepangle_step
>= 1 can be
selected for models of a diameter smaller than about 200 pixels. If
AngleStepAngleStepAngleStepAngleStepangleStepangle_step
=
'auto'"auto""auto""auto""auto""auto" or 0 is selected,
create_ncc_modelcreate_ncc_modelCreateNccModelCreateNccModelCreateNccModelcreate_ncc_model
automatically determines a suitable angle
step length based on the size of the model. The automatically
computed angle step length can be queried using
get_ncc_model_paramsget_ncc_model_paramsGetNccModelParamsGetNccModelParamsGetNccModelParamsget_ncc_model_params
.
The parameter MetricMetricMetricMetricmetricmetric
determines the conditions under which
the model is recognized in the image. If MetricMetricMetricMetricmetricmetric
=
'use_polarity'"use_polarity""use_polarity""use_polarity""use_polarity""use_polarity", the object in the image and the model must
have the same contrast. If, for example, the model is a bright
object on a dark background, the object is found only if it is also
brighter than the background. If MetricMetricMetricMetricmetricmetric
=
'ignore_global_polarity'"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_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
will increase slightly in this
case.
The center of gravity of the domain (region) of the model image
TemplateTemplateTemplateTemplatetemplatetemplate
is used as the origin (reference point) of the
model. A different origin can be set with
set_ncc_model_originset_ncc_model_originSetNccModelOriginSetNccModelOriginSetNccModelOriginset_ncc_model_origin
.
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
TemplateTemplateTemplateTemplatetemplatetemplate
(input_object) singlechannelimage →
objectHImageHObjectHImageHobject (byte / uint2)
Input image whose domain will be used to create
the model.
NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels
(input_control) integer →
HTupleUnion[int, str]HTupleHtuple (integer / string) (int / long / string) (Hlong / HString) (Hlong / char*)
Maximum number of pyramid levels.
Default:
'auto'
"auto"
"auto"
"auto"
"auto"
"auto"
List of values:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'auto'"auto""auto""auto""auto""auto"
AngleStartAngleStartAngleStartAngleStartangleStartangle_start
(input_control) angle.rad →
HTuplefloatHTupleHtuple (real) (double) (double) (double)
Smallest rotation of the pattern.
Default:
-0.39
Suggested values:
-3.14, -1.57, -0.79, -0.39, -0.20, 0.0
AngleExtentAngleExtentAngleExtentAngleExtentangleExtentangle_extent
(input_control) angle.rad →
HTuplefloatHTupleHtuple (real) (double) (double) (double)
Extent of the rotation angles.
Default:
0.79
Suggested values:
6.29, 3.14, 1.57, 0.79, 0.39
Restriction:
AngleExtent >= 0
AngleStepAngleStepAngleStepAngleStepangleStepangle_step
(input_control) angle.rad →
HTupleUnion[float, str]HTupleHtuple (real / string) (double / string) (double / HString) (double / char*)
Step length of the angles (resolution).
Default:
'auto'
"auto"
"auto"
"auto"
"auto"
"auto"
Suggested values:
'auto'"auto""auto""auto""auto""auto", 0.0, 0.0175, 0.0349, 0.0524, 0.0698, 0.0873
Restriction:
AngleStep >= 0 && AngleStep <= pi / 16
MetricMetricMetricMetricmetricmetric
(input_control) string →
HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Match metric.
Default:
'use_polarity'
"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""ignore_global_polarity", 'use_polarity'"use_polarity""use_polarity""use_polarity""use_polarity""use_polarity"
ModelIDModelIDModelIDModelIDmodelIDmodel_id
(output_control) ncc_model →
HNCCModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Handle of the model.
Result
If the parameters are valid, the operator create_ncc_modelcreate_ncc_modelCreateNccModelCreateNccModelCreateNccModelcreate_ncc_model
returns the value 2 (
H_MSG_TRUE)
. If the parameter NumLevelsNumLevelsNumLevelsNumLevelsnumLevelsnum_levels
are
chosen such that the model contains too few points, the error 8506
is raised.
Possible Predecessors
draw_regiondraw_regionDrawRegionDrawRegionDrawRegiondraw_region
,
reduce_domainreduce_domainReduceDomainReduceDomainReduceDomainreduce_domain
,
thresholdthresholdThresholdThresholdThresholdthreshold
Possible Successors
find_ncc_modelfind_ncc_modelFindNccModelFindNccModelFindNccModelfind_ncc_model
,
get_ncc_model_paramsget_ncc_model_paramsGetNccModelParamsGetNccModelParamsGetNccModelParamsget_ncc_model_params
,
clear_ncc_modelclear_ncc_modelClearNccModelClearNccModelClearNccModelclear_ncc_model
,
write_ncc_modelwrite_ncc_modelWriteNccModelWriteNccModelWriteNccModelwrite_ncc_model
,
set_ncc_model_originset_ncc_model_originSetNccModelOriginSetNccModelOriginSetNccModelOriginset_ncc_model_origin
,
set_ncc_model_paramset_ncc_model_paramSetNccModelParamSetNccModelParamSetNccModelParamset_ncc_model_param
,
find_ncc_modelsfind_ncc_modelsFindNccModelsFindNccModelsFindNccModelsfind_ncc_models
Alternatives
create_generic_shape_modelcreate_generic_shape_modelCreateGenericShapeModelCreateGenericShapeModelCreateGenericShapeModelcreate_generic_shape_model
Module
Matching