I am trying to load an image but it is showing the error message Undefined function or method 'readimage' for input arguments of type 'char'.
My calling function is here
h=uicontrol(FigWin,...
'Style','pushbutton',...
'Position',[0,320,80,20],...
'String','Load',...
'Callback',...
['image1=loadimage;'...
'subplot(AxesHandle1);'...
'imagesc(image1);'...
'title(textLoad);'...
'colormap(gray);']);
My called function is below
function image1=loadimage
[imagefile1 , pathname]= uigetfile('*.bmp;*.BMP;*.tif;*.TIF;*.jpg','Open An Fingerprint image');
if imagefile1 ~= 0
cd(pathname);
image1=readimage(char(imagefile1));
image1=255-double(image1);
end
end
Another question, if there are warnings in the program is it a problem? Sorry, i am new to Matlab. Thank you.
I could reproduce this only as a path issue.
The problem is almost certainly that
readimage.misn’t on the path, but was/is instead located in the current directory you tested it from. Right now the easiest solution would be to useimreaddirectly instead of your straight wrapperreadimage, but assuming you want to add functionality toreadimagelater:The simple solution is to add the directory
readimage.mto your path (File->Set Path->Add Folder->Browse to directory with readimage.m). However if you want to test that this is indeed the issue then make sure you can manually runreadimage('existing_image.jpg')(meaning you should browse to that directory) and then run the following modified codeThe only difference from the original code is that we’re not using cd(pathname) to change the directory, but instead are incorporating it into the readimage command itself.
I’m betting that the combination of the cd() command and it not being on the path combined to make you think that readimage(w) was on the path and working, when it was really just in the current directory… until the cd() command was run.