How can solve the error is Undefined function 'size8cut' for input arguments of type 'uint8'.

1 view (last 30 days)
Hello, can anyone help me with the following problem matlab:
I have the function:
function Y=size8cut(X) % cut the rim of the image, to make it more fit to be cut into 256*256 patches
[m,n] = size(X);
if mod(m,8)~=0
X=X(1:m-mod(m,8),:);
end
if mod(n,8)~=0
X=X(:,1:n-mod(n,8));
end
Y=X;
end
the error is
Undefined function 'size8cut' for input arguments of type 'uint8'.
If anyone knows how to solve the problem, please I need to solve it urgent.
Thank

Answers (3)

John D'Errico
John D'Errico on 28 Apr 2015
When you write a function m-file, you need to save it as a .m file on your search path.
Do NOT put it in the MATLAB toolbox directories. MATLAB does not look there for new functions.
help addpath
help savepath
which size8cut -all
  1 Comment
ISMAIL AHMED
ISMAIL AHMED on 29 Apr 2015
Edited: Walter Roberson on 6 May 2015
I am already saved at .m and put it inside my current directory.but still the error.
when write the following
help addpath
help savepath
which size8cut -all
C:\Users\ismail\Desktop\QA_release\QA_release\size8cut.m

Sign in to comment.


Jan
Jan on 28 Apr 2015
Note: A simplification:
function X = size8cut(X)
% cut the rim of the image, to make it more fit to be cut into 256*256 patches
[m, n] = size(X);
X = X(1:m-mod(m,8), 1:n-mod(n,8));
end

Walter Roberson
Walter Roberson on 6 May 2015
How are you invoking your size8cut function? If you are invoking it from within other code, then it is possible that the other code is changing directories (or even the path) so that size8cut can no longer be found. Try adding your directory C:\Users\ismail\Desktop\QA_release\QA_release specifically to the MATLAB path instead of relying on it being found in the current directory.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!