Operators |
get_training_components — Return the initial or model components in a certain image.
get_training_components( : TrainingComponents : ComponentTrainingID, Components, Image, MarkOrientation : Row, Column, Angle, Score)
get_training_components returns all initial components (if Components = 'initial_components' ) or all model components (if Components = 'model_components' ) in TrainingComponents in form of contour regions as well as in numerical form. Alternatively, by directly passing the index of an initial component, all found poses of that initial component (i.e., the poses before solving the ambiguities in train_model_components) are returned.
The pose of the returned components corresponds to their pose in the model image (if Image = 'model_image' or Image = 0) or in a training image (if Image >= 1). In order to obtain the components in the pose at which they were found in the ith training image, Image must be set to i. Furthermore, when dealing with rotationally symmetric components, one may wish to mark the current orientation of the found component. This can be achieved by setting MarkOrientation to 'true' . In this case, the contour region of each component is complemented by an arrow at its reference point pointing in the reference direction. The reference direction of a component is based on the orientation of the component in the model image and is represented by an arrow that starts at the reference point and points to the right in the horizontal direction.
In addition to the contour regions, the pose and the score of all found components is returned in Row, Column, Angle, and Score (see find_shape_model). If Components was set to 'initial_components' or 'model_components' , the tuples TrainingComponents, Row, Column, Angle, and Score always contain the same number of elements as initial components or model components contained in ComponentTrainingID, respectively. If one component was not found in the image, an empty region is returned in the corresponding element of TrainingComponents and the elements of the four output control parameters are set to the value 0. In contrast, if the index of an initial component is passed in Components, these tuples contain as many elements as matches of the corresponding initial component were found in the image.
The operator get_training_components is particularly useful in order to visualize the result of the training ComponentTrainingID, which was performed with train_model_components. With this, it is possible to evaluate the suitability of the training images or to inspect the influence of the parameters of train_model_components. Sometimes it might be reasonable to restart the training with train_model_components using a different set of training images or after adjusting the parameters.
Contour regions of the initial components or of the model components.
Handle of the training result.
Type of returned components or index of an initial component.
Default value: 'model_components'
Suggested values: 'model_components' , 'initial_components' , 0, 1, 2, 3, 4, 5
Image for which the components are to be returned.
Default value: 'model_image'
Suggested values: 'model_image' , 0, 1, 2, 3, 4, 5, 6, 7, 8
Mark the orientation of the components.
Default value: 'false'
List of values: 'false' , 'true'
Row coordinate of the found instances of all initial components or model components.
Column coordinate of the found instances of all initial components or model components.
Rotation angle of the found instances of all components.
Score of the found instances of all components.
* Get the model image. read_image (ModelImage, 'model_image.tif') * Define the regions for the initial components. gen_rectangle2 (InitialComponentRegions, 212, 233, 0.62, 167, 29) gen_rectangle2 (Rectangle2, 298, 363, 1.17, 162, 34) gen_rectangle2 (Rectangle3, 63, 444, -0.26, 50, 27) gen_rectangle2 (Rectangle4, 120, 473, 0, 33, 20) concat_obj (InitialComponentRegions, Rectangle2, InitialComponentRegions) concat_obj (InitialComponentRegions, Rectangle3, InitialComponentRegions) concat_obj (InitialComponentRegions, Rectangle4, InitialComponentRegions) * Get the training images. gen_empty_obj (TrainingImages) for i := 1 to 4 by 1 read_image (TrainingImage, 'training_image-'+i+'.tif') concat_obj (TrainingImages, TrainingImage, TrainingImages) endfor * Extract the model components and train the relations. train_model_components (ModelImage, InitialComponentRegions, \ TrainingImages, ModelComponents, 22, 60, 30, 0.6, \ 0, 0, rad(60), 'speed', 'rigidity', 0.2, 0.4, \ ComponentTrainingID) * Visualize the result of the training. count_obj (InitialComponentRegions, NumInitComp) count_obj (TrainingImages, NumTrainings) for i := 1 to NumTrainings by 1 select_obj (TrainingImages, TrainingImage, i) for j := 0 to NumInitComp-1 by 1 * Visualize the ambiguous poses of each initial component. get_training_components (TrainingComponents, ComponentTrainingID, \ j, i, 'false', Row, Column, Angle, Score) endfor * Visualize the final poses of the initial components. get_training_components (TrainingComponents, ComponentTrainingID, \ 'initial_components', i, 'false', \ Row, Column, Angle, Score) * Visualize the final poses of the model components. get_training_components (TrainingComponents, ComponentTrainingID, \ 'model_components', i, 'false', \ Row, Column, Angle, Score) endfor
If the handle of the training result is valid, the operator get_training_components returns the value 2 (H_MSG_TRUE). If necessary an exception is raised.
Matching
Operators |