ator is based on the first derivative. It takes the image as input and returns the XLD contours. When
using the second derivatives, first a Laplace operator must be executed before the contours along the
zero crossings can be extracted. Besides the gray-value-based methods, HALCON provides the latest
technology for the extraction of color edges.
Besides the extraction of edges, HALCON provides operators for the extraction of lines. In other systems
lines are also called ridges. In contrast to edges, a line consists of two gray value transitions. Thus, a line
can be considered as two parallel edges
The edge and line extraction operators not only provide the XLD contours but also so-called attributes.
Attributes are numerical values; they are associated either with each control point of the contour
(called contour attribute) or with each contour as a whole (global contour attribute). The operators
get_contour_attrib_xld and get_contour_global_attrib_xld enable you to access these val-
ues by specifying the attribute name.
The attribute values are returned as tuples of numbers. Typical attributes for edges are, e.g., the edge am-
plitude and direction. For lines a typical attribute is the line width. The available attributes can be queried
for a given contour with query_contour_attribs_xld and query_contour_global_attribs_xld.
***************************************************
dev_update_window('off')
dev_update_pc('off')
dev_update_var('off')
read_image(Image,'rim')
get_image_size(Image,Width,Height)
dev_close_window()
dev_open_window(0,0,Width,Height,'black',WindowHandle)
threshold (Image, Dark, 3, 128)
connection(Dark,DarkRegions)
select_shape (DarkRegions, Circles, ['area','circularity'], 'and', [50,0.85], [9999,1])
* 作用如图1所示
boundary(Circles,RegionBorder,'inner')
dilation_circle(RegionBorder,RegionDiation,6.5)
union1(RegionDiation,ROIEdges)
reduce_domain(Image,ROIEdges,ImageROI)
edges_sub_pix(ImageROI,Edges,'lanser2',0.3,10,30)
fit_ellipse_contour_xld (Edges, 'fhuber', -1, 0, 0, 200, 3, 2, Row, Column, Phi, Ra, Rb, StartPhi, EndPhi, PointOrder)
NumHoles :=|Ra|
*gen_tuple_const(NumHoles,'positive') 生成一个const 数组
gen_ellipse_contour_xld (ContEllipse, Row, Column, Phi, Ra, Rb, StartPhi, \
EndPhi,gen_tuple_const(NumHoles,'positive'), 1.5)
for i := 0 to NumHoles-1 by 1
sinPhi := sin(Phi[i])
cosPhi := cos(Phi[i])
disp_arrow (WindowHandle, Row[i], Column[i], Row[i] - sinPhi*Ra[i], Column[i] + cosPhi*Ra[i], 1)
disp_arrow (WindowHandle, Row[i], Column[i], Row[i] - cosPhi*Rb[i], Column[i] - sinPhi*Rb[i], 1)
disp_arrow (WindowHandle, Row[i], Column[i], Row[i] + sinPhi*Ra[i], Column[i] - cosPhi*Ra[i], 1)
disp_arrow (WindowHandle, Row[i], Column[i], Row[i] + cosPhi*Rb[i], Column[i] + sinPhi*Rb[i], 1)
set_tposition (WindowHandle, Row[i] - Rb[i] - 50, Column[i] - 85)
write_string (WindowHandle, 'D1=' + 2*Ra[i])
set_tposition (WindowHandle, Row[i] - Rb[i] - 30, Column[i] - 85)
write_string (WindowHandle, 'D2=' + 2*Rb[i])
endfor
* disp_polygon 显示血管轮廓
read_image (Angio, 'angio-part')
get_image_size(Angio,Width,Height)
dev_open_window (0, 0, Width,Height, 'black', WindowID)
dev_display(Angio)
lines_gauss (Angio, Lines, 2, 0, 1, 'dark', 'true', 'parabolic', 'true')
count_obj(Lines,Number)
for I :=1 to Number by 1
select_obj(Lines,Line,I)
get_contour_xld(Line,Row,Col)
get_contour_attrib_xld(Line,'angle',Angle)
get_contour_attrib_xld(Line,'width_left',WidthL)
get_contour_attrib_xld(Line,'width_right',WidthR)
RowR := Row+cos(Angle)*WidthR*sqrt(0.75)
ColR := Col+sin(Angle)*WidthR*sqrt(0.75)
RowL := Row-cos(Angle)*WidthL*sqrt(0.75)
ColL := Col-sin(Angle)*WidthL*sqrt(0.75)
dev_set_color ('red')
dev_display (Line)
dev_set_color ('green')
disp_polygon (WindowID, RowL, ColL)
disp_polygon (WindowID, RowR, ColR)
endfor
Subpixel Thresholding
Besides the subpixel-accurate edge and line extractors, HALCON provides a subpixel-accurate thresh-
old operator called threshold_sub_pix. If the illumination conditions are stable, this can be a fast
alternative.
Subpixel Point Extraction
In addition to the contour-based subpixel-accurate data, HALCON offers subpixel-accurate point opera-
tors for various applications. In the reference manual, these operators can be found in the chapter “Filters
. Points”