Created
June 9, 2016 22:48
-
-
Save mustafa-qamaruddin/a87f3215fb5ca7194f5476f71275e118 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [] = mqPCA() | |
global LOW_RES_INPUT_TEST_IMAGE; | |
global VISUALS; | |
dbl_lowres = double(LOW_RES_INPUT_TEST_IMAGE); | |
width = size(LOW_RES_INPUT_TEST_IMAGE,1); | |
height = size(LOW_RES_INPUT_TEST_IMAGE,2); | |
rshp_lowres = reshape(LOW_RES_INPUT_TEST_IMAGE, width*height, 3); | |
%% figure, imshow(rshp_lowres); | |
coeff = pca(double(rshp_lowres)); | |
%%#################################################### | |
lowres_dir_path = uigetdir; | |
%addpath(lowres_dir_path); | |
image_files = dir(strcat(lowres_dir_path, '\*.jpg')); | |
num_files = length(image_files); | |
table_of_features = cell(num_files); | |
table_of_names = cell(num_files); | |
for i = 1 : num_files | |
%% check isDir | |
file_name = image_files(i).name; | |
full_image_path = strcat(lowres_dir_path ,'\', file_name); | |
training_image = imread(full_image_path); | |
training_image = double(training_image); | |
training_width = size(training_image, 1); | |
training_height = size(training_image, 2); | |
reshaped_training_image = reshape(training_image, training_width * training_height, 3); | |
reduced_image = reshaped_training_image * coeff; | |
if(VISUALS == true) | |
image_to_be_displayed = reshape(reduced_image, training_width, training_height, 3); | |
imshow(image_to_be_displayed); | |
pause | |
end | |
table_of_features{i} = reduced_image; | |
table_of_names{i} = full_image_path; | |
end | |
save 'table_of_features.mat' table_of_features; | |
save 'table_of_names.mat' table_of_names; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment