这是导入多个图像和提取功能的程序。 问题是它太慢了 我认为这是因为有很多for循环。
例如
for q in range(0, height-32 , 32):
for w in range(0 , width-32 ,32):
for j in range(0,64,8):
for n in range(0,64,8):
如何更改代码以加快速度?
import numpy as np
from scipy.fftpack import dct
from PIL import Image
import glob
import matplotlib.pyplot as plt
def image_open(path):
image_list = []
#for filename in glob.glob('path/*.jpg'):
for filename in glob.glob(path+'/*.jpg'):
im=Image.open(filename)
image_list.append(im)
return image_list
path = 'C:\\Users\\LG\\PycharmProjects\\photo'
images = image_open(path)
for i in range(0, len(images)):
box3 = (0,0,256,256)
a = images[i].crop(box3)
(y,cb,cr) = a.split()
width , height = y.size
y.show()
for q in range(0, height-32 , 32):
for w in range(0 , width-32 ,32):
for j in range(0,64,8):
for n in range(0,64,8):
print(w/32)
答案 0 :(得分:0)