Note that there are some explanatory texts on larger screens.

plurals
  1. POSobel Operator not working
    primarykey
    data
    text
    <p>I've been spending the last two hours on it and didn't realize where the problem is, would you help me out?</p> <pre><code>public static void sobel(Img img) { int[][][] myArray = img.getmyArray(); int[][][] sobelX = img.copyMyArray(); int[][][] sobelY = img.copyMyArray(); //itearates through the matrix to apply the Sobel Operator for (int line = 1; line &lt; myArray.length -2; line++) for (int column = 1; column &lt; myArray[line].length -2; column++) for(int color = 0; color &lt; 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 for loop } </code></pre> <p>No error messages, the code is compiling and running, but I'm getting a bad output, it is not what I expected.. <img src="https://i.stack.imgur.com/JhGkM.png" alt="Sobel Operator"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload