Oct2PyError:倍频程计算错误:错误:对scrip的调用无效

2024-05-16 02:18:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着用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当前工作空间路径添加到octave,但没有成功:

^{pr2}$

这是我的主要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;

Tags: 代码import脚本imgnewnpscriptfunction