Reply by Firman Isnandi February 11, 20112011-02-11
I want to find the mean value of each image are located in 2 different classes.
each class there are 100 images had the extension ". PGM" eg pedestrian class:
confident (1). PGM, confident (2). PGM, confident (3). PGM ... pede (100). PGM
nonpedestrian class : nonpede (1). PGM, nonpede (2). PGM, nonpede (3). PGM ...
nonpede (100). PGM question: why the results of the mean at all? whether there
are any of my code? whereas if the mean value one by one looking for different
results. Please corrected ....

main.m

pedestrian = createdatabase ('pedestrian\');
[mp] = pca(pedestrian);
createdatabase.m

function data = CreateDatabase(X)
fileFolder = fullfile('',X);
dirOutput = dir(fullfile(fileFolder,'*.pgm'))
fileNames = {dirOutput.name}';
fileNum = numel(fileNames);
%mengubah image input dari 2 dimensi menjadi matriks
graymatrix = [];
for i = 1 : fileNum
str = strcat(fileFolder,fileNames{i});
img = imread(str);
[icol irow] = size(img);
temping = reshape(img',icol*irow,1);
graymatrix = [graymatrix temping];
end
%mengubah uint8 ke double
data = [];
for i = 1 : fileNum
temp = double(graymatrix(:,1));
data = [data temp];
end
pca.m

function[m] = pca(data)
%1.menghitung mean
m = mean(data,2);