A brief introduction of wavelet transform image analysis

The 21st century is the information age, image has become an important carrier of information for human beings, playing an increasingly important role in human daily life, the status is getting higher and higher, for example, online browsing, downloading images and videos, hospital diagnosis of diseases according to MRI (nuclear magnetic resonance image). However, in the process of image generation and transmission, it will be interfered by facilities, environment and other factors, resulting in the destruction or loss of image information [1,2]. Noise is the factor that prevents human vision or system sensors from understanding the received source information. In the process of image acquisition and transmission, it is often polluted by various noises. The generation of noise will greatly reduce the resolution of the original image, so that the original image becomes blurred and difficult to use in daily life or research, and seriously affect the subsequent series of advanced digital image processing.

Therefore, how to eliminate the noise in the process of image acquisition and transmission becomes very important. However, the traditional image denoising methods are not satisfactory in reducing noise and preserving image details. Wavelet transform can analyze signals in high frequency band with low frequency resolution and in different space. Digital signal processing based on wavelet theory has been developed vigorously and provides a new powerful signal processing method. Of course, wavelet transform is used in image noise reduction.

1 research significance and development processImage denoising based on wavelet transform is mainly done by wavelet threshold processing in wavelet domain. Wavelet domain image denoising processing can be considered as the best estimation of the input image using threshold noise data. Its structure is shown in Figure 1.The development process of the application of wavelet theory in image denoising can be roughly divided into three stages: In the first stage, Mallat proposed a very famous denoising method based on modulus maxima of wavelet system. In the second stage, Donoho and Johnstone of Stanford University proposed a series of wavelet threshold denoising methods based on theoretical research. In the third stage, with the development of various models, the main feature of this stage is denoising the correlation within and between layers through multi-scale statistical modeling of image wavelet coefficients according to image wavelet coefficients.Figure 2. Gray scale of AFIG. 2.b diagram of first order discrete wavelet transformThe image is a two-dimensional function f(x,y), where X and y are plane coordinates, and the amplitude in any pair of coordinates (x,y) is called gray level or intensity of the graph at that time. There are two types of images, namely grey scaled images and RGB images. Images are often destroyed by noise during acquisition and transmission. Various noise reduction techniques are used to eliminate noise. Most use standard algorithms to denoise images and perform individual filtering processes. Denoising usually reduces noise levels but is lost due to blurred images or excessive smoothing of edges or lines. In recent years, there has been a lot of research on wavelet threshold and the threshold part of image denoising, because wavelet provides an appropriate basic image signal for separating noise signals. Wavelet transform is good at energy compaction, small coefficients are more likely to be noise and large coefficients due to important signal characteristics. These small coefficients can affect the important features of the image by threshold processing without thresholds.

2. Technical experiment and analysisWavelet transform (WT) is a powerful tool for signal analysis in dealing with multi-resolution scenarios. Unlike Fourier transform, WT is suitable for applying non-stationary signal phenomena with transients, where the frequency response varies with time. The wavelet coefficient represents the frequency component function between the measurement signal of similarity and the selected wavelet. These coefficients are computed as the convolution of the signal and the scaling wavelet function, which can be interpreted as an expanded bandpass filter because of its bandpass sample spectrum. The global information extracted from a high scale signal by wavelet analysis is called approximation, and the refined information extracted from both scales is called detailed information.Figure 5. C wavelet threshold denoising image

Discrete wavelet transforms (DWT) require less space using space-saving encoded wavelets that are orthogonal or biorthogonal bases, and thus do not generate redundant analysis. The discrete wavelet transform corresponding to its continuous version is usually sampled on a binary grid. Thresholding is a simple nonlinear technique to calculate one wavelet coefficient at a time. In its most basic form, each coefficient is compared to a threshold. If the coefficient is less than the threshold then set it to zero, otherwise retain or modify.

Continuous wavelet in the treatment of the object will cause theory of coefficient of redundancy, in the practical application in the removal of interfering signal at the same time we need to keep original signal low redundancy, because of the discrete wavelet transform and continuous wavelet transform operation more convenient, and in the actual signal processing are discrete information stored on the computer. Therefore, the size parameters and displacement parameters need to be discretely processed to transform the original continuous translational stretching component [7].

The Lena graph is discretized as shown in FIG. 2. A is gray scale image, B is primary discrete wavelet transform image, and C is primary inverse discrete wavelet transform image.

