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

Django Bad File Descriptor on live server
Why is My Django Form Executed Twice?
In matplotlib, what's the difference between title() and suptitle()?
Modifying and rewriting .csv files in Python
How do I scroll to a certain widget in a QScrollArea
NoSuchKey when getting a signed url for a cloudstorage object with a space in the name
Not sure how to parse this
Error drawing 3D graph in python
How to change objects in a python script by using a keyboardinterrupt for specific keys?
Arguments to an object's parent's function
python regex ignoring underscore incorrectly
Will installing Anaconda3 change Mac OS X default Python version to 3.4?
Devices Labels. Python Code Debugging
Adding list of values to rows, turning the dataframe into long format afterwards
bottle_mysql Encoding failure
What exactly does the {'page': 1} mean here? “BuildError: ('main.user_profile', {'page': 1}, None)”

Categories

HOME
spring
laravel-5
project-management
drupal-7
blockchain
textwatcher
backup
reportportal
otrs
jscript
simpy
netflix-feign
onsen-ui2
image-recognition
symfony2-easyadmin
postmessage
lstm
google-openid
chocolatey
ip-camera
shippo
deb
embedly
google-maps-android-api-2
novnc
badge
ui5
interrupt-handling
dss
owl-api
pentaho-report-designer
thinking-sphinx
configure
protobuf-net
read-write
pyscripter
npm-shrinkwrap
von-neumann
mms
sonarqube-scan
strstr
concrete5-5.7
equivalence
tic-tac-toe
wsadmin
dart-pub
service-fabric-stateful
cppunit
context-free-language
jags
bnd
greenhills
date-range
adler32
redux-router
rsqlite
libtiff.net
iostat
windows-azure-pack
ruby-2.0
json-schema-validator
uwp-maps
spring-lemon
multilingual-app-toolkit
scriptlet
supportmapfragment
git-rebase
except
license-key
acm
direct3d12
persistence.xml
hyperthreading
ninject.web.mvc
robocode
jython-2.7
low-level
chaining
client-side-validation
em
ogr2ogr
node-imagemagick
outline
facebook-wall
dvcs
uipickerviewcontroller
osx-snow-leopard
asp.net-mvc-scaffolding
nimrod
ng-pattern
nuspec
fraud-prevention
device-emulation
fluidsynth
gdataxml
enumerators
subtract
datacontract
smooth
exitstatus
svn-hooks
swfloader
hmacsha1
data-entry

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