当前位置:网站首页>图像合并水平拼接
图像合并水平拼接
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)
边栏推荐
- postgres recursive query
- SQL练习 2022/7/4
- The use of the attribute of the use of the animation and ButterKnife
- 超详细MySQL总结
- 双重指针的使用
- WARNING: sql version 9.2, server version 11.0.Some psql features might not work.
- 动手学深度学习_卷积神经网络CNN
- 【CV-Learning】Convolutional Neural Network
- TensorFlow2学习笔记:7、优化器
- TensorFlow2学习笔记:4、第一个神经网模型,鸢尾花分类
猜你喜欢

Introduction of linear regression 01 - API use cases
![[Deep Learning 21 Days Learning Challenge] Memo: What does our neural network model look like? - detailed explanation of model.summary()](/img/99/819ccbfed599ffd52307235309cdc9.png)
[Deep Learning 21 Days Learning Challenge] Memo: What does our neural network model look like? - detailed explanation of model.summary()

两个APP进行AIDL通信

【深度学习21天学习挑战赛】0、搭建学习环境

双重指针的使用
Redis持久化方式RDB和AOF详解

剑指 Offer 2022/7/1

TensorFlow2 study notes: 7. Optimizer

Dictionary feature extraction, text feature extraction.

(十)树的基础部分(一)
随机推荐
(十五)B-Tree树(B-树)与B+树
(十一)树--堆排序
Polynomial Regression (PolynomialFeatures)
TensorFlow2 study notes: 6. Overfitting and underfitting, and their mitigation solutions
(五)栈及其应用
TensorFlow2学习笔记:4、第一个神经网模型,鸢尾花分类
JPEG2jpg
【树 图 科 技 头 条】2022年6月28日 星期二 伊能静做客树图社区
Lombok的一些使用心得
sql中group by的用法
sklearn中的pipeline机制
read and study
(十四)平衡二叉树
【CV-Learning】图像分类
线性回归02---波士顿房价预测
【CV-Learning】卷积神经网络预备知识
剑指 Offer 2022/7/5
[Introduction to go language] 12. Pointer
Kubernetes基本入门-集群资源(二)
RecyclerView的用法