Summary of Halcon's operators create_shape_model and find_shape_model

Summary of Halcon's operators create_shape_model and find_shape_model

Two key operators were used when doing the subject: create_shape_model and find_shape_model. Some conclusions were made by consulting the information and my understanding of the subject:

1、create_shape_model

create_shape_model(Template :: NumLevelsAngleStartAngleExtentAngleStepOptimizationMetricContrastMinContrast : ModelID)

Template : The template image after reduce_domain ( first determine an ROI area, and then get this area through the operator reduce_domain )

NumLevels : The number of pyramid levels, which can be set to "auto" or an integer of 0-10 ( the larger the value, the shorter the matching time. If the number of pyramid levels is too large, the template is not easy to identify, then it needs to be calculated The MinScore and Greediness parameters in the subfind_shape_model are set lower . If the number of pyramid levels is too small, the template matching time will increase . You can first use the output result of the operator inspect_shape_model to select a better number of pyramid levels. If the number of pyramid levels is Set to auto , the algorithm will automatically calculate the number of layers of the pyramid, you can check the number of layers of the pyramid through the operator get_shape_model_params )

AngleStart : the starting angle of template rotation

AngleExtent : the template rotation angle range, >=0 (The parameters AngleStart, AngleExtent define the possible rotation range of the template. When the subsequent operator find_shape_model finds the template, it can only be matched within this range )

AngleStep : the step length of the rotation angle, >=0 and <=pi/16 ( This parameter defines the step length within the range of the rotation angle. For smaller template images, AngleStep should be set larger . If AngleStep='auto', The operator create_shape_model will automatically define a suitable angle step based on the size of the template . The automatically calculated AngleStep can be viewed using the get_shape_model_params function )

Optimization : Set the template optimization and template creation method ( if Optimization ='none', all model points will be stored; if Optimization is set to'auto', create_shape_model automatically determines the model points; for particularly large template images, set the parameter Optimization It is very useful to set a value other than'none' . The second value of the parameter Optimization defines whether the model is preprocessed , which is set by selecting'pregeneration' or'no_pregeneration'. If the second value is not used (For example: only the first value is set), the default is the setting in the system, which is set by set_system('pregenerate _shape_models',...) )

Metric : Matching method setting ( if Metric='use_polarity' , the target in the image must have the same contrast as the model. For example, if the model is a bright target on a dark background, then only those targets that are brighter than the background can be Find. If Metric ='ignore_global_polarity' , the target can be found even when the contrast between the two is completely opposite. For example, in the example just now, if the target is darker than the background, the target can also be found. The running time of the operator ind_shape_model is here In this case, there will be a slight increase. If Metric='ignore_local_polarity' , the model can be found even if the local contrast changes. For example, when the target contains a part of medium gray, and part of it is brighter and part is darker, this mode is very Useful. Because the running time of the operator find_shape_model increases significantly in this mode, the best way is to use create_shape_model to create several models that reflect the possible contrast changes of the target, and use find_shape_models to match them. If it is a multi-channel image as a template For images or search images, only the first channel is used. If Metric='ignore_color_polarity', the model can be found even if the color contrast changes locally. For example, when the color of a part of the target changes (eg from red to green). This mode is very useful if you cannot know in advance which channel the target is visible in.'ignore_color_polarity' can be used in images with any number of channels. If used in a single channel image, the effect is exactly the same as'ignore_local_polarity' Of )

Contrast : Set the contrast (the parameter Contras determines the contrast of the model points . Contrast is used to measure the local gray value difference between the target and the background and between different parts of the target. Contrast can also be two values, then the template uses approximation The lag threshold algorithm in the edges_image function performs segmentation . Among them, the first value is a relatively low threshold, and the second value is a relatively high threshold. Contrast can also have a third value, which is important in the selection of component sizes The threshold value set when the model component. If a small model component is suppressed, but the hysteresis threshold is not used, then three values ​​must be specified in the Contrast. In this case, the first two values ​​are set to the same value. This parameter The setting can be viewed in the inspect_shape_model function. If Contrast is set to'auto ' , create_shape_model will automatically determine the three values ​​described above, or only automatically set the contrast ('auto_contrast'), hysteresis threshold ('auto_contrast_hyst') or One of the minimum size ('auto_min_size'). Other values ​​that are not automatically set can be set according to the above format. Various combinations are allowed, for example: if you set ['auto_contrast','auto_min_size'], the contrast and minimum size are automatically determined ; If you set ['auto_min_size',20,30], the minimum size will be set automatically, and the hysteresis threshold is set to 20 and 30. Sometimes the result of the automatic setting of the contrast threshold may be unsatisfactory, and you can set these parameters manually.The contrast threshold can be automatically determined using the determine_shape_model_params function, or you can use the inspect_shape_mode function to check the effect before calling create_shape_model )

MinContrast : Set the minimum contrast (The parameter MinContrast is used to determine which contrast of the model must exist when performing the operator find_shape_model for recognition . If you want to recognize the template in the image with low contrast, MinContrast must be set to a relatively small value. MinContrast must be less than Contrast. If MinContrast is set to'auto' , the minimum contrast will be automatically defined based on the noise in the template image. Use the get_shape_model_params function to query the automatically calculated minimum contrast )

 ModelID : output template handle

2、find_shape_model

find_shape_model(ImageModelIDAngleStartAngleExtentMinScoreNumMatchesMaxOverlapSubPixelNumLevelsGreediness : Row,ColumnAngleScore)

Image : the image to be searched

ModelID : The template generated by the operator create_shape_model

AngleStart : the starting angle when searching

AngleExtent : The angle range when searching, must have an intersection with the rangewhen creating the template ( if the template is created, AngleStart=-20°, AngleExtent=40°, set AngleStart=350°, AngleExtent=20° in the search template function find_shape_model , Although the angle modulus is overlapped after 360°, the template will not be found. In order to find the template, you must change AngleStart=350° to AngleStart=-10° )

MinScore : The minimum matching value, the output Score (matching score) is greater than this value ( the larger the MinScore setting, the faster the search. If the template is not occluded in the image, MinScore can be set to 0.8 or even 0.9 )

NumMatches : defines the maximum number of templates found on the image

MaxOverlap : When the found target has overlap, and the overlap is greater than this value, select a good output ( if MaxOverlap=0, the found target area cannot overlap, if MaxOverla p=1, all the found target areas must be returned )

SubPixel : Calculation accuracy setting, five modes, in most cases 2, 3 mode is selected (the least squares adjustment modes are:'least_squares','least_squares_high', and'least_squares_very_high'. If you want to set the least squares, choose'least_squares' ', because this can ensure a trade-off between running time and accuracy. Usually SubPixel is set to'interpolation' )

NumLevels : The number of pyramid levels when searching ( NumLevels can include the second parameter, which defines the lowest number of pyramid levels to find a matching template. NumLevels=[4,2] indicates that the matching starts at the fourth level of the pyramid, and at the second level Pyramid finds a match (the lowest is set to 1). This method can be used to reduce the running time of matching, but the position accuracy in this mode is lower than in the normal mode. The so-called normal mode is matched at the bottom of the pyramid. So if needed For higher accuracy, the SubPixel should be set to at least'least_squares'. If the bottom of the pyramid is set too large, the desired accuracy may not be achieved, or an incorrect matching area may be found. In this case, the minimum number of pyramid levels should be Set to minimum )

Greediness : Greediness , generally set to 0.9. The higher the speed, the faster, but it is easy to find the situation ()

Row , Column Angle Score : output the row and column coordinates, angle, and score of the matching position

Guess you like

Origin blog.csdn.net/Kevin_Sun777/article/details/108936080