在 measure_arc.hdev 示例的基础上,修改优化,并添加注释
read_image (Zeiss1, 'zeiss1')
get_image_size (Zeiss1, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width / 2, Height / 2, 'black', WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_display (Zeiss1)
* disp_continue_message (WindowHandle, 'black', 'true')
* stop ()
* 弧线圆心
Row := 275
Column := 335
*disp_cross (WindowHandle, Row, Column, 6, 0)
* 弧线半径
Radius := 107
*disp_circle (WindowHandle, Row, Column, Radius)
* 弧线起点和终点
AngleStart := -rad(55)
AngleExtent := rad(170)
dev_set_draw ('fill')
dev_set_color ('green')
dev_set_line_width (1)
*draw_ellipse (WindowHandle, Row, Column, Phi, Radius1, Radius2)
get_points_ellipse (AngleStart + AngleExtent, Row, Column, 0, Radius, Radius, RowPoint, ColPoint)
disp_arc (WindowHandle, Row, Column, AngleExtent, RowPoint, ColPoint)
dev_set_line_width (3)
* 准备用于提取垂直于环形弧的直边的测量对象
* CenterRow (input_control) Row coordinate of the center of the arc.
* CenterCol (input_control) Column coordinate of the center of the arc.
* Radius (input_control) Radius of the arc.
* AngleStart (input_control) Start angle of the arc in radians.
* AngleExtent (input_control) Angular extent of the arc in radians.
* AnnulusRadius (input_control) Radius (half width) of the annulus.
* Width (input_control) Width of the image to be processed subsequently.
* Height (input_control) Height of the image to be processed subsequently.
* Interpolation (input_control) Type of interpolation to be used.
* MeasureHandle (output_control) Measure object handle.
gen_measure_arc (Row, Column, Radius, AngleStart, AngleExtent, 10, Width, Height, 'nearest_neighbor', MeasureHandle)
count_seconds (Seconds1)
* 提取垂直于矩形或环形弧的直边
* Image (input_object) 输入图像
* MeasureHandle (input_control) 测量对象句柄
* Sigma (input_control) 高斯平滑系数
* Threshold (input_control) 最小边缘幅度
* Transition (input_control) Light/dark 或者 dark/light 边缘
* Select (input_control) 选择终点
* RowEdge (output_control) Row coordinate of the center of the edge
* ColumnEdge (output_control) Column coordinate of the center of the edge
* Amplitude (output_control) 边缘的边缘幅度(带符号)
* Distance (output_control) 连续边缘之间的距离
measure_pos (Zeiss1, MeasureHandle, 1, 10, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)
count_seconds (Seconds2)
Time := Seconds2 - Seconds1
* 计算第二点到第三点之间的距离
distance_pp (RowEdge[1], ColumnEdge[1], RowEdge[2], ColumnEdge[2], IntermedDist)
dev_set_color ('blue')
disp_cross (WindowHandle, RowEdge, ColumnEdge, 6, 0)
dev_set_color ('red')
disp_line (WindowHandle, RowEdge[1], ColumnEdge[1], RowEdge[2], ColumnEdge[2])
dev_set_color ('yellow')
disp_message (WindowHandle, 'Distance: ' + IntermedDist, 'image', -1, -1, 'yellow', 'false')
* 释放测量对象
close_measure (MeasureHandle)