A list,
Matlab GUI based image histogram, filtering, wavelet transform, segmentation processing system
Part1-Introduction To The Wavelet Transform
1, Origin of the Wavelet transform: the theories of Wavelet originate from Diffierent areas of study:
- Engineering
- Time-frequency analysis and Multiresolution Analysis
- Computer Vision
- Pyramidal algorithm
- Physics
- Pure Mathematics
2, Multiresolution Analysis (MRA- Multi-resolution Analysis and processing)
- Multiresolution analysis is about analyzing a signal based on the information appeared in different scales of such Signal — to mimic human beings in analyzing signals.
- A signal of a certain “scale” refers to its best approximation at a certain resolution
- By “‘ll “the fromthe coarse scales toward the fine scales, one zooms in and arrives at a more exact representation of the given signal
3, The Discrete Wavelet Transform
A simple way to implement MAR is by using the Discrete Wavelet Transform(DWT):
The definition of wavelet transform shows that the wavelet analysis is a measure of similarity the basis functions(wavelets) and the original function .The coefficients ,named H0 for Low Pass Filter, and H1 for High Pass Filter, caculated indicate how close the function is to the danghter wavelet at that particular scale.
Part2-Decomposition(DWT) and Reconstruction(Inverse DWT) — Discrete wavelet Decomposition and Reconstruction
For discrete Wavelet transforms, since many Wavelet functions are not orthogonal, a Scaling Coefficients and a Wavelet coefficient are needed. Thus, the original signal function can be decomposed into a linear combination of the scaling function (coefficient) and the wavelet function (coefficient), in which the scaling function produces the low frequency part and the wavelet function produces the high frequency part.
1. One-dimensional Haar wavelet transform-decomposition
When discrete signals undergo Haar wavelet transform, the information carried by the signal is first compressed to obtain N/2 data points for storage. Then, the point information is represented by these Scaling Coefficients. For discrete signal, it may have high frequency and low frequency components, and the wavelet coefficient or detail coefficient represents its high frequency part.
The downsampling in wavelet is the interpoint sampling of the signal, the purpose is to compress and store the information. The upsampling in wavelet is zero insertion at interpoint to reconstruct the signal.
The signal filtering process is mathematically equivalent to the convolution of the signal and the impulse response of the filter.
Decomposed LP filter (discrete convolution operator) :
Decomposed HP filter (discrete convolution operator) :
Discrete time convolution theorem:
“Discrete convolution” is a special operation between two discrete sequences X (n) and H (n) by multiplying and adding their relevant sequence values in pairs according to certain rules. The specific formula can be expressed as:
Where y (n) is a new sequence of convolution.
Discrete convolution has a wide range of applications in engineering. For example, in the field of digital image processing, in order to filter the digital signal, the image signal C(n) represented as a discrete sequence can be discretely convolved with the impulse response H (n) of the digital filter.
The wavelet function ψ (t) and the scale function φ(t) of multiresolution analysis satisfy the difference equation of two-scale:
Multiresolution analysis of each layer of decomposition makes the signalf(t)Through a low pass filter and a band pass filter, the signal is decomposed into low frequency part and high frequency part. Low pass filters are characterized by wavelet functionsΨ (x)Determine that the characteristics of the bandpass filter are determined by the scale functionPhi (x)Sure. The decomposed coefficient consists of two parts:Low frequency coefficient vectorc1andHigh frequency coefficient vector d1. Low frequency coefficient vectorc1 是The impulse response of the signal and the low-pass filter (determined by the wavelet function) is obtained by convolution operation, high frequency coefficient vectord1isObtained by convolution operation of signal and bandpass filter (scale function determined).
2. One-dimensional Haar wavelet transform — reconstruction
Inverse transformation process:
3. Two-dimensional Haar wavelet transform
Two-dimensional image signal
For 2d image signal, the method of horizontal and vertical filtering can be used to realize 2d wavelet multi-resolution decomposition. Figure 2.5 shows the division of sub-images after decomposition by two-dimensional discrete wavelet transform. Among them:
(l)LL subband is the wavelet coefficient generated by convolution of two directions using low-pass wavelet filter, which is the approximate representation of the image.
(2)HL subband is the wavelet coefficient generated by convolution of low-pass wavelet filter in the row direction and high-pass wavelet filter in the column direction, which represents the horizontal singularity characteristics of the image. (Horizontal subband)
(3)LH subband is the wavelet coefficient generated by convolving with high-pass wavelet filter in the row direction and then convolving with low-pass wavelet filter in the column direction, which represents the vertical singularity characteristics of the image. (Vertical subband)
(4)HH subband is the wavelet coefficient generated by convolution of two directions with high-pass wavelet filter, which represents the diagonal edge characteristics of the image. (Diagonal subband)
The first letter represents the processing of column direction, and the second letter represents the processing of row direction. The singular characteristics of the image are retained by low-pass and filtered by high-pass.
Wavelet denoising method is to find the best image from the real signal space to the wavelet function space in order to get the best restoration of the original signal.
At present, wavelet denoising methods can be roughly divided into three categories:
The first kind of method – wavelet transform modulus maximum denoising method
Wavelet transform modulus maxima principle is used to denoise, that is, according to the different propagation characteristics of signal and noise in wavelet transform scales, the modulus maxima points generated by noise are removed, the corresponding modulus maxima points of signal are retained, and then the wavelet coefficients are reconstructed by using the remaining modulus maxima points, and then the signal is restored.
The second kind of method – wavelet coefficient correlation denoising method
After the wavelet transform of the noisy signal, the correlation of wavelet coefficients between adjacent scales is calculated, and the types of wavelet coefficients are distinguished according to the magnitude of correlation, and then the signals are reconstructed directly.
The third kind of method – wavelet transform threshold method
Wavelet threshold denoising method, this method thinks that the wavelet coefficients corresponding to the signal contain important information of the signal, its amplitude is large, but the number is small, while the wavelet coefficients corresponding to the noise are uniformly distributed, the number is large, but the amplitude is small.
4. Wavelet threshold shrinkage denoising method:
1. Basic idea of wavelet threshold denoising:
The basic idea of wavelet threshold denoising proposed by Donoho is that after the signal is transformed by wavelet (Mallat algorithm is adopted), the wavelet coefficient generated by the signal contains important information of the signal. After the signal is decomposed by wavelet, the wavelet coefficient of the signal is larger, and the wavelet coefficient of the noise is smaller, and the wavelet coefficient of the noise is smaller than that of the signal. By selecting an appropriate threshold value, the wavelet coefficient greater than the threshold value is considered to be generated by signals and should be retained, while the wavelet coefficient less than the threshold value is considered to be generated by noise and set to zero to achieve the purpose of denoising. The basic steps are as follows: (1) decomposition: select a wavelet with N layers to carry out wavelet decomposition of signals; (2) Threshold processing process: After decomposition, select an appropriate threshold and use the threshold function to quantify the coefficient of each layer; (3) Reconstruction: signal reconstruction with the processed coefficients.
2. Basic problems of wavelet threshold denoising
The basic problem of wavelet threshold denoising includes three aspects: wavelet base selection, threshold selection and threshold function selection. (1) Selection of wavelet basis: Usually, we hope that the selected wavelet meets the following conditions: orthogonality, high vanishing moment, tight support, symmetry or antisymmetry. But in fact, it is impossible for the wavelet with the above properties to exist, because only Haar wavelet is symmetric or antisymmetric, and the high vanishing moment and compact support are a pair of contradictions, so in the application, the wavelet with compact support is generally selected and the more appropriate wavelet is selected according to the characteristics of the signal. (2) Selection of threshold value: The selection of threshold value is an important factor that directly affects the denoising effect. Different selection of threshold value will have different denoising effect. At present, there are mainly general shrink threshold (VisuShrink threshold), SureShrink threshold, Minimax threshold, BayesShrink threshold, etc. (3) Selection of threshold functions: Threshold functions are rules for correcting wavelet coefficients, and different inverse functions reflect different strategies for dealing with wavelet coefficients. The most commonly used threshold functions are of two types: hard and soft. There is also a Garrote function between the soft and hard threshold functions. In addition, the signal to noise ratio (SNR) and the root mean square error (MSE) between the estimated signal and the original signal are used to evaluate the denoising effect.
Ii. Source code
unction varargout = exp_gs(varargin)
% EXP_GS M-file for exp_gs.fig
% EXP_GS, by itself, creates a new EXP_GS or raises the existing
% singleton*.
%
% H = EXP_GS returns the handle to a new EXP_GS or the handle to
% the existing singleton*.
%
% EXP_GS('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EXP_GS.M with the given input arguments.
%
% EXP_GS('Property','Value',...) creates a new EXP_GS or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before exp_gs_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to exp_gs_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 exp_gs
% Last Modified by GUIDE v2.5 30-Jun-2010 13:33:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @exp_gs_OpeningFcn, ...
'gui_OutputFcn', @exp_gs_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 exp_gs is made visible.
function exp_gs_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 exp_gs (see VARARGIN)
% Choose default command line output for exp_gs
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes exp_gs wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = exp_gs_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;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit 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 button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ImgPath=get(handles.edit1,'String');
global img_1;
img_1=imread(ImgPath);
axes(handles.axes1);
imshow(img_1);
global histogram1;
histogram1=zeros(1,256);
[sizex,sizey]=size(img_1);
for ii=1:sizex % 计算直方图
for jj=1:sizey
histogram1(img_1(ii,jj)+1)=histogram1(img_1(ii,jj)+1)+1;
end
end
maxhisto1=sum(histogram1);% 归一化
histogram1=histogram1/maxhisto1;
axes(handles.axes2);
bar(0:255,histogram1);
axis([0 255 0 max(histogram1)]);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global img_1;
[sizex,sizey]=size(img_1);
for ii=1:sizex % 减小动态范围
for jj=1:sizey
img_1tmp(ii,jj)=floor(img_1(ii,jj)/2)+64;
end
end
global img_11;
img_11=img_1tmp;
axes(handles.axes3);
imshow(img_11);
histogram2=zeros(1,256);
for ii=1:sizex
for jj=1:sizey
histogram2(img_11(ii,jj)+1)=histogram2(img_11(ii,jj)+1)+1;
end
end
maxhisto2=sum(histogram2);
histogram2=histogram2/maxhisto2;
axes(handles.axes4);
bar(0:255,histogram2);
axis([0 255 0 max(histogram2)]);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global img_1;
[sizex,sizey]=size(img_1);
for ii=1:sizex % 直方图左移
for jj=1:sizey
img_1tmp(ii,jj)=img_1(ii,jj)-30;
end
end
global img_11;
img_11=img_1tmp;
axes(handles.axes3);
imshow(img_11);
histogram3=zeros(1,256);
for ii=1:sizex
for jj=1:sizey
histogram3(img_11(ii,jj)+1)=histogram3(img_11(ii,jj)+1)+1;
end
end
maxhisto3=sum(histogram3);
histogram3=histogram3/maxhisto3;
axes(handles.axes4);
bar(0:255,histogram3);
axis([0 255 0 max(histogram3)]);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global img_1;
[sizex,sizey]=size(img_1);
for ii=1:sizex % 直方图右移
for jj=1:sizey
img_1tmp(ii,jj)=img_1(ii,jj)+30;
end
end
global img_11;
img_11=img_1tmp;
axes(handles.axes3);
imshow(img_11);
histogram4=zeros(1,256);
for ii=1:sizex
for jj=1:sizey
histogram4(img_11(ii,jj)+1)=histogram4(img_11(ii,jj)+1)+1;
end
end
Copy the code
3. Operation results