python tensorflow 图片读取 cv2.imread与Image.open 效果对比

import cv2
from PIL import Image
import numpy as np

IMAGE_WIDTH, IMAGE_HEIGHT = 160, 60
fileName = ‘G:\data\yf\zqsx_cs_c7\2DGWK_831846.png’
img = cv2.imread(fileName, 0)
img_ = cv2.resize(img, (IMAGE_WIDTH, IMAGE_HEIGHT))
img = np.float32(img_)
image = img.flatten() / 255

imgArr = []
img__ = np.array(Image.open(fileName).convert(‘L’).resize((IMAGE_WIDTH, IMAGE_HEIGHT), Image.ANTIALIAS))
rows, cols = img__.shape
for i in range(rows):
for j in range(cols):
imgArr.append((img__[i, j] - 128) / 128)
print(imgArr)

python tensorflow 图片读取 cv2.imread与Image.open 效果对比_第1张图片

python tensorflow 图片读取 cv2.imread与Image.open 效果对比_第2张图片

你可能感兴趣的:(python tensorflow 图片读取 cv2.imread与Image.open 效果对比)