find_scaled_shape_models ( Image : : ModelIDs, AngleStart, AngleExtent, ScaleMin, ScaleMax, MinScore, NumMatches, MaxOverlap, SubPixel, NumLevels, Greediness : Row, Column, Angle, Scale, Score, Model )
Find the best matches of multiple scale invariant shape models.
The operator find_scaled_shape_models finds the best
NumMatches instances of the scale invariant shape models
that are passed in ModelIDs in the input image
Image. The models must have been created previously by
calling create_scaled_shape_model or
read_shape_model.
Hence, in contrast to find_scaled_shape_model, multiple
models can be searched in the same image in one call. This changes
the semantics of all input parameters to some extent. All input
parameters must either contain one element, in which case the
parameter is used for all models, or must contain the same number of
elements as ModelIDs, in which case each parameter element
refers to the corresponding element in ModelIDs.
(NumLevels may also contain either two or twice the number
of elements as ModelIDs; see below.) As usual, the domain
of the input image Image is used to restrict the search
space for the reference point of the models ModelIDs.
Consistent with the above semantics, the input image Image
can therefore contain a single image object or an image object tuple
containing multiple image objects. If Image contains a
single image object, its domain is used as the region of interest
for all models in ModelIDs. If Image contains
multiple image objects, each domain is used as the region of
interest for the corresponding model in ModelIDs. In this
case, the image matrix of all image objects in the tuple must be
identical, i.e., Image cannot be constructed in an
arbitrary manner using concat_obj, but must be created from
the same image using add_channels or equivalent calls. If
this is not the case, an error message is returned. The above
semantics also hold for the input control parameters. Hence, for
example, MinScore can contain a single value or the same
number of values as ModelIDs. In the first case, the value
of MinScore is used for all models in ModelIDs,
while in the second case the respective value of the elements in
MinScore is used for the corresponding model in
ModelIDs. An extension to these semantics holds for
NumMatches and MaxOverlap. If NumMatches
contains one element, find_scaled_shape_models returns the
best NumMatches instances of the model irrespective of the
type of the model. If, for example, two models are passed in
ModelIDs and NumMatches = 2 is selected, it can
happen that two instances of the first model and no instances of the
second model, one instance of the first model and one instance of
the second model, or no instances of the first model and two
instances of the second model are returned. If, on the other hand,
NumMatches contains multiple values, the number of
instances returned of the different models corresponds to the number
specified in the respective entry in NumMatches. If, for
example, NumMatches = [1,1] is selected, one instance of
the first model and one instance of the second model is returned.
For a detailed description of the semantics of NumMatches,
see below. A similar extension of the semantics holds for
MaxOverlap. If a single value is passed for
MaxOverlap, the overlap is computed for all found instances
of the different models, irrespective of the model type, i.e.,
instances of the same or of different models that overlap too much
are eliminated. If, on the other hand, multiple values are passed
in MaxOverlap, the overlap is only computed for found
instances of the model that have the same model type, i.e., only
instances of the same model that overlap too much are eliminated.
In this mode, models of different types may overlap completely. For
a detailed description of the semantics of MaxOverlap, see
below. Hence, a call to find_scaled_shape_models with
multiple values for ModelIDs, NumMatches and
MaxOverlap has the same effect as multiple independent
calls to find_scaled_shape_model with the respective
parameters. However, a single call to find_shape_models is
considerably more efficient.
The type of the found instances of the models is returned in
Model. The elements of Model are indices into the
tuple ModelIDs, i.e., they can contain values from 0 to
|ModelIDs|-1. Hence, a value of 0 in an element of
Model corresponds to an instance of the first model in
ModelIDs.
The position, rotation, and scale of the found instances of the
model are returned in Row, Column, Angle,
and Scale. The coordinates Row and
Column are the coordinates of the origin of the shape model
in the search image. By default, the origin is the center of
gravity of the domain (region) of the image that was used to create
the shape model with create_scaled_shape_model. A different
origin can be set with set_shape_model_origin.
Additionally, the score of each found instance is returned in
Score. The score is a number between 0 and 1, which is an
approximate measure of how much of the model is visible in the
image. If, for example, half of the model is occluded, the score
cannot exceed 0.5.
The domain of the image Image determines the search space
for the reference point of the model, i.e., for the center of
gravity of the domain (region) of the image that was used to create
the shape model with create_scaled_shape_model. A different
origin set with set_shape_model_origin is not taken into
account. The model is searched within those points of the domain of
the image, in which the model lies completely within the image.
This means that the model will not be found if it extends beyond the
borders of the image, even if it would achieve a score greater than
MinScore (see below). The parameters AngleStart
and AngleExtent determine the range of rotations for which
the model is searched. The parameters ScaleMin and
ScaleMax determine the range of scales for which the model
is searched. If necessary, both ranges are clipped to the range
given when the model was created with
create_scaled_shape_model. In particular, this means that
the angle ranges of the model and the search must truly overlap.
The angle range in the search is not adapted modulo
2*pi. To simplify the presentation, all angles in the
remainder of the paragraph are given in degrees, whereas they have
to be specified in radians in find_scaled_shape_models.
Hence, if the model, for example, was created with
AngleStart = -20° and AngleExtent =
40° and the angle search space in
find_scaled_shape_models is, for example, set to
AngleStart = 350° and AngleExtent =
20°, the model will not be found, even though the angle
ranges would overlap if they were regarded modulo
360°. To find the model, in this example it would be
necessary to select AngleStart = -10°.
The parameter MinScore determines what score a potential
match must at least have to be regarded as an instance of the model
in the image. The larger MinScore is chosen, the faster
the search is. If the model can be expected never to be occluded in
the images, MinScore may be set as high as 0.8 or even 0.9.
The maximum number of instances to be found can be determined with
NumMatches. If more than NumMatches instances
with a score greater than MinScore are found in the image,
only the best NumMatches instances are returned. If fewer
than NumMatches are found, only that number is returned,
i.e., the parameter MinScore takes precedence over
NumMatches.
If the model exhibits symmetries it may happen that multiple
instances with similar positions but different rotations are found
in the image. The parameter MaxOverlap determines by what
fraction (i.e., a number between 0 and 1) two instances may at most
overlap in order to consider them as different instances, and hence
to be returned separately. If two instances overlap each other by
more than MaxOverlap only the best instance is returned.
The calculation of the overlap is based on the smallest enclosing
rectangle of arbitrary orientation (see smallest_rectangle2)
of the found instances. If MaxOverlap=0, the found
instances may not overlap at all, while for MaxOverlap=1
all instances are returned.
The parameter SubPixel determines whether the instances
should be extracted with subpixel accuracy. If SubPixel is
set to 'none' (or 'false' for backwards
compatibility) the model's pose is only determined with pixel
accuracy and the angle and scale resolution that was specified with
create_scaled_shape_model. If SubPixel is set to
'interpolation' (or 'true') the position as well
as the rotation and scale are determined with subpixel accuracy. In
this mode, the model's pose is interpolated from the score function.
This mode costs almost no computation time and achieves an accuracy
that is high enough for most applications. In some applications,
however, the accuracy requirements are extremely high. In these
cases, the model's pose can be determined through a least-squares
adjustment, i.e., by minimizing the distances of the model points to
their corresponding image points. In contrast to
'interpolation', this mode requires additional computation
time. The different modes for least-squares adjustment
('least_squares', 'least_squares_high', and
'least_squares_very_high') can be used to determine the
accuracy with which the minimum distance is being searched. The
higher the accuracy is chosen, the longer the subpixel extraction
will take, however. Usually, SubPixel should be set to
'interpolation'. If least-squares adjustment is desired,
'least_squares' should be chosen because this results in
the best tradeoff between run time and accuracy.
The number of pyramid levels used during the search is determined
with NumLevels. If necessary, the number of levels is
clipped to the range given when the shape model was created with
create_scaled_shape_model. If NumLevels is set to
0, the number of pyramid levels specified in
create_scaled_shape_model is used. Optionally,
NumLevels can contain a second value that determines the
lowest pyramid level to which the found matches are tracked. Hence,
a value of [4,2] for NumLevels means that the
matching starts at the fourth pyramid level and tracks the matches
to the second lowest pyramid level (the lowest pyramid level is
denoted by a value of 1). This mechanism can be used to decrease
the runtime of the matching. It should be noted, however, that in
general the accuracy of the extracted pose parameters is lower in
this mode than in the normal mode, in which the matches are tracked
to the lowest pyramid level. Hence, if a high accuracy is desired,
SubPixel should be set to at least
'least_squares'. If the lowest pyramid level to use is
chosen too large, it may happen that the desired accuracy cannot be
achieved, or that wrong instances of the model are found because the
model is not specific enough on the higher pyramid levels to
facilitate a reliable selection of the correct instance of the
model. In this case, the lowest pyramid level to use must be set to
a smaller value. If the lowest pyramid level is specified
separately for each model, NumLevels must contain twice the
number of elements as ModelIDs. In this case, the number
of pyramid levels and the lowest pyramid level must be specified
interleaved in NumLevels. If, for example, two models are
specified in ModelIDs, the number of pyramid levels is 5
for the first model and 4 for the second model, and the lowest
pyramid level is 2 for the first model and 1 for the second model,
NumLevels = [5,2,4,1] must be selected. If
exactly two models are specified in ModelIDs, a special
case occurs. If in this case the lowest pyramid level is to be
specified, the number of pyramid levels and the lowest pyramid level
must be specified explicitly for both models, even if they are
identical, because specifying two values in NumLevels is
interpreted as the explicit specification of the number of pyramid
levels for the two models.
The parameter Greediness determines how ``greedily'' the
search should be carried out. If Greediness=0, a safe
search heuristic is used, which always finds the model if it is
visible in the image. However, the search will be relatively time
consuming in this case. If Greediness=1, an unsafe
search heuristic is used, which may cause the model not to be found
in rare cases, even though it is visible in the image. For
Greediness=1, the maximum search speed is achieved. In
almost all cases, the shape model will always be found for
Greediness=0.9.
Parameters
Image (input_object)
|
image(-array) -> object : byte
|
|
Input image in which the models should be found. |
ModelIDs (input_control)
|
shape_model(-array) -> integer
|
|
Handle of the models. |
AngleStart (input_control)
|
angle.rad(-array) -> real
|
|
Smallest rotation of the models. |
|
Default value: -0.39 |
|
Suggested values: -3.14, -1.57, -0.78, -0.39, -0.20, 0.0 |
AngleExtent (input_control)
|
angle.rad(-array) -> real
|
|
Extent of the rotation angles. |
|
Default value: 0.78 |
|
Suggested values: 6.28, 3.14, 1.57, 0.78, 0.39, 0.0 |
|
Restriction: AngleExtent >= 0 |
ScaleMin (input_control)
|
number(-array) -> real
|
|
Minimum scale of the models. |
|
Default value: 0.9 |
|
Suggested values: 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 |
|
Restriction: ScaleMin > 0 |
ScaleMax (input_control)
|
number(-array) -> real
|
|
Maximum scale of the models. |
|
Default value: 1.1 |
|
Suggested values: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5 |
|
Restriction: ScaleMax >= ScaleMin |
MinScore (input_control)
|
real(-array) -> real
|
|
Minumum score of the instances of the models to
be found. |
|
Default value: 0.5 |
|
Suggested values: 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 |
|
Typical range of values: 0 <= MinScore <= 1 |
|
Minimum increment: 0.01
|
Recommended increment: 0.05
|
NumMatches (input_control)
|
integer(-array) -> integer
|
|
Number of instances of the models to be found. |
|
Default value: 1 |
|
Suggested values: 0, 1, 2, 3, 4, 5, 10, 20 |
MaxOverlap (input_control)
|
real(-array) -> real
|
|
Maximum overlap of the instances of the models
to be found. |
|
Default value: 0.5 |
|
Suggested values: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 |
|
Typical range of values: 0 <= MaxOverlap <= 1 |
|
Minimum increment: 0.01
|
Recommended increment: 0.05
|
SubPixel (input_control)
|
string(-array) -> string
|
|
Subpixel accuracy if not equal to 'none'. |
|
Default value: 'interpolation' |
|
List of values: 'none', 'interpolation', 'least_squares', 'least_squares_high', 'least_squares_very_high' |
NumLevels (input_control)
|
integer(-array) -> integer
|
|
Number of pyramid levels used in the matching
(and lowest pyramid level to use if
|NumLevels| = 2). |
|
Default value: 0 |
|
List of values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 |
Greediness (input_control)
|
real(-array) -> real
|
|
``Greediness'' of the search heuristic (0: safe
but slow; 1: fast but matches may be missed). |
|
Default value: 0.9 |
|
Suggested values: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 |
|
Typical range of values: 0 <= Greediness <= 1 |
|
Minimum increment: 0.01
|
Recommended increment: 0.05
|
Row (output_control)
|
point.y-array -> real
|
|
Row coordinate of the found instances of the models. |
Column (output_control)
|
point.x-array -> real
|
|
Column coordinate of the found instances of the models. |
Angle (output_control)
|
angle.rad-array -> real
|
|
Rotation angle of the found instances of the models. |
Scale (output_control)
|
number-array -> real
|
|
Scale of the found instances of the models. |
Score (output_control)
|
real-array -> real
|
|
Score of the found instances of the models. |
Model (output_control)
|
integer-array -> integer
|
|
Index of the found instances of the models. |
Result
If the parameter values are correct, the operator
find_scaled_shape_models returns the value 2 (H_MSG_TRUE). If the
input is empty (no input images are available) the behavior can be
set via set_system('no_object_result',<Result>). If
necessary, an exception is raised.
Parallelization Information
find_scaled_shape_models is reentrant and processed without parallelization.
Possible Predecessors
add_channels,
create_scaled_shape_model,
read_shape_model,
set_shape_model_origin
Alternatives
find_shape_models,
find_shape_model,
find_scaled_shape_model,
best_match_rot_mg
Module
Template matching
Copyright © 1996-2005 MVTec Software GmbH