Figure 3.A is a grayscale image, Figure 3.b is a two-time discrete wavelet transform image, and Figure 3.c is a quadratic inverse discrete wavelet transform image.

Using wavelet transform to denoise the image is to decompose the noisy wavelet coefficient, and then calculate the infinitely close wavelet coefficient value from the pure image, and the noise image is processed by wavelet coefficient decomposition. The wavelet coefficient consists of two parts: pure wavelet coefficient and noise wavelet coefficient. The sum of the coefficients of the two parts is the wavelet coefficient of the decomposition of the noisy image, and the processing of the noisy image with the threshold value is the wavelet coefficient after the threshold value, also known as the threshold function. In this way, the noise can be processed to the maximum extent and the image reconstructed using wavelet coefficients can be more pure. The algorithm flow chart is shown in Figure 4.Figure 5. A is a grayscale image, Figure 5. B is an image with Gaussian noise, and Figure 5. The original gray image, the image with gaussian noise and the image after noise reduction are compared, the noise reduction effect is obvious.

Threshold function plays a role in image denoising in wavelet transform is coefficient selection. It processes high-frequency wavelet coefficients through threshold value and adds threshold function expression in thresholding. In the wavelet thresholding denoising method, the determination of threshold determines the image quality after denoising, which has a great influence on the effect of noise removal. The soft threshold function is selected in this experiment, and its mathematical expression is as follows.Where, y is the wavelet change coefficient of noisy signal; T is denoising threshold; Tsoft is the contraction function of soft threshold filtering; Signum of y is a sign function.

The soft threshold filter shrinks and retains the wavelet coefficients whose amplitude is greater than the threshold. The advantage of the soft threshold contraction function is good continuity.

Wavelet denoising also includes modulus maximum reconstruction filtering method. The advantage is that it does not estimate the variance of noise in advance like the wavelet threshold denoising, but it needs to use the modulus maximum to reconstruct the wavelet coefficient, which leads to a great increase in the amount of calculation. Moreover, the noise reduction effect of this method is not good, so its use is limited.

There is also spatial filtering method, which uses the correlation between wavelet coefficient scales to denoise. Although the principle is simple, many iterations are needed in the operation process, which greatly increases the amount of calculation and cannot be widely used in image denoising.

Two, some source code

function varargout = wavelet(varargin)
% WAVELET MATLAB code for wavelet.fig
%      WAVELET, by itself, creates a new WAVELET or raises the existing
%      singleton*.
%
%      H = WAVELET returns the handle to a new WAVELET or the handle to
%      the existing singleton*.
%
%      WAVELET('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in WAVELET.M with the given input arguments.
%
%      WAVELET('Property'.'Value',...). creates anew WAVELET or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before wavelet_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to wavelet_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one % instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help wavelet

% Last Modified by GUIDE v2. 5 10-Jan- 2021. 05:42:48

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @wavelet_OpeningFcn, ...
                   'gui_OutputFcn',  @wavelet_OutputFcn, ...
                   'gui_LayoutFcn', [],...'gui_Callback'[]);if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before wavelet is made visible.
function wavelet_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to wavelet (see VARARGIN)

