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 › Image processing
Page Index Toggle Pages: 1
Image processing (Read 1048 times)
Image processing
Jun 26th, 2005, 8:15pm
 
Hi everyone!

I'm new to processing but have experience in java. Right now I'm working on a project where I'm going to scan different stuff and analyze the images for different properties. Does anybody know if it is possible to use processing to look at every single pixel of an image and receive a value of the color of each pixel (or if there's another better way to get information about each pixel in an image).

Regards, Johan Ohlsson.
Re: Image processing
Reply #1 - Jun 27th, 2005, 12:20am
 
Yes you can load an image either as a GIF or JPEG into processing and then peform operations on it.

e.g. heres a program I wrote that loads in an image and outputs the proportions of each colour.

Code:
int[][][] colours = new int[256][256][256];

PImage myb;
myb = loadImage("stripes.gif");

size(myb.height, myb.width);
image(myb, 0, 0);

for(int i=0; i<myb.height*myb.width; i++) {
color c = myb.pixels[i];
colours[int(red(c))][int(green(c))][int(blue(c))]++;
}

for(int r=0; r<256; r++) {
for(int g=0; g<256; g++) {
for(int b=0; b<256; b++) {
if(colours[r][g][b] > 0) {
print(float(colours[r][g][b])/float(myb.height*myb.width)*100+"% rgb("+r+","+g+","+b+"), ");
}
}
}
}
Page Index Toggle Pages: 1