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 Kommentare

Rudrani
Rudrani am 4 Feb. 2023
i am also facing this type of problem please help me
Walter Roberson
Walter Roberson am 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

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 2 Aug. 2018

1 Stimme

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 Kommentare

oshawcole
oshawcole am 2 Aug. 2018
This is happening everytime that I am using imread.
Image Analyst
Image Analyst am 3 Aug. 2018
Unfortunately you forgot to attach 'C:\Users\shrup\Downloads\spec.jpg' so what do/can you expect us to do???
Image Analyst
Image Analyst am 3 Aug. 2018
Unfortunately you forgot to attach 'C:\Users\shrup\Downloads\spec.jpg' ( AGAIN! ) so what do/can you expect us to do???
siqian yang
siqian yang am 7 Sep. 2020
Hello this error keeps happening to me too. And I can not understand you answer well. Could you please expain in detail. Thank a lot.
Image Analyst
Image Analyst am 7 Sep. 2020
Reply to this command and attach your image with the paper clip icon.
Dharanya T
Dharanya T am 31 Dez. 2022
I am facing the same error while opening with imread().
Thank You
Image Analyst
Image Analyst am 31 Dez. 2022
@Dharanya T it's what it says. That file does not exist. You need to pass it the correct full file name.
Dharanya T
Dharanya T am 2 Jan. 2023
Thank You sir. It is resolved now.
Ahmad Bilal
Ahmad Bilal am 9 Apr. 2023
how did you resove it?
Image Analyst
Image Analyst am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (4)

Image Analyst
Image Analyst am 23 Dez. 2018

1 Stimme

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 Kommentare

Thanks for the screenshot. That really helps find the error. You forgot the parentheses. Try this:
folder = 'C:\Users\Administrator\Documents\DistortedImages';
for k = 1 : 980
baseFileName = sprintf('t(%d).bmp', i);
fullFileName = fullfile(folder, baseFileName);
if exist(fullFileName, 'file')
% It exists. Read in image.
theImage = imread(fullFileName);
else
warningMessage = sprintf('File not found:\n%s', fullFileName);
uiwait(warndlg(warningMessage))
continue; % Skip to bottom of loop.
end
Note I changed the loop index variable from i (the imaginary constant) to k. Not a good idea to use i or j as variables.
I also changed the name of the image from I to theImage so it won't ever be confused with 1(one) or l (lower case L).
The Image Analyst,
Thank you for your help. It worked, clearly saw that I forgot the parentheses after added it was achievied.
for k=1:980
k1=num2str(k);
M = imread(['C:\Users\Administrator\Documents\DistortedImages\t (',k1,').bmp']);
Also, thank you for the note of changing the loop variable and the name of the image. Have noted them.
cathrine Mutafya
cathrine Mutafya am 2 Aug. 2022
Bearbeitet: DGM am 13 Feb. 2023
this is the error am having
close all
clc
% provide the data path where the training images are present
% if your matlab environment doesn't support 'uigetdir' function
% change those lines in code for datapath and testpath as :
% datapath = 'give here the path of your training images';
% testpath = 'similarly give the path for test images';
datapath = uigetdir('C:\Users\USER\Desktop\project','C:\Users\USER\Desktop\project\New folder\traingset');
testpath = uigetdir('C:\Users\USER\Desktop\project\New folder','C:\Users\USER\Desktop\project\New folder\test images');
prompt = {'test images(1):'};
dlg_title = 'Input of PCA-Based Face Recognition System';
num_lines= 1;
def = {''};
TestImage = inputdlg(prompt,dlg_title,num_lines,def);
TestImage = strcat(testpath,'\',char(TestImage),'.jpg');
% calling the function
recog_img = facerecog(datapath,TestImage);
selected_img = strcat(datapath,'\',recog_img);
select_img = imread(selected_img);
imshow(selecting_img);
title('Recognized Image');
test_img = imread(TestImage);
figure;
imshow(test_img);
title('Test Image');
result = strcat('the recognized image is : ',recog_img);
disp(result);
Walter Roberson
Walter Roberson am 2 Jan. 2023
use fullfile() instead of building directory paths by hand
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.

Melden Sie sich an, um zu kommentieren.

Felix Ajayi
Felix Ajayi am 23 Dez. 2018
Bearbeitet: Image Analyst am 23 Dez. 2018

0 Stimmen

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 Kommentare

Felix Ajayi
Felix Ajayi am 23 Dez. 2018
Please Experts in the House , the above is a problem not an answer.
Thank you.
Felix Ajayi
Felix Ajayi am 24 Dez. 2018
Verschoben: DGM am 13 Feb. 2023
Hello Image Analyst,
Thank you for the prompt feedback.
I just uploaded the screenshot of the file in file explorer with the folder, and the images shown both reference images and distorted imagest() . In the distorted images folder there are 980 images numbered in bracket that is t(1),t(2), and so on till it reaches t(980).
Hope to read from you soon.
Thank you.
Felix Ajayi
Felix Ajayi am 25 Dez. 2018
Bearbeitet: DGM am 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 am 25 Dez. 2018
Verschoben: DGM am 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.

Melden Sie sich an, um zu kommentieren.

JAMAL CHAFI
JAMAL CHAFI am 15 Dez. 2019

0 Stimmen

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 Kommentar

Image Analyst
Image Analyst am 15 Dez. 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.

Melden Sie sich an, um zu kommentieren.

Aniee
Aniee am 10 Dez. 2024

0 Stimmen

Error in untitled (line 2)
img = imread('black rose.jpg'); % Replace with your image filename
^^^^^^^^^^^^^^^^^^^^^^^^

1 Kommentar

Walter Roberson
Walter Roberson am 10 Dez. 2024
There is no file named black rose.jpg anywhere along your MATLAB search path.

Melden Sie sich an, um zu kommentieren.

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by