Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
JagoVB JagoVB is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 508
Rep Power: 14
JagoVB mempunyai hidup yang Normal
Default Tanya Matlab [code inside]

Juragan yang pinter dan ganteng2, tanya matlab nih, ane kan mau mencari nilai mean dari masing-masing citra yang berada dalam 2 kelas berbeda. masing2 kelas ada 100 citra ber-ekstensi ".pgm"

misal:


kelas pedestrian: pede (1).pgm, pede (2).pgm, pede (3).pgm ...pede (100).pgm

kelas nonpedestrian: nonpede (1).pgm, nonpede (2).pgm, nonpede (3).pgm ...nonpede (100).pgm



nah pertanyaan ane kok hasil meannya sama smua yah apa ada yang salah dari codingan ane gan?? padahal kalo dicari nilai mean nya satu persatu hasilnya berbeda gan. mohon dikoreksi dong..




Spoiler for utama.m:





Code:

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












Spoiler for createdatabase.m:





Code:

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












Spoiler for pca.m:





Code:

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











Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 04:15 PM.


no new posts