22 lines
458 B
Matlab
22 lines
458 B
Matlab
function u_kp1 = inpainting(u0, u_k, u_d, lambda, Dx, Dy, epsilon)
|
|
|
|
N = length(u0);
|
|
u_kp1 = zeros(size(u_k));
|
|
|
|
for i=1:size(u0, 3)
|
|
|
|
coeffs = 1 ./ sqrt( (Dx * u_k(:,:,i)).^2 + (Dy * u_k(:,:,i)).^2 + epsilon );
|
|
|
|
W = spdiags(coeffs, 0, N, N);
|
|
W_od = spdiags(1 - u_d, 0, N, N);
|
|
|
|
A = W_od + lambda * (Dx' * W * Dx + Dy' * W * Dy);
|
|
b = W_od * u0(:,:,i);
|
|
|
|
u_kp1(:,:,i) = A \ b;
|
|
|
|
end
|
|
|
|
end
|
|
|