Why i cannot get full database?

1 回表示 (過去 30 日間)
RACHEL LYN JAHIRIN
RACHEL LYN JAHIRIN 2023 年 6 月 5 日
hi matlab community, ask shown in figure below, the matlab database did not show full database . it just shown []. Can someone help me? this is for my FYP. Can see coding attach. I really appreciate your help!

回答 (1 件)

Image Analyst
Image Analyst 2023 年 6 月 5 日
編集済み: Image Analyst 2023 年 6 月 5 日
Maybe it's due to you looking for the wrong extension in the folder. For example, maybe this:
addpath('C:\Users\User\Desktop\LIVE database\databaserelease2\jpeg');
for i=1:233
A=imread(sprintf('img%d.bmp',i));
A1=rgb2gray(A);
A2=double(A1);
FYPdatabase{575+i,1}=A2;
FYPdatabase{i,3}=1;
end
should really be this:
folder = 'C:\Users\User\Desktop\LIVE database\databaserelease2\jpeg';
filePattern = fullfile(folder, '*.jpeg')
fileList = dir(filePattern)
for k = 1 : numel(fileList) % For however many files are there...
% Get the full filename.
fullFileName = fullfile(fileList(k).folder, fileList(k).name);
fprintf('Adding %s\n', fullFileName)
% Read in original image.
rgbImage = imread(fullFileName);
% Convert from color to grayscale if necessary.
if size(rgbImage, 3) == 3
% It's color. Need to convert to gray scale.
grayImage = rgb2gray(rgbImage);
else
grayImage = rgbImage; % It's already grayscale.
end
grayImage = double(grayImage);
% Add it to the cell array.
% 575 should be a variable that adjusts according to how many
% images there were in the prior loops!!!
FYPdatabase{575 + k, 1} = grayImage;
FYPdatabase{k, 2} = []; % 2 is unassigned for some reason???
FYPdatabase{k, 3} = 1;
end
This is more robust than what you have. Make similar adjustments for the other loops that handle other image file extensions.
  1 件のコメント
RACHEL LYN JAHIRIN
RACHEL LYN JAHIRIN 2023 年 6 月 5 日
thnks. but still didnt get

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by