MATLAB Answers


Rectify the error in imread

Asked by varsha reddy on 8 Jul 2018
Latest activity Commented on by Walter Roberson
on 25 Aug 2019 at 22:46
Whenever i try to execute this command: a=imread('itsarose.jpg'); It shows an error: Error using imread>get_full_filename (line 516) File "itsarose.jpg" does not exist.
Error in imread (line 340) fullname = get_full_filename(filename);
i just followed it with an imshow command , nothing much.I use MatlabR2018a. What can i do to rectify this?


Show 1 older comment
Star Strider
on 9 Jul 2018
My pleasure.
It always helps to get the file name correct!
shital shinde on 25 Aug 2019 at 8:11
eventhough I go for .jpg extenction, I got the same error. please give me the suggestion
Walter Roberson
on 25 Aug 2019 at 22:46
shital shinde, at the time you execute the imread(), which directory are you cd() to? What is the name you are passing to imread() ? What is the full path of where the file is actually stored?
Do you happen to be using dir() to find files that are underneath a subfolder? If so then when you are constructing the file name you might be forgetting to include the name of the subfolder.

Sign in to comment.

2 Answers

Answer by Star Strider
on 8 Jul 2018

Your 'itsarose.jpg' image has to be in the MATLAB search path for imread to find it. If it is not, you have to provide the full path to it in the file name.


Sign in to comment.

Answer by Jan
on 8 Jul 2018
Edited by Jan
on 9 Jul 2018

Do not work with relative paths and it is a bad idea to add folders to the path, because it can confuse Matlab substantially, if the added folders contain M-files. Prefer to use absolute paths instead. In which folder is the image file found?
Folder = 'C:\Temp';
a = imread(fullfile(Folder, 'itsarose.jpg'))


get_full_filename is an internal function of imread()
on 9 Jul 2018
@Walter: Thanks. I've removed the corresponding part from my answer.

Sign in to comment.