本文主要是介绍halcon-基于视觉的血管支架检测和测量,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.示例图
(1)原始图
(2)结果图
2
2.halcon 代码
* vessel.hdev: Segmentation & Measurement of a blood vessel
*
dev_update_window ('off')
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowID)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
read_image (Image, 'vessel')
dev_display (Image)
disp_continue_message (WindowID, 'black', 'true')
stop ()
dev_set_draw ('fill')
dev_set_color ('green')
dev_set_line_width (3)
texture_laws (Image, Texture, 'el', 2, 5)
dev_display (Texture)
disp_continue_message (WindowID, 'black', 'true')
stop ()
mean_image (Texture, Energy, 211, 61)
dev_display (Energy)
disp_continue_message (WindowID, 'black', 'true')
stop ()
dev_display (Image)
binary_threshold (Energy, Vessel, 'smooth_histo', 'dark', UsedThreshold)
dev_display (Vessel)
disp_continue_message (WindowID, 'black', 'true')
stop ()
dev_set_draw ('margin')
get_region_contour (Vessel, VesselRows, VesselColumns)
gen_region_points (VesselBoundary, VesselRows, VesselColumns)
dev_display (Image)
clip_region (VesselBoundary, Boundaries, 0, 2, 511, 509)
dev_display (Boundaries)
smallest_rectangle1 (Boundaries, UpperRow, Column1, LowerRow, Column2)
disp_continue_message (WindowID, 'black', 'true')
stop ()
*
* Measurement of Diameter
*
Diameter := []
dev_set_color ('red')
dev_update_var ('off')
dev_update_time ('off')
dev_update_pc ('off')
for i := 2 to 509 by 1gen_region_line (ScanLine, UpperRow, i, LowerRow, i)dev_display (ScanLine)intersection (Boundaries, ScanLine, BoundaryPoints)get_region_points (BoundaryPoints, Rows, Columns)Diameter := [Diameter,abs(Rows[|Rows| - 1] - Rows[0])]
endfor
dev_update_pc ('on')
dev_update_time ('on')
dev_update_var ('on')
Diameter := Diameter
*
* statistics
*
meanDiameter := sum(Diameter) / |Diameter|
minDiameter := min(Diameter)
dev_set_color ('green')
dev_display (Image)
dev_display (Boundaries)
dev_set_color ('yellow')
get_image_size (Image, Width, Height)
get_string_extents (WindowID, 'meanDiam: ' + meanDiameter + ', minDiameter: ' + minDiameter, Ascent, Descent, TxtWidth, TxtHeight)
disp_message (WindowID, 'meanDiam: ' + meanDiameter + ', minDiameter: ' + minDiameter, 'image', (UpperRow + LowerRow) / 2, (Width - TxtWidth) / 2, 'yellow', 'false')
* get_mbutton (WindowID, Row, Column, Button)
dev_set_draw ('fill')
dev_set_line_width (1)
dev_update_window ('on')
这篇关于halcon-基于视觉的血管支架检测和测量的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!