필터 지우기
필터 지우기

Error in imread function

조회 수: 8 (최근 30일)
Dewandra
Dewandra 2022년 11월 30일
답변: T.Nikhil kumar 2024년 4월 16일
I am receiving this error when trying to read images into my script
Error using imread>get_format_info (line 544)
Unable to determine the file format.
Error in imread/call_format_specific_reader (line 460)
fmt_s = get_format_info(fullname);
Error in imread (line 434)
[X, map] = call_format_specific_reader();
Error in test1 (line 9)
img = imread(namafile);
Why is this happening and how can I fix it?
My code is
clc
clear
close all
datafolder = fullfile('C:\GambarM');
imds = imageDatastore(datafolder, 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
for i = 1: length(imds.Files)
namafile = imds.Files{i, 1};
img = imread(namafile);
%image processing
H = fspecial ('motion',20,45);
imgMotionBlur = imfilter(img, H, 'replicate');
%ekstraksi fitur berrbasis histogram
N(i,:) = histcounts(imgMotionBlur,256);
end

답변 (1개)

T.Nikhil kumar
T.Nikhil kumar 2024년 4월 16일
Hello Dewandra,
I understand that you are facing an error with the ‘imread’ function.
I tried running your code with a folder of sample images and it ran without errors for me. This could mean that the issue lies with the images or their paths and not with your code. I would suggest you to try the following methods to resolve this error:
  1. Ensure the file format of all the images is supported by ‘imread’ (e.g., JPG, PNG, BMP, GIF). If the file is in a format not supported by imread, you can convert it to a supported format using an external tool.
  2. Ensure that the image is not empty or corrupted. Check if you can open and view the image outside MATLAB.
  3. Verify that the file path in ‘namafile’, for every iteration, is correct and that the file exists at that location.
  4. Ensure that MATLAB has read access to the file and directory.
Refer to the following documentation to understand more about the formats allowed by 'imread' -
I hope this helps.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by