title: How to add a gaussian blur with a real gaussian shape on an image with Python
body: <p>Let's say I have an image as the following 2D arrays:</p>
  
  <pre><code>img = np.array([
             [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0]])
  </code></pre>
  
  <p>I would like to apply a gaussian blur on it so the image would be as following :</p>
  
  <pre><code>imgBlurred = np.array([
             [0.0, 0.2, 0.7, 1, 0.7, 0.2, 0.3, 0.4, 0.5, 0.4, 0.3, 0.2, 0.1],
             [0.0, 0.2, 0.7, 1, 0.7, 0.2, 0.3, 0.4, 0.5, 0.4, 0.3, 0.2, 0.1],
             [0.0, 0.2, 0.7, 1, 0.7, 0.2, 0.3, 0.4, 0.5, 0.4, 0.3, 0.2, 0.1],
             [0.0, 0.2, 0.7, 1, 0.7, 0.2, 0.3, 0.4, 0.5, 0.4, 0.3, 0.2, 0.1],
             [0.0, 0.2, 0.7, 1, 0.7, 0.2, 0.3, 0.4, 0.5, 0.4, 0.3, 0.2, 0.1],
             [0.0, 0.2, 0.7, 1, 0.7, 0.2, 0.3, 0.4, 0.5, 0.4, 0.3, 0.2, 0.1],
             [0.0, 0.2, 0.7, 1, 0.7, 0.2, 0.3, 0.4, 0.5, 0.4, 0.3, 0.2, 0.1],
             [0.0, 0.2, 0.7, 1, 0.7, 0.2, 0.3, 0.4, 0.5, 0.4, 0.3, 0.2, 0.1]])
  </code></pre>
  
  <p>Basically, I would like a result where the gaussian is very thick for the ones values and larger for the 0.5 values in the original image.</p>
  
  <p>Until now, I proceed as following:</p>
  
  <pre><code> from scipy import ndimage
   import numpy as np
   #img is a numpy array
   imgBlurred = ndimage.filters.gaussian_filter(img, sigma=0.7)
   #Normalisation by maximal value, because the gaussian blur reduce the 1 to ~0.5
   imgBlurred = imgBlurred/imgBlurred.max()
   imgBlurred[imgBlurred &gt; 1] = 1# In case of the maximal value was &gt; 1
  </code></pre>
  
  <p>But doing this let the same larger for the ones and 0.5 on the blurred image.
  If someone know how to fix this "issue" I would like to have some advices !</p>