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 & HelpPrograms › Seeding a 1d CA with a 2d image
Page Index Toggle Pages: 1
Seeding a 1d CA with a 2d image? (Read 319 times)
Seeding a 1d CA with a 2d image?
Jan 9th, 2009, 6:00pm
 
I'm a beginning processing user, I'm interested in using cellular automata to filter images-
Some examples:
http://onecm.com/sketches/mycelium/
http://www.flong.com/projects/zoo/

I've been using a mac node-based image editor called Toolbox, which lets you feed an image through a wolfram 1d cellular automata patch to produce some interesting results. I would like to learn to do the same thing programmatically in processing, but the problem is that the Wolfram ruleset is one dimensional- so I would have to find a way to pipe the bright pixels of the image in line by line as individual arrays or something. I'm just not advanced enough yet to figure out an elegant way of doing it.

Does anyone know what approach I should take?



Re: Seeding a 1d CA with a 2d image?
Reply #1 - Jan 11th, 2009, 11:48am
 
You can get a quick 1D array of image data by using pixels[].
http://processing.org/reference/pixels.html

Something like this:

Quote:
PImage pic;

void setup() {
 size(400, 400); //set to whatever you like, I assumed pic was the same size

 //pic = new PImage(400, 400); //this would give you a blank  picture

 pic = loadImage("somepicture.jpg")
}

void draw() {

 for (int i=0; i<pic.pixels.length; i++) {
   //do something to the data
   
   pic.pixels[i] = color(0, 128, 0);//turns green :]
 }

 //Show the results
 image(pic, 0, 0);

}

Re: Seeding a 1d CA with a 2d image?
Reply #2 - Jan 11th, 2009, 5:16pm
 
Thanks!
Page Index Toggle Pages: 1