JoshJoshJosh
JoshJoshJosh

Reputation: 917

how to use opencv to convert an image into a matrix in Python

I have read the documentation of opencv regarding image processing but I am still pretty new to opencv. I am trying to convert some images into matrix so that I can do some classification after that. Can anyone help tell me how I should start this? Thanks so much!

Upvotes: 1

Views: 6122

Answers (1)

quantummind
quantummind

Reputation: 2136

If you simply read an image with opencv in python, you will get it in a matrix. Eg.:

import cv2
img = cv2.imread('a.jpg',0)
type(img)
Out[3]: numpy.ndarray
img.shape
Out[4]: (200, 200)

Upvotes: 1

Related Questions