4

I am trying to replicate a code taht I did in MATLAB to Python, using OpenCV. I have an image with .mat format that I managed to load, however I cannot displayed it using cv2.imshow(), since it does not supports it. So does anyone know how I can visualize my image??

#Load image
import scipy.io as sio 

matimage='img1.mat'
img = sio.loadmat(matimage)
cv2.imshow('Image', img) 

Thanks in advance!

Dan Mašek
  • 17,852
  • 6
  • 57
  • 85
turningpointe
  • 43
  • 1
  • 4
  • According to the documentation of [`scipy.io.loadmat`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html): "*Returns:* ... dictionary with variable names as keys, and loaded matrices as values." | So no, you can't pass that dictionary to `cv2.imshow` an expect it to work. What variables does the mat file (and therefore the loaded dictionary you misnamed `img`) contain? – Dan Mašek Apr 29 '17 at 15:05
  • I solved it using: "name = sio.loadmat('img1', appendmat=True) a = name['img1']" – turningpointe May 04 '17 at 10:56

0 Answers0