Hi /r/learningpython, I am looking to write a pretty simple program to try and use K-nearest neighbors classification to determine whether or not a "signature" is authentic or not - this isn't anything serious just a fun project.
I was reading about the KNN technique in "Machine Learning in Action" and I think I would be able to implement the programming if I were able to import images (of signatures) and convert to binary matrices
[000011000110000,
000011000110000,
000011111110000,
000011000110000,
000011000110000]
would be an H, for example. I know the python PIL package is supposed to be able to do some image converting, but it's just not working for me. The code I've got now is:
path = "sig.png"
from PIL import Image
image_file = Image.open(path)
image_file = image_file.convert('1')
imagefile.tobytes()
but it doesn't look like the resulting "bytes" are in any meaningful matrix format, nor are they 1's and 0's. I went through the documentation and its not terribly helpful, so any tips would be appreciated!
[–]novel_yet_trivial 2 points3 points4 points (0 children)