当前位置:网站首页>图像合并水平拼接
图像合并水平拼接
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)
边栏推荐
- 【CV-Learning】卷积神经网络
- Linear Regression 02---Boston Housing Price Prediction
- Briefly say Q-Q map; stats.probplot (QQ map)
- MySql的concat和group_concat的区别
- SQL练习 2022/7/2
- SQL练习 2022/7/5
- win云服务器搭建个人博客失败记录(wordpress,wamp)
- 【CV-Learning】Image Classification
- [Deep Learning 21 Days Learning Challenge] 1. My handwriting was successfully recognized by the model - CNN implements mnist handwritten digit recognition model study notes
- Install dlib step pit record, error: WARNING: pip is configured with locations that require TLS/SSL
猜你喜欢
随机推荐
TensorFlow:tf.ConfigProto()与Session
数据库根据提纲复习
EPSON RC+ 7.0 使用记录一
【CV-Learning】目标检测&实例分割
剑指 Offer 2022/7/8
flink onTimer定时器实现定时需求
[Deep Learning 21 Days Learning Challenge] 1. My handwriting was successfully recognized by the model - CNN implements mnist handwritten digit recognition model study notes
TensorFlow2学习笔记:6、过拟合和欠拟合,及其缓解方案
thymeleaf中 th:href使用笔记
线性回归简介01---API使用案例
Usage of RecyclerView
【CV-Learning】图像分类
TensorFlow2学习笔记:7、优化器
Androd Day02
逻辑回归---简介、API简介、案例:癌症分类预测、分类评估法以及ROC曲线和AUC指标
SQL练习 2022/7/5
The difference between oracle temporary table and pg temporary table
安装dlib踩坑记录,报错:WARNING: pip is configured with locations that require TLS/SSL
(TensorFlow)——tf.variable_scope和tf.name_scope详解
postgres recursive query









