I’m new to image processing and I’m really having a hard time understanding stuff…so the idea is that how do you create a matrix from a binary image in python?
to something like this:
It not the same image though the point is there. Thank you for helping, I appreciate it cheers
Advertisement
Answer
Using cv2 -Read more here
JavaScript
x
5
1
import cv2
2
img = cv2.imread('path/to/img.jpg')
3
resized = cv2.resize(img, (128, 128), cv2.INTER_LINEAR)
4
print pic
5
Using skimage – Read more here
JavaScript
1
3
1
import skimage.io as skio
2
faces = skio.imread_collection('path/to/images/*.pgm',conserve_memory=True) # can load multiple images at once
3
Using Scipy – Read more here
JavaScript
1
4
1
from scipy import misc
2
pic = misc.imread('path/to/img.jpg')
3
print pic
4
Plotting Images
JavaScript
1
4
1
import matplotlib.pyplot as plt
2
plt.imshow(faces[0],cmap=plt.cm.gray_r,interpolation="nearest")
3
plt.show()
4