当前位置:网站首页>图像合并水平拼接
图像合并水平拼接
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)
边栏推荐
猜你喜欢
![[Deep Learning 21 Days Learning Challenge] 1. My handwriting was successfully recognized by the model - CNN implements mnist handwritten digit recognition model study notes](/img/62/ab3dbbd7d4d0009c7cba5e45879f25.png)
[Deep Learning 21 Days Learning Challenge] 1. My handwriting was successfully recognized by the model - CNN implements mnist handwritten digit recognition model study notes

(六)递归

Lombok的一些使用心得

Thoroughly understand box plot analysis

(十一)树--堆排序
![[Go language entry notes] 13. Structure (struct)](/img/0e/44601d02a1c47726d26f0ae5085cc9.png)
[Go language entry notes] 13. Structure (struct)

纳米级完全删除MYSQL5.7以及一些吐槽

Simple and clear, the three paradigms of database design

Matplotlib中的fill_between;np.argsort()函数

Install dlib step pit record, error: WARNING: pip is configured with locations that require TLS/SSL
随机推荐
NFT市场以及如何打造一个NFT市场
[Go language entry notes] 13. Structure (struct)
Th in thymeleaf: href use notes
Introduction of linear regression 01 - API use cases
EPSON RC+ 7.0 使用记录一
Logistic Regression --- Introduction, API Introduction, Case: Cancer Classification Prediction, Classification Evaluation, and ROC Curve and AUC Metrics
数据库根据提纲复习
读研碎碎念
剑指 Offer 2022/7/12
(TensorFlow)——tf.variable_scope和tf.name_scope详解
(十六)图的基本操作---两种遍历
剑指 Offer 2022/7/9
Kubernetes基础入门(完整版)
Lombok的一些使用心得
SQL练习 2022/7/1
flink-sql所有数据类型
【深度学习21天学习挑战赛】0、搭建学习环境
Linear Regression 02---Boston Housing Price Prediction
简单明了,数据库设计三大范式
TensorFlow2学习笔记:4、第一个神经网模型,鸢尾花分类