필터 지우기
필터 지우기

Unable to read image.JPG file

조회 수: 19 (최근 30일)
Nataliya
Nataliya 2016년 12월 16일
댓글: Guillaume 2018년 4월 16일
I am getting the error
Error using imread (line 349)
File "E:\GT\out_of_focus0016.JPG" does not exist.
How can i resolve this error. i have the image in the folder by this name. Actually the problem is, its reading the images having .jpg extension but giving error for images having .JPG (capital) extension. How can I resolve this. Please help.
  댓글 수: 4
Nataliya
Nataliya 2016년 12월 16일
Its returning 0 (zero)
José-Luis
José-Luis 2016년 12월 16일
편집: José-Luis 2016년 12월 16일
From the documentation:
" exist name returns the type of name as a number. This list describes the type associated with each value:
0 — name does not exist."
Could you copy the file in your current folder and try again?

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2016년 12월 16일
편집: Jan 2016년 12월 17일
Windows is not case-sensitive for file names. Matlab states clearly, that the file "E:\GT\image0016.JPG" does not exist. Therefore your opinion that this file is existing must be wrong. Therefore this error can be solved only by providing the correct file name.
[EDITED] Please post the output of:
FileList = dir('Proposed\*.jpg');
for k = 1:numel(FileList)
NameC = FileList(k).name;
NameD = uint16(NameC);
fprintf('\n%s:\n', NameC);
fprintf('%d ', NameD);
end
  댓글 수: 7
Walter Roberson
Walter Roberson 2016년 12월 17일
"Windows is not case-sensitive for teh file names"
That is not entirely correct. In MS Windows, whether a file name component is case-sensitive or not depends on both the API used to access it and on the file system it is on. See http://superuser.com/questions/266110/how-do-you-make-windows-7-fully-case-sensitive-with-respect-to-the-filesystem
Jan
Jan 2016년 12월 17일
편집: Jan 2016년 12월 17일
@Walter: You are right: After setting a registry flag you can consider the case on NFS network drives or with CgyWin commands, when the drive is mounted with the POSIX flag, as far as I understand the discussion. I hope the OP does tell us, if something like this happens. :-)
@Nataliya: See [EDITED] to detect hidden characters in the file names.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2016년 12월 17일
The .name you get back from dir() does not include the directory. You need to fullfile() the directory information into place before you can open the file.
  댓글 수: 1
Image Analyst
Image Analyst 2016년 12월 17일
She was. She said:
"This is the complete code:
smapName = files(k).name;
smapImg = imread(fullfile(SMAP, smapName));
gtName = strrep(smapName, smapSuffix, gtSuffix);
gtImg = imread(fullfile(GT, gtName));

댓글을 달려면 로그인하십시오.


Holly Pothier
Holly Pothier 2018년 4월 16일

Hello, I am getting the same error. However, when I check with the recommended 'exist', the output is 2. Which, according to the documentation, means: "2 — name is a file with extension .m, .mlx, or .mlapp, or name is the name of a file with a non-registered file extension (.mat, .fig, .txt)." How can I move forward?

I am confused imread is in a loop, and all the files are .jpg files. However, when I loop, some of the images result in the error. Here is the relevant portion of my code. Thank you.

display ('top'); %Get list of all files in the folder with the desired file name pattern filePattern = fullfile(myFolder, '*.jpg'); %find files that are .jpg jpegFiles = dir(filePattern); %dir = list all files that match .jpg (from filePattern)

if ~isdir(myFolder) errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder); uiwait(warndlg(errorMessage)); return; end

display ('before loop'); for k = 1:length(jpegFiles) %loop through all .jpg files display ('inside loop'); baseFileName = jpegFiles(k).name; %name of .jpgs (indexed individually (k)); Ex: SDC10705_RS.jpg fullFileName = fullfile(myFolder, baseFileName); %fullfile builds filename from parts = myfolder\baseFileName (full path of ^) fprintf(1, 'Now reading %s\n', fullFileName); imageArray = imread(fullFileName); %read specific FULLfilename from store of .jpg files %this should be the full

    %Rotate                                   
    display ('rotation');
    %raw= jpegFiles(k).name;
    I = imread(jpegFiles(k).name); %must have imread for next step to work (rotation of I)
    R = imrotate(I, 355, 'bicubic'); %put angle and type of rotation here. 'bicubic' works best/ least distortion                           
    imshow(R); %display image
    %drawnow; %force display to update immediately
    %Break up fileparts to allow saving with '_rotate' extension when looping through files
    [tmp_path, tmp_name, tmp_ext] = fileparts(fullFileName); %separating fullFileName, into path, name, and ext (.jpg) (pretty much opposite of fullfile)
                                                             %need to do this so .jpg is at the end
    fullFileName_rotate = [tmp_path, filesep, tmp_name, '_rotate',tmp_ext];
    imwrite(R, fullFileName_rotate); %new rotated image
                                     %saved as filename_rotate
  댓글 수: 1
Guillaume
Guillaume 2018년 4월 16일
Please start your own question rather than highjacking somebody's else. You can link to this question in your own question if you feel they are related.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by