title: TypeError: Image data can not convert to float on plt.imshow()
body: <p>I am trying to segment hand from the depth image attached in this question. In the process, I wrote the below code which process the histogram of the image first and then does median filtering on the processed image. But this code is giving an error continuously even after trying hard to solve it.  </p>
  
  <pre><code>    import numpy as np
      import matplotlib
      import matplotlib.pyplot as plt
      import matplotlib.image as mpimg
      import scipy
      from scipy import ndimage, misc
      from scipy.misc import imshow
      import skimage
      img = mpimg.imread('C:/Users/Prachi/Desktop/kinect_leap_dataset/acquisitions/P1/G1/1_depth.png')
      plt.hist(img.ravel(), bins=256, range=(0.0, 1.0))
      plt.show()
      imgplot = plt.imshow(img, clim=(0.064, 0.068))
      #plt.axis('off')
      plt.show()
      mod_img = ndimage.median_filter(imgplot, 20)
      plt.imshow(mod_img)
      plt.show()
  </code></pre>
  
  <p>This is the error I am getting. Kindly help in solving this error. I have checked each and every thread regarding this error, but was not successful in solving it. 
  It seems that the code is doing median filtering but is not able to display the image as the error is occuring on the line:</p>
  
  <pre><code>plt.imshow(mod_img)
  
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-129-8482175fdf0e&gt; in &lt;module&gt;()
       16 plt.show()
       17 mod_img = ndimage.median_filter(imgplot, 20)
  ---&gt; 18 plt.imshow(mod_img)
       19 plt.show()
  
  C:\Users\Prachi\AppData\Local\Programs\Python\Python36-32\Anaconda3\lib\site-packages\matplotlib\pyplot.py in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, hold, data, **kwargs)
     3155                         filternorm=filternorm, filterrad=filterrad,
     3156                         imlim=imlim, resample=resample, url=url, data=data,
  -&gt; 3157                         **kwargs)
     3158     finally:
     3159         ax._hold = washold
  
  C:\Users\Prachi\AppData\Local\Programs\Python\Python36-32\Anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, *args, **kwargs)
     1895                     warnings.warn(msg % (label_namer, func.__name__),
     1896                                   RuntimeWarning, stacklevel=2)
  -&gt; 1897             return func(ax, *args, **kwargs)
     1898         pre_doc = inner.__doc__
     1899         if pre_doc is None:
  
  C:\Users\Prachi\AppData\Local\Programs\Python\Python36-32\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
     5122                               resample=resample, **kwargs)
     5123 
  -&gt; 5124         im.set_data(X)
     5125         im.set_alpha(alpha)
     5126         if im.get_clip_path() is None:
  
  C:\Users\Prachi\AppData\Local\Programs\Python\Python36-32\Anaconda3\lib\site-packages\matplotlib\image.py in set_data(self, A)
      594         if (self._A.dtype != np.uint8 and
      595                 not np.can_cast(self._A.dtype, np.float)):
  --&gt; 596             raise TypeError("Image data can not convert to float")
      597 
      598         if (self._A.ndim not in (2, 3) or
  
  TypeError: Image data can not convert to float
  </code></pre>
  
  <p>As I cannot attach image so here are the details of the image. </p>
  
  <p>The image (gray) is the '1_depth.png' from the dataset "Microsoft Kinect and Leap Motion" at </p>
  
  <p><a href="http://lttm.dei.unipd.it/downloads/gesture/" rel="nofollow noreferrer">http://lttm.dei.unipd.it/downloads/gesture/</a></p>