- 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.
- Ensure that the image is not empty or corrupted. Check if you can open and view the image outside MATLAB.
- Verify that the file path in ‘namafile’, for every iteration, is correct and that the file exists at that location.
- Ensure that MATLAB has read access to the file and directory.
Error in imread function
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
T.Nikhil kumar
el 16 de Abr. de 2024
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:
Refer to the following documentation to understand more about the formats allowed by 'imread' -
I hope this helps.
0 comentarios
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!