Halcon图像修复

1.之前研究OpenCV的图像修复时,知道Opencv提供的inpaint API能够实现这个效果。

void inpaint(

InputArray src, 原图

InputArray inpaintMask, 二进制掩模,指示要修复的像素

OutputArray dst, 目标图像

double inpaintRadius, 像素周围的邻域补绘。通常,如果要修复的区域很小,则使用较小的值仅产生较少模糊

int flags INPAINT_NS 或 INPAINT_TELEA

)
2.今天研读halcon算子时发现Halcon也有相对应的图像修复算子,而且效果还非常好。以下是算子和案例。
2.1 inpainting_aniso

功能:通过各向异性扩散执行图像修复。

2.2 inpainting_ced

功能:通过一致性增强扩散执行图像修复。

2.3 inpainting_ct

功能:通过连贯传送执行图像修复。

2.4 inpainting_mcf

功能:通过水平线平滑执行图像修复。

2.5 inpainting_texture

功能:通过结构传导执行图像修复。
3.摘取其中两个常用的算子讲解
3.1案例

  • This example program shows how inpainting_ct can be used to remove the
  • fence from an image of a lynx.
    read_image (Image, ‘lynx’)
    get_image_size (Image, Width, Height)
    dev_close_window ()
    dev_open_window (0, 0, Width, Height, ‘black’, WindowHandle)
    set_display_font (WindowHandle, 16, ‘mono’, ‘true’, ‘false’)
    dev_display (Image)
    Message := ‘Image to be inpainted’
    disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
    stop ()
    read_region (Region, ‘lynx_mask’)
    dev_display (Image)
    dev_set_color (‘blue’)
    dev_display (Region)
    Message := ‘Inpainting region’
    disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
    stop ()
    inpainting_ct (Image, Region, InpaintedImage, 13, 70, 1.2, 4, 1)
    dev_display (InpaintedImage)
    Message := ‘Inpainted image’
    disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
    原图
    在这里插入图片描述
    结果图
    在这里插入图片描述
    3.2 案例2
  • This example program shows how inpainting_texture can be used to remove
  • unwanted objects from an image and replace them with natural looking
  • texture
    dev_update_off ()
    read_image (Image, ‘plit2’)
    get_image_size (Image, Width, Height)
    dev_close_window ()
    dev_open_window (0, 0, Width, Height, ‘black’, WindowHandle)
    set_display_font (WindowHandle, 16, ‘mono’, ‘true’, ‘false’)
    decompose3 (Image, ImageR, ImageG, ImageB)
    trans_from_rgb (ImageR, ImageG, ImageB, ImageH, ImageS, ImageV, ‘hsv’)
    threshold (ImageV, Region, 0, 120)
    reduce_domain (ImageS, Region, ImageReduced)
    threshold (ImageReduced, Region, 0, 120)
    dilation_circle (Region, RegionDilation, 2.5)
    opening_circle (RegionDilation, RegionTrees, 6.5)
    dev_display (Image)
    Message := ‘Original image’
    disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
    stop ()
    dev_display (Image)
    dev_set_color (‘white’)
    dev_set_draw (‘margin’)
    dev_set_line_width (3)
    dev_display (RegionTrees)
    Message := ‘Region to be inpainted’
    disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
    stop ()
    inpainting_texture (Image, RegionTrees, InpaintedImage, 11, 40, 0, ‘none’, 0)
    dev_display (InpaintedImage)
    Message := ‘Result of the inpainting’
    disp_message (WindowHandle, Message, ‘window’, 12, 12, ‘black’, ‘true’)
    原图
    在这里插入图片描述
    结果图
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值