【issue-halcon例程学习】edges_color.hdev

例程功能

 演示如何使用edges_color,展示只能从彩色图像中提取某些边缘的图像,说明edges_coloredges_image输出之间的差异。

代码如下

dev_update_off ()
read_image (Image, 'olympic_stadium')
get_image_size (Image, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_set_part (0, 0, Height - 1, Width - 1)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_display (Image)
Message := 'Color image'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
stop ()
* Convert the color image to a gray value image.  Note that there is no contrast
* between the soccer field and the track in the gray value image.
rgb1_to_gray (Image, GrayImage)
dev_display (GrayImage)
Message := 'Gray value image'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
stop ()
* Compute the color edges without non-maximum suppression and hysteresis
* thresholding, i.e., the raw edge amplitude image.  Note that there is a clearly
* visible edge between the soccer field and the track in the color edge image.
edges_color (Image, ImaAmp, ImaDir, 'canny', 1, 'none', -1, -1)
dev_display (ImaAmp)
Message := 'Color edge image'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
stop ()
* Compute the gray value edges without non-maximum suppression and
* hysteresis thresholding, i.e., the raw edge amplitude image.  Note that there is
* no visible edge between the soccer field and the track in the gray value edge
* image.
edges_image (GrayImage, ImaAmpGray, ImaDirGray, 'canny', 1, 'none', -1, -1)
dev_display (ImaAmpGray)
Message := 'Gray value edge image'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
stop ()
* Now perform the color edge extraction including non-maximum suppression
* and hysteresis thresholding.  Note the segmented edge between the soccer
* field and the track.
edges_color (Image, ImaAmpHyst, ImaDirHyst, 'canny', 1, 'nms', 20, 40)
threshold (ImaAmpHyst, RegionColor, 1, 255)
skeleton (RegionColor, EdgesColor)
dev_display (Image)
dev_set_color ('blue')
dev_display (EdgesColor)
Message := 'Segmented color edges'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
stop ()
* Now perform the gray value edge extraction including non-maximum
* suppression and hysteresis thresholding.  Note the absence of an edge
* between the soccer field and the track.
edges_image (GrayImage, ImaAmpGrayHyst, ImaDirGrayHyst, 'canny', 1, 'nms', 20, 40)
threshold (ImaAmpGrayHyst, RegionGray, 1, 255)
skeleton (RegionGray, EdgesGray)
dev_display (GrayImage)
dev_set_color ('blue')
dev_display (EdgesGray)
Message := 'Segmented gray value edges'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
stop ()
* Now display everything again, while only showing the part of the image
* containing the soccer field and the track.
Row1 := 220
Col1 := 215
Row2 := 399
Col2 := 489
dev_set_part (Row1, Col1, Row2, Col2)
dev_display (Image)
stop ()
dev_display (GrayImage)
stop ()
dev_display (ImaAmp)
stop ()
dev_display (ImaAmpGray)
stop ()
dev_display (Image)
dev_set_color ('blue')
dev_display (EdgesColor)
stop ()
dev_display (GrayImage)
dev_set_color ('blue')
dev_display (EdgesGray)

要点

  1. 例程中着重说明图像中足球场和跑道两个区域间几乎没有对比度。以此为难点分别用edges_coloredges_image分割图像边缘。
    没有对比度意味着灰度化后足球场和跑道区域间边缘特征不明显(看起来像一块区域),后接edges_image 确实没有检测出足球场边框。
    edges_color直接对彩色图像进行边缘提取,效果会好于edges_image方法。两个算子的参数相同,不同点在于入参图像分别为彩色图像和灰度图像。
    edges_color——使用 Deriche、Lanser、Shen 或 Canny 过滤器提取边缘;
    Image ——入参,待处理图像;
    ImaAmp ——出参,边缘幅度(梯度)分割结果;
    ImaDir ——出参,边缘方向分割结果;
    Filter ——入参,过滤器;
    Alpha ——入参,滤镜参数(值越小,平滑效果越强,细节越少,canny算子相反);
    NMS ——入参,极大值抑制;
    Low ——入参,滞后阈值分割的低阈值(不需要则置negative);
    High ——入参,滞后阈值分割的高阈值(不需要则置negative);

相关推荐

  1. issue-halcon学习】ball.hdev

    2024-01-24 11:00:01       29 阅读
  2. issue-halcon学习】fin.hdev

    2024-01-24 11:00:01       48 阅读
  3. issue-halcon学习】measure_arc.hdev

    2024-01-24 11:00:01       23 阅读
  4. issue-halcon学习】fuzzy_measure_pin.hdev

    2024-01-24 11:00:01       32 阅读
  5. issue-halcon学习】edge_segments.hdev

    2024-01-24 11:00:01       35 阅读
  6. issue-halcon学习】edges_color.hdev

    2024-01-24 11:00:01       35 阅读
  7. issue-halcon学习】lines_gauss.hdev

    2024-01-24 11:00:01       27 阅读
  8. issue-halcon学习】rim_simple.hdev

    2024-01-24 11:00:01       31 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-24 11:00:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-24 11:00:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-24 11:00:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-24 11:00:01       20 阅读

热门阅读

  1. ffmpeg 实用命令 -- 缩放与裁切

    2024-01-24 11:00:01       45 阅读
  2. 【笔记】Helm-3 主题-17 弃用的Kubernetes API

    2024-01-24 11:00:01       36 阅读
  3. 推荐系统——基于用户的协同过滤算法

    2024-01-24 11:00:01       27 阅读
  4. 哈希--49. 字母异位词分组/medium 理解度C

    2024-01-24 11:00:01       33 阅读
  5. PingCode:引领敏捷开发的项目管理新范式

    2024-01-24 11:00:01       41 阅读
  6. OpenCV进行图形检测

    2024-01-24 11:00:01       42 阅读
  7. QT基础篇(15)QT5多国语言国际化

    2024-01-24 11:00:01       29 阅读
  8. OpenCV基础-图像数字化

    2024-01-24 11:00:01       38 阅读
  9. docker基础

    2024-01-24 11:00:01       38 阅读
  10. 正则表达式

    2024-01-24 11:00:01       37 阅读
  11. Git Reset 详解:Soft、Mixed、Hard、Keep 选项

    2024-01-24 11:00:01       32 阅读
  12. 使用 ChatGPT 提升工作效率,我的建议是

    2024-01-24 11:00:01       37 阅读