title: Fast image normalisation in python
body: <p>I am looking for a faster approach to normalise image in Python. I want to convert all pixels to values between 0 and 1. </p>
  
  <p>INPUT: 150x150 RGB images in JPEG format. </p>
  
  <p>OS/HARDWARE: LINUX/P40 GPU with 8GB RAM</p>
  
  <p>USE-CASE: Image Preprocessing for a real-time classification task.</p>
  
  <p>Current time per image is ~5-10 milliseconds. I am looking for a method that can reduce this time. </p>
  
  <p>I tried two approaches, with numpy and opencv. </p>
  
  <h1>Using numpy (Approx time: 8ms):</h1>
  
  <pre><code>norm = (img - np.min(img)) / (np.max(img) - np.min(img))
  </code></pre>
  
  <h1>Using opencv (Approx time: 3ms):</h1>
  
  <pre><code>norm = cv2.normalize(img, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)
  </code></pre>
  
  <p>Both these methods are slow for my usecase. Can anyone guide me with a faster method for image normalisation?</p>