当前位置:网站首页>Halcon knowledge: contour operator on region (2)

Halcon knowledge: contour operator on region (2)

2022-06-24 03:38:00 Mr anhydrous

One 、 summary

Regions and contours are always used interchangeably in calculations , therefore , Know the good outline , Can better solve regional problems . This article introduces three examples of obtaining outer contour .

Two 、 Convex envelope

2.1 . get_region_convex operator

function : Look up the raised surface as the outline (contour).

read_image (Image, 'f:/images/DOTS/block.jpg')
rgb1_to_gray(Image,gray)

get_image_size(gray,width,height)
* gen_rectangle1(rect,0,0,height,width)
fast_threshold (gray,regin,0, 50 , 7)
get_region_convex(regin, row, col)
gen_image_const(BlkImage,'byte',width,height)

for I:=0 to |row|-1 by 1
    tmpRow :=row[I]
    tmpCol :=col[I]
    set_grayval(BlkImage, tmpRow, tmpCol, 228)
endfor
dev_display(BlkImage)
disp_polygon(3600, row, col)

Original picture :

Highlight : 

  The figure connecting the salient points is :

2.2 How to generate contour regions from hash points

  

  • gen_region_polygon( : Region : Rows, Columns : )

By hashing point coordinates , Generate a region , This area is the contour bar area . Through this area , Sub pixel contour lines can be generated . Such as ( The red linear area above ).

  • gen_contour_nurbs_xld

        gen_contour_nurbs_xld Generate approximation NURBS curve ( Non uniform rational B Splines ) Of XLD outline . NURBS A curve is defined by its degree 、 Control polygon ( Through rows and columns )、 Weight vectors and node vectors specify .( The green linear area above ).       

  The degree of the curve determines the degree of differentiability of the curve . The curve lies on its control polygon (Rows,Cols) In the convex hull of . The weight in the weight determines that the curve is controlled by each control point ( That's ok 、 Column ) The degree of attraction . If you choose “ Automatically ”, A weight vector with the same weight for all control points will be generated . Knots A vector describes the domain of a curve . Usually , This parameter can be set to “ Automatically ”.

         Generated Contour The accuracy of depends on two parameters MaxDistance and MaxError. MaxDistance Limit two subsequent Contour The maximum distance between points . Generated Contour And the reality NURBS The maximum distance between curves is limited to MaxError. By default , The approximation must satisfy these two constraints , But you can set one of these parameters to “ Omit ”. Select the MaxError and MaxDistance The lower the , The better the approximation of the curve . Please note that , All contour points are exactly on the curve ( Except for inaccurate values ).

原网站

版权声明
本文为[Mr anhydrous]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206232317118867.html