Converting matlab to python reference

来源:互联网 发布:纽约客插画知乎 编辑:程序博客网 时间:2024/04/28 14:48

1.转换矩阵数据类型(matlab / python_numpy_opencv)

img = single(img)
img = img.astype(float)

2.read mat in python

import scipy.io as siomatfile = 'data.mat'raw_data = sio.loadmat(matfile)# type(raw_data) is dictraw_data = raw_data["some key"].ravel()boxes = raw_data[:, (1,0,3,2)]-1

Use [:, (1,0,3,2)] to change index order, and -1 since matlab index starting from 1 while python from 0.

0 0
原创粉丝点击