code: function (inData, outData, width, height) {
          var i, n = width * height * 4,
              gr1, gr2, gg1, gg2, gb1, gb2,
              data1 = [],
              data2 = [];
  
          convolve3x3(inData, data1, width, height,
              [
                  [-1, 0, 1],
                  [-2, 0, 2],
                  [-1, 0, 1]
              ]);
  
          convolve3x3(inData, data2, width, height,
              [
                  [-1, -2, -1],
                  [ 0, 0, 0],
                  [ 1, 2, 1]
              ]);
  
          for (i = 0; i < n; i += 4) {
              gr1 = data1[i];
              gr2 = data2[i];
              gg1 = data1[i + 1];
              gg2 = data2[i + 1];
              gb1 = data1[i + 2];
              gb2 = data2[i + 2];
  
              if (gr1 < 0) {
                  gr1 = -gr1;
              }
              if (gr2 < 0) {
                  gr2 = -gr2;
              }
              if (gg1 < 0) {
                  gg1 = -gg1;
              }
              if (gg2 < 0) {
                  gg2 = -gg2;
              }
              if (gb1 < 0) {
                  gb1 = -gb1;
              }
              if (gb2 < 0) {
                  gb2 = -gb2;
              }
  
              outData[i] = 255 - (gr1 + gr2) * 0.8;
              outData[i + 1] = 255 - (gg1 + gg2) * 0.8;
              outData[i + 2] = 255 - (gb1 + gb2) * 0.8;
              outData[i + 3] = inData[i + 3];
          }
      }
docs: A 3x3 Sobel edge detect (similar to Photoshop's)