function result = ColorCorrection( source, target, mask, alpha, membrane, w)
%COLORCORRECTION Summary of this function goes here
%   Detailed explanation goes here

result = zeros(size(target));

start = start_timer('Starting Color Correction... ');

for i=1:3
    tar = target(:,:,i);
    temp = (1 - w * alpha) .* membrane(:,:,i) + source(:,:,i);
    tar(mask) = temp(mask);
    result(:,:,i) = tar;
end

end_timer(start);

end

function t = start_timer(msg)
	fprintf(1, msg); t = tic;
end

function end_timer(timer)
	t = toc(timer); fprintf(1, '%.8f sec\n', t);
end
