));Р% msk = ones(size(img));Р% msk(1,:,:) = 0;Р% msk(:,1,:) = 0;Р% msk(size(img,1),:,:) = 0;Р% msk(:,size(img,2),:) = 0;Р% [Fh Fv] = imgrad(X);Р% Fh = Fh * 2;Р% Y = PoissonJacobi(X, Fh, Fv, msk);Р%Р%Рfunction dst = PoissonJacobi(src, Fh, Fv, msk, itr, th, verbose)Рif( nargin < 5 )Рitr = 1024;РendРif( nargin < 6 )Рth = 1E-3;РendРif( nargin < 7 )Рverbose = false;РendРK=[0,1,0;1,0,1;0,1,0];Рp = ( msk > 0 );Рlap = grad2lap(Fh,Fv);Рdf0 = 1E32;Рdst = src;Рdst0 = dst;Рfor i = 1:itrРlpf = imfilter(dst,K,'replicate');Рdst(p) = (lap(p) + lpf(p))/4;Рdif = abs(dst-dst0);Рdf = max(dif(:));Рif( verbose )Рfprintf('%d %g %g\n',i, df, (df0 - df)/df0);РendРif( (df0 - df)/df0 < th )Рbreak;РendРdst0 = dst;Рdf0 = df;РendРfunction lap = grad2lap(Fh, Fv)Рlap = circshift(Fh,[0,1]) + circshift(Fv,[1,0]) - Fh - Fv;