2

I have an image dataset in the .mat format, what I want is to load this dataset and visualize it's images to interact with them such as resize them and save them in folder in the format that enable me to show them such as .jpg, .png, etc. How can I do that? What I did is save the dataset in the scipy.io path in the python site-packages and write the following code:

import scipy.io as sio    
dbpath = sio.loadmat('COFW_train_color.mat')
listing = os.listdir(dbpath)
num_samples = size(dbpath)
for file in listing:
    im = (dbpath + '\\' + file)
    imag = cv2.imread(im)
    cv2.imshow(imag)

But this did not give me what i need and also return me the following error:

FileNotFoundError: [Errno 2] No such file or directory: 'COFW_train_color.mat'

I also tried to use the full path to the dataset as folloe:

dbpath = "C:\\Users\\SONY\\AppData\\Local\\Programs\\Python\\Python35\\Lib\\site-packages\\scipy\\io\\COFW_train_color.mat"

but I received another error message:

NotImplementedError: Please use HDF reader for matlab v7.3 files

How can I reach and interact with this type of dataset and visualize it's images? can anyone please help me and I will be thankful.

hh tt
  • 223
  • 3
  • 16
  • You should try to use an absolute path to your `.mat` file. – Attila Bognár Dec 17 '18 at 07:08
  • @AttilaBognár thanks for your reply, I'm also used the path, but gave me another error "NotImplementedError: Please use HDF reader for matlab v7.3 files" , can you please help me how can i visualize the images? – hh tt Dec 17 '18 at 07:55
  • What was the other error? You should describe the problem precisely and update the question wtih everything you have tried so far. – Attila Bognár Dec 17 '18 at 07:57
  • @AttilaBognár I mentioned to the error in the comment above and also I updated the question. – hh tt Dec 17 '18 at 10:42
  • Then you should use an HDF reader as the message suggests. See https://stackoverflow.com/questions/17316880/reading-v-7-3-mat-file-in-python – Attila Bognár Dec 17 '18 at 11:22

0 Answers0