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 › Image luminosity/brigthness analysis
Page Index Toggle Pages: 1
Image luminosity/brigthness analysis (Read 512 times)
Image luminosity/brigthness analysis
Apr 30th, 2007, 9:04pm
 
Hello, as you see im new in this BB and also new to Processing and java.

I'm working on a sketch that is supposed to fetch images from Flickr via the Flickr API (i'm not working on that so far), do an image analysis of the average brightness, and storing values of brightness and file path in an array.

I would like someone to check my code and tell me if i'm on the right way to do this, or if I'm totally wrong, and should restart form zero.

By the way, I would like to know how to analyse the images placed in the grid i've made. The code to analyse works, but analyses the whole window, and I want to analyse each image average brightness seperatly, and store the values in the array at the top of the sketch.

Any help would be much appreciated, thank you in advance!
I'm really stuck now Undecided

Here is the code : images are simple green or red or whatever jpgs (you just need two or three) and set numberOfImages in void setup()

====================

import processing.opengl.*;

PImage images[];

int pwsize; //picture width
int phsize; //picture height
int numberOfImages; //number of images taken in account
int imgcounter; //counter of images

void setup()
{
 size(1024,768,OPENGL);
 colorMode(RGB,1,1,1);
 background(0);
 smooth();
 noLoop();
 
 pwsize = 100;
 phsize = 75;

 numberOfImages = 11;
 imgcounter = 0;
 images = new PImage[numberOfImages];
 for ( int i=0; i < numberOfImages; i++ ) //loader for the numbered images in data folder, bound with numberOfImages
 {
   images[i] = loadImage("image"+i+".jpg"); //loads the images with the "i" until numerOfImages is reached
   //images[i].filter(GRAY); //converts the images in grayscale.
 }
}

void draw()
{
 picturegrid(25,35,pwsize,phsize);  //draws and defines the void picturegrid beneath
}

void picturegrid(int _gx,int _gy,int w,int h) //defined in void draw, defines the grid of pictures,
{   //loads images in order, loops when it reaches numberOfImages
 float total = 0;
 loadPixels();
 for(int gy = _gy; gy < height-phsize; gy = gy+100)
 {
   for(int gx = _gx; gx < width-pwsize; gx = gx+125)
   {
     image(images[imgcounter],gx,gy,pwsize,phsize);
     imgcounter++;
     imgcounter %= numberOfImages;
     color imgc;
     imgc = pixels[gy+gx]; ////// where there is a problem ///////////////////////////////////////////////////
     total = total+red(imgc)+green(imgc)+blue(imgc)/3;
   }
   total = total/pixels.length;
   println(total);
 }
}
Page Index Toggle Pages: 1