1. 程式人生 > >python-圖片橫向拼接

python-圖片橫向拼接

import os
from PIL import Image
UNIT_SIZE = 220 # the size of image
TARGET_WIDTH = 6 * UNIT_SIZE
save_path = '/root/……cyclegan_6.0/web/result1/'
path = "/root/……cyclegan_6.0/web/images"
images = []  # all pic name
def pinjie():
    for img in os.listdir(path):
        images.append(img)
    if not os.path.exists(save_path):
        os.makedirs(save_path)
    for i in range(len(images)/6): # eyery 3 a group
        imagefile = []
        j = 0
        for j in range(6):
            imagefile.append(Image.open(path+'/'+images[i*6+j]))
        target = Image.new('RGB', (TARGET_WIDTH, UNIT_SIZE))  # width , height
        left = 0
        right = UNIT_SIZE
        for image in imagefile:
            target.paste(image, (left, 0, right, UNIT_SIZE))
            left += UNIT_SIZE
            right += UNIT_SIZE
            quality_value = 1000
        target.save(save_path+'out_{}.jpg'.format(i), quality=quality_value)
if __name__ == '__main__':
    pinjie()

拼接完結果圖:


相關推薦

python-圖片橫向拼接

import os from PIL import Image UNIT_SIZE = 220 # the size of image TARGET_WIDTH = 6 * UNIT_SIZE save_path = '/root/……cyclegan_6.0/web/res

Python-圖片同時橫向縱向拼接

import os from PIL import Image UNIT_SIZE = 220  # the size of image # train train_save_path = '/root/……cyclegan_8.0/web/train_result/'

python 圖片抓取

meid pat book png lis time env cep efault 1、圖片地址為下載地址訪問圖片地址可直接下載的   #!/usr/bin/env python  # -*- coding: utf-8 -*-  import urllib2  impor

Python圖片識別找坐標(appium通過識別圖片點擊坐標)

ron 最好 screen clas shape onf tap 矩形 註意 ***如果只想了解圖片相似度識別,直接看第一步即可 ***如果想了解appium根據圖片識別點擊坐標,需要看第一、二、三步 背景|在做UI測試時,發現iOS自定義的UI控件,appium識

Python #圖片驗證碼

測試 imp ase 使用 color blog pre ati install //測試環境 Python 2.7 安裝 pip install graphic-verification-code 使用 import gvcode img,code=gvcode.

OpenCV--python---圖片的讀取顯示

details detail 筆記 tail opencv 顯示 bsp article enc openCV-Python筆記一:圖像的讀取、顯示和保存 http://blog.csdn.net/djcxym/article/details/52097812

pythonpython圖片轉字符畫

python#知識: #1)pillow:對圖像進行處理 #im = Image.open(IMG) 打開圖像 #im.resize 設置圖像大小 #Image.NEAREST 設置圖像質量,最低質量 #im.getpixel 返回給定位置的像素值 #2)argparse:命令行參數處理:說白了就是定義腳

Python圖片處理 生產4位驗證碼

color class ext string int 填充 分享圖片 www 背景 圖像處理是一門應用非常廣的技術,而擁有非常豐富第三方擴展庫的 Python 當然不會錯過這一門盛宴。PIL (Python Imaging Library)是 Python 中最常用的圖像處

python文本 拼接或合並字符串

bottom word 大致 rep class repeat 字符 position sof python文本 拼接、合並字符串 場景: 拼接、合並字符串 在這個場景中,我們首先想到的當然是使用+或者+=將兩個字符串連接起來 >>> a=‘a‘

圖片src拼接後臺返回ID

sys con fault fig pict www ase end src 本文地址:http://www.cnblogs.com/veinyin/p/8507403.html 在學習 CSS 時只了解了給固定地址,但是如果給的是一個需要拼接的地址就蒙了,以下是基於 V

python 圖片識別灰度

rom nump mage bmp def dst div nsf port # -*- coding: cp936 -*- from skimage import io,transform,color import numpy as np def convert_g

Python圖片縮放

圖片 nbsp odi readlines ont put pre def spa from PIL import Image def size(jpg,now_size): im = Image.open(jpg) width, height = im

Python圖片裁剪實例代碼(如頭像裁剪)

cin follow comm 都是 {} pill 左旋轉 light 頭像裁剪 轉載地址:https://www.jb51.net/article/116789.htm 1. 安裝pillow 用pip安裝 ? 1 pip install pil

python圖片旋轉

import cv2 import matplotlib.pyplot as plt import numpy as np def show(image): plt.imshow(image) plt.axis('off') plt.show() def imread

python圖片轉視訊

使用opencv,將資料夾中的圖片合成avi視訊格式。程式碼如下: """ @file: test.py @time: 2018/10/31 """ import cv2 import glob import os def imgs2video(imgs_dir, save_nam

OpenCV-Python圖片疊加與融合,cv2.add與cv2.addWeighted的區別

python圖片疊加與融合,cv2.add與cv2.addWeighted的區別  目標 影象加法、減法、位運算 學習函式cv2.add(),cv2.addWeighted() 加法: 使用cv2.add()將兩個影象相加,可以使用numpy中的矩陣加法來實現。但是在openc

python圖片生成gif方法彙總

一、使用 PIL 和 images2gif 庫     第一種方法主要是採用PIL和imagegif庫,由於版本的原因,可能有的imagegif對圖片進行處理的時候,以下語句會報錯 writeGif(outfilename

python圖片處理(入門一)

先上一個程式碼例子 from PIL import Image import os,sys for infile in sys.argv[1:]:# print(infile) outfile=os.path.splitext(infile)[0]#os.path.split

JS實現圖片自動滾動(圖片橫向滾動)

實現的效果就是 一排圖片自動橫向滾動,滑鼠指向的時候,暫定滾動,滑鼠離開,繼續滾動 首先看下html程式碼:隨便加入四張圖片 <div id="div1"> <ul> <li><img src="img/logo-black.png"

Python中字串拼接的N種方法

python拼接字串一般有以下幾種方法: ①直接通過(+)操作符拼接 s = 'Hello'+' '+'World'+'!'print(s) 輸出結果:Hello World! 使用這種方式進行字串連線的操作效率低下,因為python中使用 + 拼接兩個字串時會生成一