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 › Histogram Problem!
Page Index Toggle Pages: 1
Histogram Problem! (Read 859 times)
Histogram Problem!
Jun 26th, 2007, 3:26pm
 
Hey community,

I tried the histogram example but everytime i start it i get a
"java.lang.ArrayIndexOutOfBoundsException: 200" failure

I just changed the picture like a=loadImage("1.jpg");
which is different from the one in the example ( but has the same proportions and is greyscale too )

Anyone?
Re: Histogram Problem!
Reply #1 - Jun 26th, 2007, 5:08pm
 
You need do change the values of the width and heights of the example pic width the width and height of your pic.
Re: Histogram Problem!
Reply #2 - Jun 26th, 2007, 5:41pm
 
Yes, that's correct but i've already done that.

My picture is 200*200 pix like the example pic!

Re: Histogram Problem!
Reply #3 - Jun 26th, 2007, 8:29pm
 
Okay, I tried a totally blank *.jpg = NO PROB.
Then I simply added another pic, a random photo =



java.lang.ArrayIndexOutOfBoundsException: 200

at Temporary_6399_4861.setup(Temporary_6399_4861.java:26)

at processing.core.PApplet.handleDisplay(PApplet.java:1281)

at processing.core.PGraphics.requestDisplay(PGraphics.java:564)

at processing.core.PApplet.run(PApplet.java:1450)

at java.lang.Thread.run(Unknown Source)


java.lang.ArrayIndexOutOfBoundsException: 200

at Temporary_6399_4861.setup(Temporary_6399_4861.java:26)

at processing.core.PApplet.handleDisplay(PApplet.java:1281)

at processing.core.PGraphics.requestDisplay(PGraphics.java:564)

at processing.core.PApplet.run(PApplet.java:1450)

at java.lang.Thread.run(Unknown Source)


So I can't figure out the problem:
All Images are 8 Bit, RGB, 200 by 200 Pixel....

Maybe someone knows out there?
Re: Histogram Problem!
Reply #4 - Jun 27th, 2007, 1:31am
 
It has to do with the colorMode conversions, where the rgb value 255 maps to width, which is 200, which is too big an index for an array of size 200.  (the example works because that image doesn't contain a maximum red value, so never maps to index 200)  One fix would be to alter the line "colorMode(RGB, width);" to "colorMode(RGB, width-1);".  Hope that helps.  Smiley
Re: Histogram Problem!
Reply #5 - Jun 27th, 2007, 11:19am
 
Hey,

thank you...with "width-1" the image is shown properly BUT there's no historamm ^^.
Re: Histogram Problem!
Reply #6 - Jun 28th, 2007, 1:32am
 
It's being drawn, but it's transparent.  This is a not-so-obvious side effect of the code trying to figure out what type of color value you've specified with that integer.  (99% of the time it does the right thing, but you've found an ambiguous case)

Find the line "stroke(width);" and instead use any (one) of the following to restore the solid white stroke:

stroke(width-1);
stroke(float(width));
stroke(#FFFFFF);
stroke(0xFFFFFFFF);
stroke(g.colorModeX);
stroke(-1);
// etc...
Page Index Toggle Pages: 1