clc
%addpath(genpath('./conv_pyr'));
addpath(genpath('./utils'));
addpath(genpath('./images'));
all_names={'church','comparison_color_me_right','eye','eye_on_me','fish','girl','house','lionsavana','mixed_background','plane','portrait','ship','trolls'};
current_composition = 1;


%%
folder = ['images/' all_names{current_composition}];
src = im2double(imread(strcat(folder,'/source.jpg')));
trg = im2double(imread(strcat(folder,'/target.jpg')));
alpha = im2double(imread(strcat(folder,'/alpha.jpg')));
alpha = alpha(:,:,1);
if exist(strcat(folder,'/mask.jpg'))
    mask = im2double(imread(strcat(folder,'/mask.jpg')));
    mask = logical(mask(:,:,1));
else
    mask = imdilate(logical(alpha),strel('disk',1));    
end
[res_poisson,membrane] = ConvolutionPyramid(src, trg, mask);

w = [0.8 0.8 0.8];
res_w = ColorCorrection_dominant_color(src, trg, mask, alpha, membrane,w);
figure;imshow(res_w);title(strcat('Using same W:  ',num2str(w(1))))

w_new = [0.9 0.6 0.6];
res_different_w = ColorCorrection_dominant_color(src, trg, mask, alpha, membrane,w_new);
figure;imshow(res_different_w);title(strcat('Using W:  ',mat2str(w_new)))
