I am currently working on a project of flower identification by using RGB color extraction, but I get some errors when I want to read the image files. It said :
Error using imread>get_full_filename (line 516)
File "Image_Folder\Image_Files(n).name" does not exist.
Error in imread (line 340)
fullname = get_full_filename(filename);
Error in Latih (line 8)
Img = imread(fullname);
How can I solve this? Here is my code:
Image_Folder = 'D:\TUGAS KULIAH\PEMODELAN KECERDASAN BUATAN\Tugas Pengganti UAS\Data Latih';
Image_Files = fullfile(Image_Folder,'*.jpeg');
Total_Images = numel(Image_Files);
Training_Data = zeros(3,Total_Images);
for n = 1:Total_Images
fullname= fullfile('Image_Folder', 'Image_Files(n).name');
Img = imread(fullname);
Img = im2double(Img);
% RGB Color Extraction
R = Img(:,:,1);
G = Img(:,:,2);
B = Img(:,:,3);
CharR = mean2(R);
CharG = mean2(G);
CharB = mean2(B);
Training_Data(1,n) = CharR;
Training_Data(2,n) = CharG;
Training_Data(3,n) = CharB;
end

 채택된 답변

Walter Roberson
Walter Roberson 2019년 5월 18일

1 개 추천

Image_Files = dir( fullfile(Image_Folder,'*.jpeg') );
and
fullname= fullfile(Image_Folder, Image_Files(n).name);

댓글 수: 3

Qvna Lhyvnav
Qvna Lhyvnav 2019년 5월 18일
Thank you. I already edited the code, but Image_Files, n, Total_Images, and Training_Data have no value while with the old code they had it. How to show the value?
In your previous code, Image_Files would have held
'D:\TUGAS KULIAH\PEMODELAN KECERDASAN BUATAN\Tugas Pengganti UAS\Data Latih\*.jpeg'
not a list of files in the folder. numel() of it would be the number of characters in the vector. It would not have a .name field to use with fullfile()
If you are finding that Image_files is empty and Total_images is 0 and n is coming out empty, then the reason for that is that you have no files whose name end with .jpeg inside a folder named D:\TUGAS KULIAH\PEMODELAN KECERDASAN BUATAN\Tugas Pengganti UAS\Data Latih . That could happen if you have a mistake in the name. It could also happen in the situation where the JPEG files are named with .jpg instead of .jpeg .
Qvna Lhyvnav
Qvna Lhyvnav 2019년 5월 18일
I understand now. I wrote the .jpeg instead of .jpg and it works. Thank you so much for your help!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품

릴리스

R2017a

질문:

2019년 5월 18일

댓글:

2019년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by