We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › pixel recognition
Page Index Toggle Pages: 1
pixel recognition? (Read 643 times)
pixel recognition?
Sep 10th, 2007, 11:31pm
 
hi
Warning: I am completely new to processing and have no idea what i am talking about!!!

I somehow need to be able to read a pixel from an image and depending on its tone / black, white / hue be able to produce that pixel as something else (as a cross for example).

I have been reading through the libraries etc for clues and ideas. Does anyone have any ideas where I could find help to work this out.

Sorry my explanation isnt clearer ... just message if you need more defining.

Thanks!!! Smiley
Re: pixel recognition?
Reply #1 - Sep 11th, 2007, 12:32am
 
hi,

have a look at the learning-section of this website. What you want is looping throuth the pixels-array. here's a start:
http://processing.org/learning/topics/pixelarray.html

http://processing.org/learning/examples/explode.html

you can access the pixel[]-array of every PImage. After creating a PImage, something like this:
Quote:


PImage myImg;
void setup() {
  (...)
  myImg = loadImage("somepic.jpg");
  (...)
}


you can use myImg.pixels[0] to get the color of the first pixel of the image, and myImg.pixels[myImg.width*myImg.height] to get the last pixel.

Quote:


void draw() {
 color c = myImage.pixels[23];
 fill(c);
 // -> everything you draw here will be filled with the color of pixel nr 23 in your image.
}




hope this makes sense...
Re: pixel recognition?
Reply #2 - Sep 13th, 2007, 2:35pm
 
Thanks. That helps in my process a little. Its a research paper so anything I can come up with will hopefully get me a little closer to finishing!
Page Index Toggle Pages: 1