java - Sobel Operator not working -


i've been spending last 2 hours on , didn't realize problem is, me out?

public static void sobel(img img) {      int[][][] myarray = img.getmyarray();     int[][][] sobelx = img.copymyarray();     int[][][] sobely = img.copymyarray();      //itearates through matrix apply sobel operator     (int line = 1; line < myarray.length -2; line++)         (int column = 1; column < myarray[line].length -2; column++)             for(int color = 0; color < 3; color++){              sobelx[line][column][color] =                     -1 * myarray[line-1][column-1][color] +                     -2 * myarray[line-1][column][color] +                     -1 * myarray[line-1][column+1][color] +                       0 * myarray[line][column-1][color] +                      0 * myarray[line][column][color] +                      0 * myarray[line][column+1][color] +                       1 * myarray[line+1][column-1][color] +                      2 * myarray[line+1][column][color] +                      1 * myarray[line+1][column+1][color];              sobely[line][column][color] =                     -1 * myarray[line-1][column-1][color] +                      0 * myarray[line-1][column][color] +                      1 * myarray[line-1][column+1][color] +                      -2 * myarray[line][column-1][color] +                      0 * myarray[line][column][color] +                      2 * myarray[line][column+1][color] +                      -1 * myarray[line+1][column-1][color] +                      0 * myarray[line+1][column][color] +                      1 * myarray[line+1][column+1][color];               //final calculation             myarray[line][column][color] = check_0_255_limit((int)math.sqrt(                     sobelx[line][column][color] * sobelx[line][column][color]                     +                     sobely[line][column][color] * sobely[line][column][color]                     ));          }// end loop } 

no error messages, code compiling , running, i'm getting bad output, not expected.. sobel operator

you calculating gradients each channel independently; need to, output isn't in colour? output of operator, given 0..255 channel value inputs, -1020..1020 need scale before or after getting magnitude sqrt, 0..255 range.

but main problem "final calculation" output overwrites array looping on (i.e. filter reprocessing already-processed values) put in own array. gives cool dithering effect!


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -