天天看點

【圖像處理】全變差圖像處理【Matlab 457期】

一、數字圖像處理簡介

圖像處理基礎教程連結

1 【基礎教程】基于matlab圖像處理(表示方法+資料結構+基本格式+類型轉換+讀取+點運算+代數運算)【含Matlab源碼 834期】

2 【基礎教程】基于matlab圖像處理(讀寫+顯示+運算+轉換+變換+增強+濾波+分析+統計)【含Matlab源碼 144期】

3 【基礎教程】基于matlab圖像增強+複原+分割【含Matlab源碼 056期】

二、部分源代碼

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.

           

三、運作結果

【圖像處理】全變差圖像處理【Matlab 457期】

四、matlab版本及參考文獻

1 matlab版本

2014a

2 參考文獻

[1] 蔡利梅.MATLAB圖像處理——理論、算法與執行個體分析[M].清華大學出版社,2020.

[2]楊丹,趙海濱,龍哲.MATLAB圖像處理執行個體詳解[M].清華大學出版社,2013.

[3]周品.MATLAB圖像處理與圖形使用者界面設計[M].清華大學出版社,2013.

[4]劉成龍.精通MATLAB圖像處理[M].清華大學出版社,2015.

[5]陳浩,方勇,朱大洲,王成,陳子龍.基于蟻群算法的玉米植株熱紅外圖像邊緣檢測[J].農機化研究. 2015,37(06)

繼續閱讀