title: Sobel Filter giving poor results
body: <p>I was trying to implement the sobel filter in python, but the output was poor and full of noise.
  The Output image i got was:
  <a href="https://i.stack.imgur.com/8McfU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8McfU.png" alt="enter image description here" /></a></p>
  <p>The Input I gave was(after blurring):</p>
  <p><a href="https://i.stack.imgur.com/ldPmF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ldPmF.png" alt="enter image description here" /></a></p>
  <p>The code for sobel filter is below:</p>
  <pre><code>def sobel_filters(img):
    Kx = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]])
    Ky = np.array([[1, 2, 1], [0, 0, 0], [-1, -2, -1]])
  
    Ix = ndimage.filters.convolve(img, Kx)
    Iy = ndimage.filters.convolve(img, Ky)
  
    G = np.sqrt(np.square(Ix) + np.square(Iy))
    G *= 255.0 / G.max()
    
  
    return G
  </code></pre>
  <p>I blurred the results using sigma=1.3. The input image size is 512 by 512.
  I expected the output to be similar to what is shown in here:<a href="https://www.adeveloperdiary.com/data-science/computer-vision/how-to-implement-sobel-edge-detection-using-python-from-scratch/" rel="nofollow noreferrer">https://www.adeveloperdiary.com/data-science/computer-vision/how-to-implement-sobel-edge-detection-using-python-from-scratch/</a></p>