I am trying to load .mat image exported from Tensorflow with Scipy.io using OpenCV.
I can modify the Tensorflow code to export the .mat image with only 3 channels directly but I will lose a lot of data and it doesn't look correct even.
And that's why I am trying to export the raw data as it is.
In my case I load the .mat file with scipy.io and get the numpy array which looks like this
(640, 640, 128)
and I want to reshape it because OpenCV cannot load an image with 128 channels.
(640, 640, 3)
I am not fully understanding the concept of reshaping and I think I am doing it wrong.
I am getting this error:
ValueError: cannot reshape array of size 52428800 into shape (640,640,3)
Thank you and have a good day,
Hesham
Edit 1: That's the code:
import cv2
import scipy.io as sio
import numpy as np
matfile = 'docia.mat'
img = sio.loadmat(matfile)
img_reshaped = img['embedmap'].reshape(640, 640, 3)
cv2.imshow("segmented_map", img['embedmap'])
cv2.waitKey(0)`