二维测量--血管

对应示例程序:
angio.hdev

目标:提取图像中的血管曲线,并测量直径
思路为:
      1.读取图像
      2.通过设置合理的calculate_lines_gauss_parameters参数,利用算子lines_gauss 提取出图像中血管中心曲线
      3. 对提取出的曲线进行排序,并利用算子get_contour_xld计算出每条小曲线中点的坐标
      4.利用算子get_contour_attrib_xld获取Width_left,Width_right以及Contrast的值
      5.直径的计算公式为:Diameter := (WidthL + WidthR) * sqrt(0.75) ,去均值为最后的结果
      6.在窗口上进行相关显示

图像:
在这里插入图片描述

代码:

dev_update_off ()
read_image (Angio, 'angio-part')
get_image_size (Angio, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowID)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
dev_display (Angio)
disp_message (WindowID, 'Original image', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowID, 'black', 'true')
stop ()
calculate_lines_gauss_parameters (8, [12,0], Sigma, Low, High)
lines_gauss (Angio, Lines, Sigma, Low, High, 'dark', 'true', 'parabolic', 'true')  //提取血管中心线条
select_contours_xld (Lines, RelLines, 'length', 5.0, 999, 0, 0) //XLD选择
dev_set_colored (12)
dev_display (Angio)
dev_display (RelLines)
disp_message (WindowID, 'Extracted lines', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowID, 'black', 'true')
stop ()
count_obj (RelLines, Number)
sort_contours_xld (RelLines, RelLines, 'lower_left', 'true', 'row')  //XLD 排序
gen_empty_obj (PrintedLines)
for I := 1 to Number by 1
    dev_display (Angio)
    dev_set_color ('white')
    dev_display (PrintedLines)
    select_obj (RelLines, Line, I)
    dev_set_color ('green')
    dev_display (Line)
    concat_obj (PrintedLines, Line, PrintedLines)
    get_contour_xld (Line, Row, Col)  //得到线条的点坐标
    meanRow := sum(Row) / |Row|  //求均值Row
    meanCol := sum(Col) / |Col|  //求均值Column
    
    get_contour_attrib_xld (Line, 'width_left', WidthL) //返回Attrib中XLD轮廓Contour的属性Name的值
    get_contour_attrib_xld (Line, 'width_right', WidthR)
    get_contour_attrib_xld (Line, 'contrast', Contrast)
    meanContrast := sum(Contrast) / |Contrast|
    * To display the lines widths, the point at which the gray value drops
    * to 25% of the contrast between the line and the background will be
    * displayed.  This point is given by sqrt(3/4) for the parabolic line
    * model.    
    //进行显示
    
    Diameter := (WidthL + WidthR) * sqrt(0.75)  //直径
    Diam := sum(Diameter) / |Diameter|
    if (meanRow > Height - 50)
        disp_message (WindowID, 'diam: ' + Diam, 'image', Height - 70, meanCol, 'yellow', 'false')
    else
        disp_message (WindowID, 'diam: ' + Diam, 'image', meanRow, meanCol, 'yellow', 'false')
    endif
    disp_message (WindowID, 'Diameters of line segments', 'window', 135, 60, 'black', 'true')
    if (I < 5)
        disp_continue_message (WindowID, 'black', 'true')
        stop ()
    else
       wait_seconds (0.2)
    endif
    
endfor
dev_update_on ()


用到的几个算子:
      calculate_lines_gauss_parameters–从要提取的线条的最大宽度和对比度计算线条高斯的参数sigma、low和high
      lines_gauss --提取血管中心线条
      sort_contours_xld-- XLD轮廓排序
      get_contour_xld–得到线条的点坐标
      get_contour_attrib_xld //返回Attrib中XLD轮廓Contour的属性Name的值

参考资料:
[1]:https://www.cnblogs.com/xiaomaLV2/archive/2011/12/28/2304821.html

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页