python


Image data can not convert to float - python


I am trying to display an image in python and I am not 100% sure why imshow() is throwing an error.
The error trace is :
Traceback (most recent call last):
File "knn.py", line 65, in <module>
digit_axes.imshow(paths[0],cmap = cm.Greys_r)
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1892, in inner
return func(ax, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 5118, in imshow
im.set_data(X)
File "/usr/local/lib/python2.7/site-packages/matplotlib/image.py", line 545, in set_data
raise TypeError("Image data can not convert to float")
TypeError: Image data can not convert to float
The code is as follows:
paths = []
paths.append('./images/image1.png')
digit_axes = main_figure.add_subplot(211)
digit_axes.get_xaxis().set_visible(False)
digit_axes.get_yaxis().set_visible(False)
digit_axes.set_title('Image')
digit_axes.imshow(paths[0],cmap = cm.Greys_r)
I think I found the solution by using imread()
img = imread(paths[0])
digit_axes.imshow(img,cmap = cm.Greys_r)

Related Links

Can Nikola bootstrap Jinja2 theme render navigation dropdown menu in nikola?
Running Django unittests causes South migrations to duplicate tables
Python - Regex capture multiple fields and build a dictionary with them
Running multiple Python scripts
programatically change matplotlib fill data
Python: include module into one *.py file
TypeError: can't multiply sequence by non-int of type 'tuple'
Assert that two dictionaries are almost equal
How to retry urllib2.urlopen n times
Python: Create a multidimensional array from a loop
MySQL SELECT: Find all languages by Unicode
how to write IS NOT for str.endswith in python [closed]
Python — Use of Numpy.mgrid and Numpy.reshape
How can I add more to a file when printing stdout to a file, instead of overwriting the file?
How do I create a custom window title bar using PyQt4?
Trouble printing all items from a list in python

Categories

HOME
tensorflow
pug
drupal-7
performancecounter
raspbian
antivirus
ocaml
boost-thread
puppet
otrs
wms
mapbox-gl-js
concourse
bibtex
zend-framework2
jrebel
eval
goutte
aruco
cockroachdb
wordpress-theming
jacoco
mod-pagespeed
android-toolbar
cairo
arm-template
pyephem
jogl
jni
jquery-form-validator
header-files
piwik
onesignal
unpack
forum
websauna
xor
read-write
spreedly
pljson
recurrence-relation
von-neumann
rider
wfp
bigcartel
ntfs-mft
visualstudio.testtools
polyfills
common.logging
nsexception
code-composer
microdata
aqgridview
proof
seamless-immutable
azureportal
slidesjs
update-site
software-product-lines
jackson-databind
faraday
axes
asp.net-mvc-2
plone-3.x
file-diffs
data-import
python-winshell
xaml-designer
chaining
belongs-to
activity-streams
gmaps4rails
collabnet
roxygen
bignum
loop-invariant
dllexport
dig
ng-pattern
sharpmap
zend-lucene
database-permissions
awesomeprint
pascals-triangle
cgpath
autostart
xmlslurper
rose-db-object
gjs
text-size
exitstatus
hibernate3-maven-plugin
scatterview
inline-if

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App