我正在尝试在 python 中运行 matlab 代码。
出于这个原因,我安装了 oct2py 来从 Spyder 读取 .m 脚本文件。
脚本文件 (Enhance.m) 包含一些函数。当我尝试调用此脚本文件时,它返回:
Oct2PyError: Octave evaluation error:
error: invalid call to script C:\Users\melih\Fingerprint\Matlab_kod_deneme\Enhance.m error.
我试图通过此代码将我的 python 当前工作空间路径添加到八度,但它没有工作:
oc.addpath(r"C:\Users\melih\Fingerprint\Matlab_kod_deneme")
这是我的主要 python 代码:
from oct2py import Oct2Py
import cv2
from skimage import exposure
import numpy as np
oc = Oct2Py()
#oc.addpath(r"C:\Users\melih\Fingerprint\Matlab_kod_deneme")
img = cv2.imread('mehtap2.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img = exposure.equalize_adapthist(img, clip_limit=0.03)
rows,cols = np.shape(img);
aspect_ratio = np.double(rows)/np.double(cols);
new_rows = 350; # randomly selected number
new_cols = new_rows/aspect_ratio;
#img = cv2.resize(img,(new_rows,new_cols));
img = cv2.resize(img,(np.int(new_rows),np.int(new_cols)));
img = oc.Enhance(img)
img = oc.Enhance(img)
img = oc.Enhance(img)
这是我的 Enhance.m 脚本:
1;
function [Enhimage] = Enhance(img)
%...some operations...
% it calls other functions within Enhance.m script file
Enhimage = enhimg;
end;
Examples of some functions that are inside Enhance.m script file
( they are called by Enhance function) :
function y = raised_cosine(nBlkSz,nOvrlp)
%...some operations...
y(abs(x)<nBlkSz/2)=1;
end;
function w = raised_cosine_window(blksz,ovrlp)
y = raised_cosine(blksz,ovrlp);
w = y(:)*y(:)';
end;