melihgorgulu
melihgorgulu

Reputation: 11

Oct2PyError: Octave evaluation error: error: invalid call to script

I'm trying to run matlab code in python.

For this reason, I installed the oct2py to read a .m script file from Spyder.

The script file (Enhance.m) contains some functions. When I try to invoke this script file, it returns:

Oct2PyError: Octave evaluation error:
error: invalid call to script C:\Users\melih\Fingerprint\Matlab_kod_deneme\Enhance.m error.

I tried to add my python current work space path to octave via this code but it didn't work:

oc.addpath(r"C:\Users\melih\Fingerprint\Matlab_kod_deneme")

This is my main python code :

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)

and this is my Enhance.m script :

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;

Upvotes: 1

Views: 2133

Answers (0)

Related Questions