title: Sobel operator & Convolution with WriteableBitmapEx
body: <p>So I'm using WriteableBitmapEx for an app on Windows RT. I'm trying to implement edge detection on an image using the sobel operator. I have successfully applied both kernels for x and y detection onto the image using .Convolute(), but now I'm stuck adding both images to one. 
  The problem is, that all the pixels of both images seem to have the value 0 for transparency (so the A in ARGB). I can display both images on their own without a Problem, but adding them gives me just a black picture. 
  So my questions are:</p>
  
  <ul>
  <li>Why is the transparency set to 0 for every pixel after the convolution?</li>
  <li>Why can I still display the Image without it being all black?</li>
  <li>Why is it black when I add two Images?</li>
  <li>Is there a better way of combining two Images? Blit unfortunatley doesn't seem to support this kind of pixel-adding. But ForEach really is slow...</li>
  </ul>
  
  <p>For calrification, here's my code so far. I can display both wbmpY and wbmpX,  but finalbmp is completely black.</p>
  
  <pre><code>    public int[,] sobelY = new int[3, 3] { { 1, 2, 1 }, { 0, 0, 0 }, { -1, -2, -1 } };
      public int[,] sobelX = new int[3, 3] { { -1, 0, 1 }, { -2, 0, 2 }, { -1, 0, 1 } };
  
      public void trim(WriteableBitmap wbmp)
      {
          var graybmp = wbmp.Clone();
          graybmp.ForEach(toGrayscale);
  
          var wbmpY = graybmp.Clone();
          var wbmpX = graybmp.Clone();
  
          wbmpY = wbmpY.Convolute(sobelY, 1, 0);
          wbmpX = wbmpX.Convolute(sobelX, 1, 0);
  
          var finalbmp = combineSobel(wbmpX, wbmpY);           
       }
  
      public WriteableBitmap combineSobel(WriteableBitmap img, WriteableBitmap img2)
      {
          int height = img.PixelHeight;
          int width = img.PixelWidth;
          WriteableBitmap result = img.Clone();
          for (int x = 0; x &lt; width; x++)
          {
              for (int y = 0; y &lt; height; y++)
              {
                  Color imgColor = img.GetPixel(x, y);
                  Color img2Color = img2.GetPixel(x, y);
                  Color newColor = Color.FromArgb(
                      Math.Min((byte)Math.Sqrt(Math.Pow(imgColor.A, 2) + Math.Pow(img2Color.A, 2)), (byte)255),
                      Math.Min((byte)Math.Sqrt(Math.Pow(imgColor.R, 2) + Math.Pow(img2Color.R, 2)), (byte)255),
                      Math.Min((byte)Math.Sqrt(Math.Pow(imgColor.G, 2) + Math.Pow(img2Color.G, 2)), (byte)255),
                      Math.Min((byte)Math.Sqrt(Math.Pow(imgColor.B, 2) + Math.Pow(img2Color.B, 2)), (byte)255)
                  );
  
                  result.SetPixel(x, y, newColor);
              }
          }
          return result;
      }
  </code></pre>