Hi, I've seen to be having some trouble - here's my situation. I'm trying to access 
all 8 neighbours (if possible) from a central source as:
# - border, C - central pixel, X - neighhbours

####
#CX
#XX
#

Now if C is my central pixel (0,0), I should get back 3 Xs and C, however if I run the 
code below, I get back the wrong answer.

applyKernel(0,0);

public void applyKernel(int x, int y) {
  for(int i=-1; i<2; i++) {
    for(int j=-1; j<2; j++) {
     try {
      aBufferedImage.getRGB(i + x, j + y);
      System.out.println("Good");
      }
     catch(ArrayIndexOutOfBoundsException e) {
       System.out.println("Bad");
       }
     }
   }
 }

The funny thing is, if I run this code replacing my bufferedImage with an array of 
integer I get the correct result for the same starting position of (0,0) - giving me 
1,2, 4,5

####
#123
#456
#786

public static void main(String args[]) {
      int test[][] =
        {
        {1,2,3},
        {4,5,6},
        {7,8,9}
        };

     for(int i=-1; i<2; i++) {
       for(int j=-1; j<2; j++) {
         try {
           System.out.println(test[i][j]);
           }
          catch(ArrayIndexOutOfBoundsException e) {
             System.out.println("Bad");
             }
        }
      }
       }

...Confused...

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to