将变换应用于p中的图像列表

2024-09-28 22:23:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图对列表中的每个图像并行应用相同的变换(HOGs/模糊)。图像是使用cv2.imread导入的numpy ndarray,并保存到列表中

当前,当我将图像列表传递给函数时,数组中的一个条目似乎被传递,即图像中的一个像素而不是整个图像。您能否建议如何将整个阵列/映像传递给池中的每个工作进程

谢谢

# imports
from functools import partial
from skimage.feature import hog
from multiprocessing import Pool

def findhog(image):
    return hog(image, visualise=True)[1] # hog returns two things, only return the visualisation

with Pool(processes=4) as pool:
    hogs = pool.map(findhog, listofimages)


Tags: from图像imageimportnumpy列表returncv2