title: Attempting to resize and reshape an image using CV2 and numpy
body: <p>I have an image I want to make it the correct shape to fit into my keras model.</p>
  
  <p>I wanted to use imread, imresize,imshow from scipy, but it seems that they are now deprecated.</p>
  
  <p>The old code with the functionality I am trying to emulate is:</p>
  
  <pre><code>x = imread('output.png',mode='L')
  x = np.invert(x)
  x = imresize(x,(28,28))
  imshow(x)
  x = x.reshape(1,28,28,1)
  </code></pre>
  
  <p>My new code is as follows:</p>
  
  <pre><code>import numpy as np
  from PIL import Image
  import cv2
  
  def load_image( infilename ) :
      img = Image.open( infilename )
      img.load()
      data = np.asarray( img, dtype="int32" )
      return data
  
  x = load_image("output.png")
  
  x = cv2.resize(x, dsize=(28, 28))
  x = x.reshape(1,28,28,1)
  </code></pre>
  
  <p>I am currently attempting to use cv2 and numpy to handle the image when I get the following error:</p>
  
  <pre><code>x = cv2.resize(x, dsize=(28, 28))
  cv2.error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\imgproc\src\resize.cpp:3922: error: (-215:Assertion failed) func != 0 in function 'cv::hal::resize'
  
  </code></pre>