from PIL import Image
import numpy
import os
path = os.getcwd()
#img = cv2.imread(path + '/Image/test_Image.png', cv2.IMREAD_GRAYSCALE)
img = Image.open(path + '/test2/resize.png') # 我使用的是灰度图像
up_img = Image.new('L', (648, 12), 'white') # 制作宽1024,长12的白条
down_img = Image.new('L', (648, 17), 'white') # 制作宽1024,长17的白条
up_img.save(path + '/test2/up.png')
down_img.save(path + '/test2/down.png')
img.paste(up_img, (0, 0)) # 从左上角(0,0)处开始贴图
img.paste(down_img, (0, 495)) # 从下面开始贴图
img.save(path + '/test2/chartlet.png') # 保存图像
markImg = Image.new(‘L’,(1024,12),‘white’)
- 1 (1-bit pixels, black and white, stored with one pixel per byte) #
- L (8-bit pixels, black and white) #0-255 灰度图像
- P (8-bit pixels, mapped to any other mode using a color palette)
- RGB (3x8-bit pixels, true color)
- RGBA (4x8-bit pixels, true color with transparency mask) # PIL图像
- CMYK (4x8-bit pixels, color separation)
- YCbCr (3x8-bit pixels, color video format)