halcon 图像拼接

需求:将两个图像各裁剪一半,然后拼接到一张图像中

read_image (Image1, './1 - 副本.bmp')
read_image (Image2, './1 - 副本 (6).bmp')

get_image_size (Image1, Width, Height)

* 左半区域
gen_rectangle1 (Rectangle1, 0, 0, Height, Width/2)
*右半区域
gen_rectangle1 (Rectangle2, 0, Width/2, Height, Width)

* reduce_domain后图像大小和原先一样,crop后裁剪掉其余的,大小变了
reduce_domain (Image1, Rectangle1, ImageReduced1)
crop_domain (ImageReduced1, ImagePart1)
reduce_domain (Image2, Rectangle2, ImageReduced2)
crop_domain (ImageReduced2, ImagePart2)

* 连接两个图像,【注意】Images是一个图像数组!
concat_obj (ImagePart1, ImagePart2, Images)

* 将图像数组中的图像,按照指定的位置进行排布,最后的图像大小由Width, Height决定
* 参数3表示两个图像的起始行偏移
* 参数4表示两个图像的起始列偏移
* 参数5/6/7/8表示对图像进行裁剪
tile_images_offset (Images, TiledImage, [0,0], [0, Width/2], [-1,-1], [-1,-1], [-1,-1],[-1,-1], Width, Height)

write_image (TiledImage, 'bmp', 0, 'comb')

这里关键是concat_obj 和tile_images_offset的搭配使用,前者是一个图像数组,后者将该图像数组中的图像进行排布

你可能感兴趣的:(图像处理,图像处理)