I am converting pdf files to image using Wand. Then, I do further image processing using ndimage.
I would like to directly convert the Wand image into a ndarray... I have seen the answer here, but it use OpenCV. Is this possible without using OpenCV?
For the moment I save a temporary file, which is re-opened with scipy.misc.imread()
Images are an easier way to represent the working model. In Machine Learning, Python uses the image data in the format of Height, Width, Channel format. i.e. Images are converted into Numpy Array in Height, Width, Channel format.
As of Wand 0.5.3 this is supported directly
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With