在MATLAB的官方网站,有关于如何为Python安装MATLAB API的指导教程
import matlab.engine
eng = matlab.engine.start_matlab()
res = eng.GetRowColOfImage('test_img.jpg')
print res
function res = GetRowColOfImage(filename)
% filename = 'test_img.jpg';
test_mat = imread(filename);
row = size(test_mat,1);
col = size(test_mat,2);
res = [row, col];
end
两部分的程序文件需要放在同一个路径下。输入输出参数似乎不用作特殊处理。