Apply PCA to low resolution input image
im_path = 'SplitFrame_000.bmp'; lowres = imread(im_path); dbl_lowres = double(lowres); width = size(lowres,1); height = size(lowres,2); rshp_lowres = reshape(lowres, width*height, 3); %% figure, imshow(rshp_lowres); coeff = pca(double(rshp_lowres));
Multiply each low resolution training image by the coefficient matrix. The inner product is interpreted as projecting the training set into the coordinate space that provides maximum between class variance.
lowres_dir_path = uigetdir; %addpath(lowres_dir_path); image_files = dir(strcat(lowres_dir_path, '\*.bmp')); num_files = length(image_files); table_of_features = ; for i = 1 : num_files %% check isDir file_name = image_files(i).name; training_image = imread(strcat(lowres_dir_path ,'\', file_name)); training_image = double(training_image); training_width = size(training_image, 1); training_height = size(training_image, 2); reshaped_training_image = reshape(training_image, width * height, 3); reduced_image = reshaped_training_image * coeff; table_of_features = [table_of_features; transpose(reduced_image)]; end
Finally save the results for KNN processing
save features.dat table_of_features -ascii -double;