如何将魔杖图像对象转换为 numpy 数组(没有 OpenCV)?

xdz*_*ze2 7 python pdf numpy wand ndimage

我正在使用Wand将 pdf 文件转换为图像。然后,我使用 ndimage 进行进一步的图像处理。

我想直接将 Wand 图像转换为 ndarray ......我在这里看到了答案,但它使用 OpenCV。这可能不使用 OpenCV 吗?

目前我保存了一个临时文件,它用 scipy.misc.imread() 重新打开

Pra*_*sas 6

Wand 0.5.3 开始直接支持

import numpy as np
from wand.image import Image

with Image(filename='rose:') as img:
    array = np.array(img)
    print(array.shape)  #=> (70, 46, 3)
Run Code Online (Sandbox Code Playgroud)