FAQ |
Calendar |
![]() |
|
Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman. |
![]() |
|
Thread Tools |
#1
|
|||
|
|||
![]()
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 ![]() 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); Terkait:
|
![]() |
|
|