Filter löschen
Filter löschen

Why i cannot get full database?

1 Ansicht (letzte 30 Tage)
RACHEL LYN JAHIRIN
RACHEL LYN JAHIRIN am 5 Jun. 2023
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!

Antworten (1)

Image Analyst
Image Analyst am 5 Jun. 2023
Bearbeitet: Image Analyst am 5 Jun. 2023
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.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by