Face Hallucination

Face Reconstruction Step for Face Hallucination

2016-04-02-013615_1366x768_scrotface reconstruction
face hallucination after 150 iterations

function [ hallucinated_image ] = mqReconstruct( interpolated_image, coeffiecients_weights, k_images )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

im_path = 'C:\Users\Qamar-ud-Din\Documents\MATLAB\SplitFrame_479.bmp';

testim = imread(im_path);

%% low resolution %%
lowresim = imresize(testim, 0.125);
figure, imshow(lowresim), title('low resolution');

interpolated_image = imresize(lowresim, [128 128], 'method', 'cubic');
figure, imshow(interpolated_image), title('interpolated low resolution');

%% to be calculated from low resolution input image and target high resolution %%
global DOWNSAMPLING_FACTOR;
DOWNSAMPLING_FACTOR = 128 / 16;
global SCALEFACTOR;
SCALEFACTOR = 0.05;
global NUMBERITERATIONS;
NUMBERITERATIONS = 150;
global PATCH_SIZE;
PATCH_SIZE = 7;

%% scale factor $$
g = 0.05;

%% LOAD COEFFICIENTS WEIGHTS %%
w = struct2cell(load('coefficients_omega_for_all_patches.mat'));
w = w{1};

%% PADDING $$
offset=floor(PATCH_SIZE/2);
interpolated_image = padarray(interpolated_image, [offset offset]);
        
%% LOOP T ITERATIONS %%
    for t = 1 : 300
        counter = 1;
        %% loop rows
        fin_row = size(interpolated_image, 2) - offset;
        for c = offset+1 : fin_row
            %% loop cols
            fin_col = size(interpolated_image, 1) - offset;
            for r = offset+1 : fin_col
                I0 = interpolated_image(r, c);
                patch = interpolated_image([r-offset:r+offset], [c-offset:c+offset]);
                patch = mqExtractNeighborhoodFromSinglePatch(patch, PATCH_SIZE);
                weights = cell2mat(w(counter));
                DELTA_T = double(I0) - dot(weights, double(patch));
                if DELTA_T ~= 0
                    DELTA_T;
                end
                I = I0 - g * DELTA_T;
                I - I0
                %%%% cutoff here
                if I < 0 
                    I = 0
                elseif I > 255
                    I = 255
                end
                interpolated_image(r,c) = I;
                counter = counter + 1;
            end
        end
    end
        the_title = sprintf('Hallucinated Image @iteration:=%d', 300);
        hold on
        figure, imshow(interpolated_image), title(the_title);
        hold off
    figure, imshow(testim), title('Ground Truth');
end

 

reconstruction after iterations

number of iterations for reconstruction

300 iterations for face reconstructions

warped input image

MSE & PSNR vs #Iterations

mse & psnr vs #iterations

2016-04-15-143244_1366x768_scrot
mse & psnr vs #iterations

References:

  1. https://github.com/thecortex/Face-Hallucination-using-Sparse-Local-Pixel-Structures
Advertisements

One thought on “Face Reconstruction Step for Face Hallucination

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s