brightness is a function in processing, which you can call on color (or pixel.. which holds a color)
so first you need a max-size for the ellipses, and that will also be the spacing between the ellipses
Code:
int spacing = 4;
float d = spacing/255;
noStroke();
for(int j = 0; j < image.height; j++){
for(int i = 0; i < image.width; i++){
int pix = j*image.width+i; // gets the position of the pixel we're about to draw as an ellipse
float b = brightness(image.pixels[pix]); // gets the brightness of that pixel
fill(image.pixels[pix]; // fills ellipse with the current color
ellipse(i*spacing,j*spacing,b*d,b*d); // draws ellipse according to brightness and spacing
}
}
this should do what you're trying to do.. off the top of my head.. not tested
-seltar
-- EDIT --
http://processing.org/learning/index.html <- here's a bunch of cool stuff, all with source..
What is it basicly you're having problems with?
quick overview:
Code:
// all global variables should go here
// by global i mean that you can call upon the variables you create here from anywhere within the program
PImage image; // now we created variable image of type PImage.
void setup()
{
// if you add variables here, they will not be available for other functions, and they will "die" at the end of this function
size(300,300); // size of applet (width, height)
image = loadImage("image.gif"); // loading image.
// the image must be placed in the <data> folder in your sketch
}
void draw()
{
background(0); // to clear the screen after each frame
// this function loops, but only shows the user the result at the end of this function
//here you run your ellipse-drawing function
drawEllipses();
}
void drawEllipses()
{
int spacing = 4;
float d = spacing/255;
noStroke();
for(int j = 0; j < image.height; j++){
for(int i = 0; i < image.width; i++){
int pix = j*image.width+i; // gets the position of the pixel we're about to draw as an ellipse
float b = brightness(image.pixels[pix]); // gets the brightness of that pixel
fill(image.pixels[pix]; // fills ellipse with the current color
ellipse(i*spacing,j*spacing,b*d,b*d); // draws ellipse according to brightness and spacing
}
}
}
-- EDIT --