% Choose default command line output for wavelet
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes wavelet wait for user response (see UIRESUME)
% uiwait(handles.figure_wavelet);
setappdata(handles.figure_wavelet,'img_src'.0% initialize variables to window frames setAppData (handles. Figure_wavelet,'WAVELET_NAME'.0);
setappdata(handles.figure_wavelet,'Filter_style'.0);
setappdata(handles.figure_wavelet,'Image_R'.0);

% --- Outputs from this function are returned to the command line.
function varargout = wavelet_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output; % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % %, import the pictures %**********************************************************************% % --- Executes on button press in Import_image.function Import_image_Callback(hObject, eventdata, handles)
% hObject    handle to Import_image (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile( ...
    {'*.bmp; *,jpg; *.png; *.jpeg; *.tif'.'Image File(*.bmp,*.jpg,*.png,*jpeg,*.tif)'; .'*. *'.'All File(*.*)'},...
    'Pick an image'); axes(handles.axes_original); % axes set axes to axes_src fpath = [pathname filename]; % combine filename and directory name into a complete path img_src = imread(fpath); % load image imshow(img_src); % Use imread to read images and use imshow to display setAppData (handles. Figure_wavelet,'img_src',img_src);

% --- Executes on button press in analyze_image.
function analyze_image_Callback(hObject, eventdata, handles)
% hObject    handle to analyze_image (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%Main

img_src = getappdata(handles.figure_wavelet,'img_src');
%[ X,map] = rgb2ind( img_src, 256); % convert RGB graph to index image to get color matrixmap
%save '00' X map; load 00;
%colormap( map); HANDDLE_IMAGE = img_src; %image(HANDDLE_IMAGE); % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % % 2, and the choice of wavelet base wave, Calculate the correlation filtering function % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % WAVELET_NAME = getappdata(handles.figure_wavelet,'WAVELET_NAME');
%WAVELET_NAME = 'sym8';
[Lo_D,Hi_D,Lo_R,Hi_R]=wfilters(WAVELET_NAME);
RowLo_DTemp = RanksSampling(RanksConv(HANDDLE_IMAGE,Lo_D,'r'),'c'.2); % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % % 3, decomposition %**********************************************************************% CA = RanksSampling(RanksConv(RowLo_DTemp,Lo_D,'c'),'r'.2);
RowLo_DTemp = RanksSampling(RanksConv(HANDDLE_IMAGE,Lo_D,'r'),'c'.2);
CA = RanksSampling(RanksConv(RowLo_DTemp,Lo_D,'c'),'r'.2);
CH = RanksSampling(RanksConv(RowLo_DTemp,Hi_D,'c'),'r'.2);
RowHi_DTemp = RanksSampling(RanksConv(HANDDLE_IMAGE,Hi_D,'r'),'c'.2);
CV = RanksSampling(RanksConv(RowHi_DTemp,Lo_D,'c'),'r'.2);
CD = RanksSampling(RanksConv(RowHi_DTemp,Hi_D,'c'),'r'.2); %[CA,CH,CV,CD] = dwt2(HANDDLE_IMAGE,WAVELET_NAME); axes(handles.axes_CA); image(CA); axes(handles.axes_CH); image(CH); axes(handles.axes_CV); image(CV); axes(handles.axes_CD); image(CD); % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % % 4 and denoising %**********************************************************************% Filter_style = getappdata(handles.figure_wavelet,'Filter_style');    
newCA =CA;
if(2 == Filter_style)

    [THR,SORH,KEEPAPP]=ddencmp('den'.'wv',CH); % Obtain the default threshold for denoising (soft or hard) newCH=wdencmp('gbl',CH,WAVELET_NAME,2,THR,SORH,KEEPAPP);
    [THR,SORH,KEEPAPP]=ddencmp('den'.'wv',CV); % Obtain the default threshold (soft or hard) in the denoising process newCV=wdencmp('gbl',CV,WAVELET_NAME,2,THR,SORH,KEEPAPP); % Global threshold for image denoising [THR,SORH,KEEPAPP]=ddencmp('den'.'wv',CD); % Get the default threshold for denoising (soft or hard) newCD=wdencmp('gbl',CD,WAVELET_NAME,2,THR,SORH,KEEPAPP); % Use the global threshold to denoise the imageend
if(3 == Filter_style)% Below is the image denoising thr_h with the independent threshold option= [96.245.97.411]; % Horizontal threshold thr_v=[99.321.94.122]; % Vertical threshold thr_d=[95.762.92.330]; % Diagonal threshold THR1 =[THR_h; THR_V; THR_D]; % 3d matrix, length N newCH=wdencmp('lvd',CH,WAVELET_NAME,2,thr1,'s'); % Select soft threshold newCV=wdencmp('lvd',CV,WAVELET_NAME,2,thr1,'s');
    newCD=wdencmp('lvd',CD,WAVELET_NAME,2,thr1,'s');
end
    
    
    axes(handles.axes_newCA); image(newCA); axes(handles.axes_newCH); image(newCH); axes(handles.axes_newCV); image(newCV); axes(handles.axes_newCD); image(newCD); % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % % 5, refactoring %**********************************************************************% CA_Temp = RanksInterpolation(newCA,'r'.2);
CH_Temp = RanksInterpolation(newCH,'r'.2);
CloumnTemp1 = RanksConv(CA_Temp,Lo_R,'c')+RanksConv(CH_Temp,Hi_R,'c');
CV_Temp = RanksInterpolation(newCV,'r'.2);
CD_Temp = RanksInterpolation(newCD,'r'.2);
CloumnTemp2 = RanksConv(CV_Temp,Lo_R,'c')+RanksConv(CD_Temp,Hi_R,'c');

CloumnTempA = RanksInterpolation(CloumnTemp1,'c'.2);
CloumnTempB = RanksInterpolation(CloumnTemp2,'c'.2);
RowTemp = RanksConv(CloumnTempA,Lo_R,'r')+RanksConv(CloumnTempB,Hi_R,'r');

Image_R =wkeep(RowTemp,size(HANDDLE_IMAGE),'c'); Axes (handles. Axes_worked); image (Image_R) setappdata(handles.figure_wavelet,'Image_R',Image_R); %HANDDLE_IMAGE = img_src; % To avoid misuse of X in subsequent programs, use custom variables to replace %image(HANDDLE_IMAGE); % imshow(X); % read the image with imread and display % WAVELET_NAME = on axes_src with imshow'sym8';
%[Lo_D,Hi_D,Lo_R,Hi_R]=wfilters(WAVELET_NAME);
%RowLo_DTemp = RanksSampling(RanksConv(HANDDLE_IMAGE,Lo_D,'r'),'c'.2);
%CA = RanksSampling(RanksConv(RowLo_DTemp,Lo_D,'c'),'r'.2);
%subplot(221); image(CA); colormap(map); title('Lo_D low-pass decomposition of image CA'Paint a picture of CA -- human selection change in popupmenu1.function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1





% --- Executes on selection change in wavelet_style.
function wavelet_style_Callback(hObject, eventdata, handles)
% hObject    handle to wavelet_style (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns wavelet_style contents as cell array
%        contents{get(hObject,'Value')} returns selected item from wavelet_style
WAVELET_NAME = 'haar';
val = get(handles.wavelet_style,'Value'); % gets the value of the drop-down boxswitchVal % selects waveletscase 1                         
        WAVELET_NAME = 'haar'
    case 2 
        WAVELET_NAME = 'db2';
    case 3 
        WAVELET_NAME = 'db4';
    case 4 
        WAVELET_NAME = 'db6';
    case 5 
        WAVELET_NAME = 'db8';
    case 6 
        WAVELET_NAME = 'db10';
    case 7 
        WAVELET_NAME = 'sym2';
    case 8 
        WAVELET_NAME = 'sym4';
    case 9 
        WAVELET_NAME = 'sym6';
    case 10 
        WAVELET_NAME = 'sym8';
    case 11 
        WAVELET_NAME = 'sym10';
    case 12 
        WAVELET_NAME = 'coif1';
    case 13 
        WAVELET_NAME = 'coif3';
    case 14 
        WAVELET_NAME = 'coif5';
    case 15 
        WAVELET_NAME = 'dmey'
    case 16 
        WAVELET_NAME = 'haar'
end
setappdata(handles.figure_wavelet,'WAVELET_NAME',WAVELET_NAME);

% --- Executes during object creation, after setting all properties.
function wavelet_style_CreateFcn(hObject, eventdata, handles)
% hObject    handle to wavelet_style (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end


% --- Executes on selection change in filter_style.
function filter_style_Callback(hObject, eventdata, handles)
% hObject    handle to filter_style (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns filter_style contents as cell array
%        contents{get(hObject,'Value')} returns selected item from filter_style
Filter_style  = get(handles.filter_style,'Value');
setappdata(handles.figure_wavelet,'Filter_style',Filter_style);

% --- Executes during object creation, after setting all properties.
function filter_style_CreateFcn(hObject, eventdata, handles)
% hObject    handle to filter_style (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end



% --------------------------------------------------------------------
function m_thanks_Callback(hObject, eventdata, handles)
% hObject    handle to m_thanks (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
h = thanks; % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --function m_about_Callback(hObject, eventdata, handles)
% hObject    handle to m_about (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
h = about;

Copy the code

3. Operation results

Matlab version and references

1 matlab version 2014A

2 Reference [1] CAI Limei. MATLAB Image Processing — Theory, Algorithm and Case Analysis [M]. Tsinghua University Press, 2020. [2] Yang Dan, ZHAO Haibin, LONG Zhe. Examples of MATLAB Image Processing In detail [M]. Tsinghua University Press, 2013. [3] Zhou Pin. MATLAB Image Processing and Graphical User Interface Design [M]. Tsinghua University Press, 2013. [4] LIU Chenglong. Proficient in MATLAB Image Processing [M]. Tsinghua University Press, 2015. [5] HAN Tianqi, Yang Wenjie, ZHAO Jianguang. Image denoising Analysis based on wavelet transform threshold [J]. Software. 201,42(06)