필터 지우기
필터 지우기

Why i cannot get full database?

조회 수: 1 (최근 30일)
RACHEL LYN JAHIRIN
RACHEL LYN JAHIRIN 2023년 6월 5일
댓글: 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.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by