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 › pixel[] color values
Page Index Toggle Pages: 1
pixel[] color values (Read 590 times)
pixel[] color values
Feb 7th, 2007, 7:37pm
 
I am trying to use "pixel[]" to retrieve the color information for an image, and i cannot figure out values that it gives me.  it is too many digits sometimes to just be RGB or anything.  

here is my program code:


colorMode(HSB, 360, 100, 100);
PImage b;
b = loadImage("color.jpg");



 
image(b, 0, 0);
loadPixels();

for (int i = 0; i<width*height; i++) {
println(pixels[i]);
}

and here are some of the values that i get:

-85101
-214115
-14166
-143181
-733776
-1390420
-1652309
-1914967
-1981274
-1719895
-1655385
-3893372
-4157570
-3698814
-2384494
-3175292
-2584179
-2650740
-2848119


what does this mean?  

THANKS!
Re: pixel[] color values
Reply #1 - Feb 7th, 2007, 9:49pm
 
The results you see are because the pixels[] array contains elements of type color, which println apparently doesnt know how to handle.  So this would work:

Code:

color f;

for(i=0;i<width*height;i++){
f=pixels[i];
println(red(f)+","+green(f)+","+blue(f));
}
Re: pixel[] color values
Reply #2 - Feb 7th, 2007, 10:30pm
 
even quicker than double posting is searching the forums! Wink
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1130980939

hex() is also useful for printing colors:
http://processing.org/reference/hex_.html
Page Index Toggle Pages: 1