了解一下Halcon图像的拆分(fill_interlace)与重置灰度值(set_grayval)
图像拆分多数时候搭配光源分时频闪进行工作。多用于缺陷检测,分时频闪,是一种特殊的线阵扫描方式。 区别于传统线阵扫描的恒定照明方式,分时频闪控制器在线阵相机每采集一行图像时切换光源的种类或亮度,使得多种光源成像有序地间隔排列在图像中。采集完成后对原始图像进行拆分重组,即可在一次扫描中获得多种光源效果图像,从而降低成本,提高兼容性,获得最佳成像效果。
由于实际项目的保密性,现在手动在一张空白图像上通过重置灰度值来模拟分时频闪相机采集图像。
read_image (Image33, 'E:/Halcon数据/资源图片/33.png')
get_image_size (Image33, Width, Height)
重置灰度值模拟图像
for Index := 0 to Height-1 by 4
for Index1 := 0 to Width-1 by 1
set_grayval (Image33, Index, Index1, 10)
endfor
endfor
for Index := 1 to Height-1 by 4
for Index1 := 0 to Width-1 by 1
set_grayval (Image33, Index, Index1, 90)
endfor
endfor
for Index := 2 to Height-1 by 4
for Index1 := 0 to Width-1 by 1
set_grayval (Image33, Index, Index1, 180)
endfor
endfor
模拟图像效果展示
局部放大效果
通过fill_interlace对图像进行拆分
rgb1_to_gray (Image33, GrayImage)
fill_interlace (GrayImage, Image_2N, 'rmodd')
拆分结果
局部放大
*提取2N+1行
fill_interlace (GrayImage, Image_2N_1, 'rmeven')
局部放大效果
*提取4N行
fill_interlace (Image_2N, Image_4N, 'rmodd')
*提取4N+1行
fill_interlace (Image_2N_1, Image_4N_1, 'rmodd')
*提取4N+2行
fill_interlace (Image_2N, Image_4N_2, 'rmeven')
*提取4N+3行
fill_interlace (Image_2N_1, Image_4N_3, 'rmeven')
从4N-到4N-3,对应的灰度值依次为10,90,180,255,对应上面填充效果。