Getting error using imread

163 views (last 30 days)
oshawcole
oshawcole on 2 Aug 2018
Commented: Image Analyst on 9 Apr 2023
a=imread('C:\Users\shrup\Downloads\spec.jpg');
I am trying to read an image and this is the error I am getting this error. Please help.
Error using fopen The file name contains characters that are not contained in the filesystem encoding. Certain operations may not work as expected.
Error in imread>get_full_filename (line 504) [fid, errmsg] = fopen(filename, 'r');
Error in imread (line 340) fullname = get_full_filename(filename);
  2 Comments
Rudrani
Rudrani on 4 Feb 2023
i am also facing this type of problem please help me
Walter Roberson
Walter Roberson on 4 Feb 2023
You are using MATLAB Online but you are trying to read files from your C drive. MATLAB Online does not have the ability to read files from your local disk (except the upload feature)
MATLAB Online is being accessed through a browser, and browsers do not have the ability to read files except through a dedicated upload facility. This is for security reasons: no-one should be able to write a web page that reads files on your disk without you knowing

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 2 Aug 2018
Unfortunately you forgot to attach 'C:\Users\shrup\Downloads\spec.jpg', so about all I can say is that the filename is corrupted somehow. It must have hidden/special characters in it like the error message says.
  10 Comments
Ahmad Bilal
Ahmad Bilal on 9 Apr 2023
how did you resove it?
Image Analyst
Image Analyst on 9 Apr 2023
@Ahmad Bilal undoubtedly he corrected the filename string and passed it a string corresponding to a file that actually exists, not to one that does not exist.

Sign in to comment.

More Answers (3)

Image Analyst
Image Analyst on 23 Dec 2018
Felix, I think the error
File "C:\Users\Administrator\Documents\DistortedImages\t1.bmp" does not exist.
is pretty clear. Why do you think it does exist? Can you show us (upload) a screenshot of that file in File Explorer with the folder, and the file both shown?
If you want you can use exist(filename, 'file') to see if the file exists, and skip it if it doesn't exist. Or use imagesDataStore(). Or you can Use the FAQ to run code that gets ONLY files that exist and not ones that don't exist.
  5 Comments
Walter Roberson
Walter Roberson on 2 Jan 2023
use fullfile() instead of building directory paths by hand
Image Analyst
Image Analyst on 2 Jan 2023
Instead of uigetdir and inputdlg, let the user either pick the filename out of a listbox of all the filenames (best), or have them pick each image with uigetfile:
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = pwd; % or 'C:\wherever';
if ~isfolder(startingFolder)
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
TestImage = fullFileName; % Bad name - it's not an image it's a character string.

Sign in to comment.


Felix Ajayi
Felix Ajayi on 23 Dec 2018
Edited: Image Analyst on 23 Dec 2018
Hello Image Analyst, I have issues with sytax below
for i=1:980
i1=num2str(i);
I = imread(['C:\Users\Administrator\Documents\DistortedImages\t',i1,'.bmp']);
Command Window
Error using imread
File "C:\Users\Administrator\Documents\DistortedImages\t1.bmp" does not exist.
It is observed that each image of the 980 distorted images is saved as t(1), t(2), t(3) and so on till it reaches the last image with t(980) all distorted images with different distortion types and levels.
Also, what is the syntax code using referenece image of about 20 images and corresponding distorted images which is about 980 images. with every reference image compared and obtain an output score with respect to the respective 49 distorted images
first reference image to 49 distorted images
second reference image to 49 distorted images
and so on until it reaches the 20th reference image and corresponding distorted image.
All the distorted images are in the database are saved as t(1), t(2) and on till it reaches t(980).
Thank you in advance.
  4 Comments
Felix Ajayi
Felix Ajayi on 25 Dec 2018
Edited: DGM on 13 Feb 2023
The Image Analyst,
Let me use this opportunity again to thank you for your gesture.
Please I have reference and distorted images of different quanity that is not equal quantity in numbers.
Number of reference images is 20
Number of distorted is 980
The first reference image already have 49 distorted images (different distrotion types and levels)
Now, am to input each pair into a local binary(similarity) to get a score that is one reference multiply by 49 distortions to get 49 score on a row. This is applicable to the all 20 reference images x 980 distrotions = 980 scores to have 49 rows and 20 columns.
Attached is a screenshot. Please I will appreciate function of code to achieve this.
Thank you!
Image Analyst
Image Analyst on 25 Dec 2018
Moved: DGM on 13 Feb 2023
This is a project. Not something I can bang out in 5 minutes, or even an hour. If you can't do it yourself, then you can hire a consultant to do it for you. Try fiverr.com or The MathWorks Consulting Best wishes.

Sign in to comment.


JAMAL CHAFI
JAMAL CHAFI on 15 Dec 2019
imread: unable to find file 0+1i.jpeg
called from
imageIO at line 71 column 7
imread at line 106 column 30
TP_ISM at line 12 column 3
  1 Comment
Image Analyst
Image Analyst on 15 Dec 2019
Yes, so? You simply do not have an image file on disk with that particular filename. Are you sure that is the name? It looks very unusual to have a complex number be the file name.
Do you think you should have that file? Are you using fullfile() to construct the full file name, or are you expecting the image file to be in the same folder as your m-file, or at least on the search path.

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!