title: Trying to read numpy array into opencv - cv2.imdecode returns empty argument
body: <p>Just getting back into coding after a few years out. Trying to write a piece of code that can go through a folder with .fits files, read out the image data, convert them to an array, read them into opencv, then perform edge detection on them. I can get it working fine with .png files as I don't have to play with arrays. I've done a lot of reading about, and that's enabled me to get to this point. Problem is, img is currently being returned empty, which causes everything else to freak. Any ideas please? Any help would be gratefully received!</p>
  <pre><code>#import packages
  
  import cv2
  from matplotlim import pyplot as plt
  import os
  from astropy.io import fits
  from skimage import img_as_uint
  import numpy as np
  
  #create array with filenames
  
  data = []
  for root, dirs, files in os.walk(r'/Users/hannah/Desktop/firefountain-testset'):
      for file in files:
          if file.endswith('.fits'):
              data.append(file)
  
  #start my loop through the folder
  for i in data:
      fn = i
  #read fits image data
      hdulist = fits.open(fn)
      img_data = hdulist[1].data
  #put fits data into array with dtype set as original
      imgraw=np.array(img_data, dtype = np.uint8)
  #convert to uint16 
      img = img_as_uint(imgraw)
  #crop to area of interest then add into array - possibly don't need second line
      imgcrop = img[210:255,227:277]
      imgcroparr = np.array(imgcrop)
  #attempt to read into cv2 - this is where it loses the data 
  #all fine before this point I believe
      imgfinal = cv2.imdecode(imgcroparr, 0,)
      plt.imshow(imgfinal) 
  #imgfinal returns blank.
  </code></pre>
  <p><a href="https://drive.google.com/open?id=0B5sX66D_9xkwb18tdGpwU1M3bTA" rel="nofollow noreferrer">google drive with .fits files I'm using, plus .png to show what they should look like</a></p>
  <h1>Updated my code</h1>
  <pre><code>for i in data:
      fn = i
      imgraw = fits.getdata(fn)
      imgcrop = imgraw[210:255,227:277]
      img = cv2.imdecode(imgcrop, 0,)
      plt.imshow(img) 
  </code></pre>
  <p>This opens the fits files no issue and imgcrop works as expected. cv2.imdecode(imgcrop, 0), however, throws up the following:</p>
  <p>error: /Users/jhelmus/anaconda/conda-bld/work/opencv-2.4.8/modules/highgui/src/loadsave.cpp:307: error: (-215) buf.data &amp;&amp; buf.isContinuous() in function imdecode_</p>
  <p>Can't find anything on this error in this context online, getting more and more confused. It's probably something very silly and basic that I've forgotten to do, but I can't see it.</p>