Thanx BenHem!! it did help ^^ I got rid of my error, but now I'm getting:
ArrayIndexOutOfBoundsException : 2
Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 2
at sketch_aug28a.draw(sketch_aug28a.java:118)
at processing.core.PApplet.handleDraw(PApplet.java:1406)
at processing.core.PApplet.run(PApplet.java:1311)
at java.lang.Thread.run(Unknown Source)
Which PhiLho talks about in his reply to other post saying:
"Oh, and you want to put a limit on nodecount! Otherwise you will get another exception: ArrayOutOfBounds."In my case I suppose that means I should limit "centroidN". But I think I already do :S. By limiting it, he means for example, setting it to 0 again some time right?
Before I check a new frame, my code ends with:
centroidN = 0;
updatePixels();
And I've made the program so it doesnt take into count every blob, just blobs bigger than 1500pixels... so it shouldnt exceed the limit I think, should it? :S
(Or maybe PhiLho means something else by putting a limit to that variable? )
Thanx again
PD: I've just checked something. The program works ok while there is only 1 blob, it only crashes when it detects 2 blobs or more.