function [ R ] = deconv_tuberlin( B, h )
% Reference: http://www.ndt.net/article/wcndt00/papers/idn230/idn230.htm

n = length(h);
N = size(B,2);
M = N + n - 1;
H = zeros(N,M);
for i=1:N
H(i,i:i+n-1) = h;
end
lambda = 1e6;
P = [eye(N,N) zeros(N,n-1)];

% Loop through all color channels
for i = 1:size(B,3)
    R(:,:,i) = B(:,:,i)*(lambda*H+P)*(inv(lambda*H'*H+P'*P))';
end

% Perform shift of image
for i = 1:size(B,3)
    R(:,:,i) = (circshift(R(:,:,i)',-fix(length(h)/2)))';
end

% Clip image to make it fit to the original dimensions
R = R(:,1:size(B,2),:);


