title: Why did this way to save an array of normalized pixels in PNG file not work?
body: <p>I searched many questions about saving an array of pixels in PNG file and made some modifications based on the previous answers. But my code still does not work. The system keeps printing out "cannot convert". Could anybody give any advice? I will greatly appreciate it.</p>
  
  <pre><code>for i in range(0, len(imgfile)-1):
      img = cv2.imread(join(mypath,imgfile[i]),cv2.IMREAD_COLOR)
      imgs[i] = cv2.normalize(img, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, 
  dtype=cv2.CV_32F)
  
  height=100
  width=100
  max_pat=1000
  total_size=len(imgs)*max_pat*height*width*3
  patches = np.zeros(total_size)
  patches = patches.reshape(len(imgs), max_pat, height, width, 3)
  patches = patches.astype('float32')
  
  # Create patches and save to PNG files
  for i in range(0, len(imgs)-1):
      arr = np.array(imgs[i])
      patches[i,:,:,:,:] = extract_patches_2d(arr, (height, width), max_pat)
      for j in range(0, max_pat-1):
          try:
             image.fromarray(patches[i,j,:,:,:],'RGB').save(join(pathto,'pic',str(i),str(j),'.PNG'),'PNG')
          except IOError:
              print "cannot convert"
  </code></pre>