how can i get matlab coding for wls filter

Example
% -------
% RGB = imread('peppers.png');
% I = double(rgb2gray(RGB));
% I = I./max(I(:));
% res = wlsFilter(I, 0.5);
% figure, imshow(I), figure, imshow(res)
% res = wlsFilter(I, 2, 2);
% figure, imshow(res)
if(~exist('L', 'var')), L = log(IN+eps); end
if(~exist('alpha', 'var')), alpha = 1.2; end
if(~exist('lambda', 'var')), lambda = 1; end
smallNum = 0.0001;
[r,c] = size(IN); k = r*c;
% Compute affinities between adjacent pixels based on gradients of L dy = diff(L, 1, 1); dy = -lambda./(abs(dy).^alpha + smallNum); dy = padarray(dy, [1 0], 'post'); dy = dy(:);
dx = diff(L, 1, 2); dx = -lambda./(abs(dx).^alpha + smallNum); dx = padarray(dx, [0 1], 'post'); dx = dx(:);
% Construct a five-point spatially inhomogeneous Laplacian matrix B(:,1) = dx; B(:,2) = dy; d = [-r,-1]; A = spdiags(B,d,k,k);
e = dx; w = padarray(dx, r, 'pre'); w = w(1:end-r); s = dy; n = padarray(dy, 1, 'pre'); n = n(1:end-1);
D = 1-(e+w+s+n); A = A + A' + spdiags(D, 0, k, k);
% Solve OUT = A\IN(:); OUT = reshape(OUT, r, c);

1 commentaire

Royi Avital
Royi Avital le 14 Avr 2018
Do you mean the Weighted Least Squares filter for Image Processing?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange

Tags

Question posée :

le 14 Oct 2017

Commenté :

le 14 Avr 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by