title: Image Normalization In Python
body: <p>The image file is as follows:</p>
  
  <pre><code>file = misc.imread("....\image_123.png")
  Image.fromarray(file,'L')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/o0Msn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o0Msn.png" alt="image"></a></p>
  
  <pre><code>file.shape
  (600, 600)
  </code></pre>
  
  <p>Range of pixel values in the file:</p>
  
  <pre><code>print ("min = %s, max = %s"% (np.min(file1), np.max(file1)))
  min = 0, max = 239
  </code></pre>
  
  <p>I want to apply a standard normalization like subtract 255/2 from the pixel values and divide by 255</p>
  
  <pre><code>file_mod = (file.astype(float) - 255/2)/255
  </code></pre>
  
  <p>Next when I try to visualize the normalized image I see a completely distorted output:</p>
  
  <p><a href="https://i.stack.imgur.com/ugs03.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ugs03.png" alt="enter image description here"></a></p>
  
  <p>Even something like below distorts the image:</p>
  
  <pre><code>file_mod = (file.astype(float) - 0.0)/1.0
  </code></pre>
  
  <p>Please help with the process of standard normalization methods.</p>