Reputation: 1
Trying to complete a simple school exercise but I'm stuck at the beginning. This is the code that doesn't work:
from skimage import io
img = io.imread('mypic.jpg')
io.imshow(img)
io.show()
After execution I get this error:
Exception in Tkinter callback Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1536, in __call__
return self.func(*args)
File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 283, in resize
self.show()
File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 355, in draw
tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
File "/usr/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 26, in blit
_tkagg.tkinit(tk.interpaddr(), 1)
OverflowError: Python int too large to convert to C long
I also tried the same thing with OpenCV library and I got a similar result: Code
import numpy as np
import cv2
img = cv2.imread('mypic.jpg',0)
cv2.imshow('image',img)
waitKey(0)
Error:
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /builddir/build/BUILD/opencv-2.4.12.3/modules/highgui/src/window.cpp, line 261
Traceback (most recent call last):
File "imagetry.py", line 6, in <module>
cv2.imshow('lasta',img)
cv2.error: /builddir/build/BUILD/opencv-2.4.12.3/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow
I'm running this on 32-bit Fedora 24 and Python 2.7. I would really appreciate your help!
Upvotes: 0
Views: 1890
Reputation: 406
The basic way of reading an image in python using open CV is as follows
import cv2
img = cv2.imread('mypic.jpg',0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Upvotes: 1