フィルターのクリア

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 Center および File ExchangeHistograms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by