function compareimages(A,ATitle,B,BTitle) %COMPAREIMAGES Displays two images side by side with linked axes % COMPAREIMAGES(A,B) displays images A and B, where A and B are either % grayscale or RGB color images with values in [0,1]. The images are % displayed with linked axes for convenient panning and zooming. % % COMPAREIMAGES(A,'A title',B,'B title') specifies titles above the % images. % % See also linkaxes. % Pascal Getreuer 2009 if nargin == 2 B = ATitle; ATitle = ''; BTitle = ''; elseif nargin < 4 error('Must have 2 or 4 input arguments.'); end ax(1) = subplot(1,2,1); hold off if ndims(A) == 2 image(A*255); colormap(gray(256)); elseif ndims(A) == 3 image(min(max(A,0),1)); end set(gca,'Units','Normalized','Position',[0,0.1,0.5,0.8]); axis image axis off title(ATitle); zoom; ax(2) = subplot(1,2,2); hold off if ndims(B) == 2 image(B*255); colormap(gray(256)); elseif ndims(B) == 3 image(min(max(B,0),1)); end set(gca,'Units','Normalized','Position',[0.5,0.1,0.5,0.8]); axis image axis off title(BTitle); %%% Demo of image deconvolution %%% BlurRadius = 3; NoiseLevel = 0.005; lambda = 4e3; uexact = double(imread('einstein.png'))/255; % Construct the blur filter [x,y] = meshgrid(1:size(uexact,2),1:size(uexact,1)); psf = double((x-size(uexact,2)/2).^2 ... + (y-size(uexact,1)/2).^2 <= BlurRadius^2); psf = psf/sum(psf(:)); % Simulate a noisy and blurry image f = real(ifft2(fft2(uexact).*fft2(fftshift(psf)))); f = f + randn(size(uexact))*NoiseLevel; % Deblur u = tvdeconv(f,lambda,psf);unction u = tvdenoise(f,lambda,varargin) %TVDENOISE Total variation image denoising. % u = TVDENOISE(f,lambda,model) denoises grayscale, color, or arbitrary % multichannel image f using total variation regularization. Parameter % lambda controls the strength of the noise reduction: smaller lambda % implies stronger denoising. % % The model parameter specifies the noise model (case insensitive): % 'Gaussian' or 'L2' - (default) The degradation model for additive % white Gaussian noise (AWGN), % f = (exact) + (Gaussian noise). % 'Laplacian' or 'L1' - The degradation model assumes impulsive noise, % for example, salt & pepper noise. % 'Poisson' - Each pixel is an independent Poisson random % variable with mean equal to the exact value. % % TVDENOISE(...,Tol,MaxIter) specify the stopping tolerance and the % maximum number of iterations. % % See also tvdeconv, tvinpaint, and tvrestore.
版本:2014a
完整代码或代写加QQ1564658423