jeudi 26 mars 2015

Converting an image to rows of grayscale pixel values

I'd like to use the node indico API. I need to convert the image to grayscale and then to arrays containing arrays/rows of pixel values. Where do I start?



These tools take a specific format for images, a list of lists, each sub-list containing a 'row' of values corresponding to n pixels in the image.




e.g. [[float, float, float ... *n ], [float, float, float ... *n ], ... *n]



Since pixels tend to be represented by RGBA values, you can use the following formula to convert to grayscale.




Y = (0.2126 * R + 0.7152 * G + 0.0722 * B) * A



We're working on automatically scaling images, but for the moment it's up to you provide a square image



Aucun commentaire:

Enregistrer un commentaire