I want to be able to read the values of pixels in an image, and then turn them to text so that I can use them for other things. If I have an image loaded as a PImage, is there a way for me to parse it pixel by pixel?
Thanks!
I want to be able to read the values of pixels in an image, and then turn them to text so that I can use them for other things. If I have an image loaded as a PImage, is there a way for me to parse it pixel by pixel?
Thanks!
how about banging pimage into google
i didnt read much but it seems height x width should provide the size of the pixles array so something along the lines of
for (int x=0,x<width x height,x++){
byte mypixel = pixels[x];
// do byte stuff
}
filk:
for (int x=0,x<width x height,x++){
byte mypixel = pixels[x];
// do byte stuff
}
Save CPU time by calculating height x width once before you start the loop
(Edited to change commas to semi-colons)
unsigned int totPixels = width * height;
for (int x=0; x < totPixels; x++){
byte mypixel = pixels[x];
// do byte stuff
}
...R
Save CPU time by calculating height x width once before you start the loop
Save even more time by writing code that actually works. Misusing the comma operator that way is not syntactically wrong, but it won't produce useful iterations of the loop.
PaulS:
Save even more time by writing code that actually works.
Thank you for your sharp eyes. I have corrected the part of the code I claim (some) ownership of.
...R
PaulS:
Save even more time by writing code that actually works. Misusing the comma operator that way is not syntactically wrong, but it won't produce useful iterations of the loop.
:-* my bad, lazy typing.. tho i did qualify with a 'something like'