简单拼接图像的tile_images和tile_images_offset算子

简单拼接图像的tile_images和tile_images_offset算子 - xh6300 - 博客园

纸上得来终觉浅,绝知此事要躬行。炒也要炒一遍。

一、简介

有时候通常需要简单的拼图,不涉及图像融合之类的,仅仅是简单的平移将多张图拼接成一张图。tile_imagestile_images_offset就是用于简单拼图的2个算子。

谈到拼图,肯定有以下问题要明确:

1、将多少张图拼起来?由于是多张图,这需要一个元组来存储多张图片的集合。

2、是横向拼图,还是纵向拼图?这涉及拼图的方向。

3、是一张挨着一张无缝拼接吗?能不能做“有缝”的自由拼接?这涉及拼接偏移量。

 二、tile_images算子拼图

tile_images(Images : TiledImage : NumColumns, TileOrder : )

其中:NumColumns指最终拼成的图有多少TileOrder指子图片排列的顺序——垂直方向还是水平方向

*简单拼接图像的tile_images和tile_images_offset算子
read_image (Image1, 'D:/OpenCVandImages/opencv_images/635.png')
read_image (Image2, 'D:/OpenCVandImages/opencv_images/636.png')
read_image (Image3, 'D:/OpenCVandImages/opencv_images/637.png')
read_image (Image4, 'D:/OpenCVandImages/opencv_images/628.png')
get_image_size (Image2, Width, Height)

gen_empty_obj (Images)
concat_obj (Images, Image1, Images)
concat_obj (Images, Image2, Images)
concat_obj (Images, Image3, Images)
concat_obj (Images, Image4, Images)

tile_images (Images, TiledImage,3, 'vertical')

tile_images (Images, TiledImage2,2, 'vertical')

tile_images (Images, TiledImage3,3, 'horizontal')

tile_images (Images, TiledImage4,2, 'horizontal')

扫描二维码关注公众号,回复: 13717197 查看本文章

 

 

 三、tile_images_offset

tile_images_offset (imgs, TiledImage, [0, Height], [0,0], [-1,-1], [-1,-1], [-1,-1], [-1,-1], Width, Height *2)

① 上面这行代码中有很多二维元组,实际上,有几张图元组就有几维

② [0, Height], [0,0]指第一张图的左上角行列坐标是(0, 0),第二张图左上角行列坐标是(Height, 0),也就说第二张图在垂直方向上紧挨着第一张图。

③ 之后的四个参数Row1, Col1, Row2, Col2大家感兴趣可以自己去看帮助文档,一般保持默认值就行。

④  Width, Height *2指的是最终拼接图的宽度是 Width, 高度是Height *2。

 

 


read_image (Image11, 'D:/OpenCVandImages/opencv_images/635.png')
read_image (Image22, 'D:/OpenCVandImages/opencv_images/636.png')
read_image (Image33, 'D:/OpenCVandImages/opencv_images/637.png')
get_image_size (Image2, Width, Height)
gen_empty_obj (imgs)
concat_obj (imgs, Image11, imgs)
concat_obj (imgs, Image22, imgs)


*第一、二、三、四……张图的左上角顶点的位置
tile_images_offset (imgs, TiledImage5, [0, Height], [0,0], [-1,-1], [-1,-1], [-1,-1], [-1,-1], Width, Height *2)

tile_images_offset (imgs, TiledImage6, [0, Height], [0,100], [-1,-1], [-1,-1], [-1,-1], [-1,-1], Width, Height *2)
concat_obj (imgs, Image33, imgs)
tile_images_offset (imgs, TiledImage5, [0, Height,2*Height], [0,0,0], [-1,-1,-1], [-1,-1,-1], [-1,-1,-1], [-1,-1,-1], Width, Height *3)

猜你喜欢

转载自blog.csdn.net/weixin_39354845/article/details/123539054