当前位置:网站首页>图像合并水平拼接
图像合并水平拼接
2022-08-04 05:29:00 【CV小Rookie】
import PIL.Image as Image
import os
# from IPython import embed
# embed()
# 定义图像拼接函数
def image_compose(imag, imag_1):
src = os.path.join(os.path.abspath(IMAGE_SAVE_PATH), img)
to_image = Image.new('RGB', (2 * h, 1 * w)) # 创建一个新图
# 把两张图片按顺序粘贴到对应位置上
rom_image = Image.open(IMAGES_PATH + imag).resize((h, w), Image.ANTIALIAS)
rom_image_1 = Image.open(IMAGES_PATH_1 + imag_1).resize((h, w), Image.ANTIALIAS)
to_image.paste(rom_image, (0, 0))
to_image.paste(rom_image_1, (h, 0))
to_image.save(src) # 保存新图,还是原来的名称
if __name__ == '__main__':
IMAGES_PATH = '/Users/xxx/Downloads/val/1/' # left image
IMAGES_PATH_1 = '/Users/xxx/Downloads/2/' # right image
IMAGE_SAVE_PATH = '/Users/xxx/Downloads/3/' # new image
IMAGES_FORMAT = ['.jpg'] # 图片格式 jpg png都可以
list_n = []
w = 512 # 每张小图片的大小
h = 512
# 获取图片集地址下的所有图片名称
image_names = [name for name in os.listdir(IMAGES_PATH) for item in IMAGES_FORMAT if
os.path.splitext(name)[1] == item]
image_names_1 = [name for name in os.listdir(IMAGES_PATH_1) for item in IMAGES_FORMAT if
os.path.splitext(name)[1] == item]
# 文件名相同就调用拼接函数
for img in image_names:
for img_1 in image_names_1:
if img == img_1:
image_compose(img, img_1)
边栏推荐
- (TensorFlow) - detailed explanation of tf.variable_scope and tf.name_scope
- flink-sql查询配置与性能优化参数详解
- [Go language entry notes] 13. Structure (struct)
- 剑指 Offer 2022/7/5
- 安装dlib踩坑记录,报错:WARNING: pip is configured with locations that require TLS/SSL
- 超详细MySQL总结
- 属性动画的用法 以及ButterKnife的用法
- WARNING: sql version 9.2, server version 11.0.Some psql features might not work.
- flink onTimer定时器实现定时需求
- oracle的number与postgresql的numeric对比
猜你喜欢

动手学深度学习_卷积神经网络CNN

Logistic Regression --- Introduction, API Introduction, Case: Cancer Classification Prediction, Classification Evaluation, and ROC Curve and AUC Metrics

flink-sql所有语法详解

TensorFlow2学习笔记:5、常用激活函数

flink-sql自定义函数

TensorFlow2学习笔记:8、tf.keras实现线性回归,Income数据集:受教育年限与收入数据集
k3s-轻量级Kubernetes

TensorFlow2 study notes: 8. tf.keras implements linear regression, Income dataset: years of education and income dataset

with recursive用法

Lombok的一些使用心得
随机推荐
flink自定义轮询分区产生的问题
组原模拟题
(十四)平衡二叉树
TensorFlow: tf.ConfigProto() and Session
【树 图 科 技 头 条】2022年6月27日 星期一 今年ETH2.0无望
剑指 Offer 2022/7/12
[Go language entry notes] 13. Structure (struct)
SQL练习 2022/7/5
postgres recursive query
flink-sql所有表格式format
网络大作业心得笔记
flink-sql查询配置与性能优化参数详解
(十三)二叉排序树
Kubernetes集群安装
Kubernetes基本入门-概念介绍(一)
win云服务器搭建个人博客失败记录(wordpress,wamp)
k9s-终端UI工具
yolov3中数据读入(一)
简单明了,数据库设计三大范式
图像形变(插值方法)