✅ Author Introduction: A MATLAB simulation developer passionate about research, improving both mindset and technology. For MATLAB project collaboration, feel free to contact.
🏆 Code Acquisition Method:
QQ:912100926
⛳️ Motto: Those who travel a hundred miles are halfway at ninety.
## ⛄ 1. Introduction to Two-Dimensional Image Decomposition Using Wavelets
This article uses two wavelet analysis methods: Haar and db3, which effectively demonstrate the characteristics of wavelet transforms. Below, we will introduce these two wavelet functions.
**1. Haar Wavelet Function**
The Haar function is the earliest orthogonal wavelet function used in wavelet analysis, and it is also the simplest. It is discontinuous, resembling a step function. The definition of the Haar wavelet function is:
**2. db3 Wavelet Function**
The db3 wavelet function is one of the dbN (Daubechies) wavelet family. The Daubechies function was constructed by the world-renowned wavelet analysis scholar Ingrid Daubechies. Except for db1 (the Haar wavelet), other wavelets do not have explicit expressions, but the square modulus of the transformation function h is very clear. The dbN function is a compactly supported orthogonal wavelet, which makes discrete wavelet analysis possible.
Below is the definition of dbN:
The effective support length of the dbN wavelet function ψ and the scaling function φ is 2N-1, and the vanishing moment order of the wavelet function ψ is N.
Most dbN wavelets do not possess symmetry, and for some wavelet functions, the asymmetry is very pronounced.
Regularity increases with the order N.
The function possesses orthogonality.
Daubechies wavelet functions provide more effective analysis and synthesis than Haar wavelet functions. The wavelet basis in the Daubechies family is denoted as dbN, where N is the order, and N=1,2,…10.
No image of db3 will be provided here.
**2. Wavelet Decomposition and Reconstruction Process**
The Haar wavelet is the simplest wavelet function, so we will use it as an example to illustrate the specific process of wavelet decomposition and reconstruction. Suppose there is a one-dimensional image with a resolution of only 4 pixels p0, p1, p2, p3, with corresponding pixel values or coefficients as follows:
[9 7 3 5]
The steps to calculate its Haar wavelet transform coefficients are as follows.
Step 1: Calculate the average (averaging). Calculate the average of adjacent pixel pairs to obtain a new image with lower resolution, which has 2 pixels, meaning the new image’s resolution is half of the original, with corresponding pixel values:
[8 4]
Step 2: Calculate the difference (differencing). Clearly, using 2 pixels to represent this image means that some information has been lost. To reconstruct the original image with 4 pixels from the image composed of 2 pixels, we need to store some detail coefficients to recover the lost information during reconstruction. The method is to subtract the average value of the pixel pair from the first pixel value of that pair, or to use the difference of that pixel pair divided by 2. In this example, the first detail coefficient is (9-8)=1, because the calculated average is 8, which is 1 less than 9 and 1 more than 7. Storing this detail coefficient allows us to recover the first two pixel values of the original image. Using the same method, the second detail coefficient is (3-4)=-1, storing this detail coefficient allows us to recover the last 2 pixel values. Therefore, the original image can be represented by the following two average values and two detail coefficients:
[8 4 1 -1]
Step 3: Repeat steps 1 and 2, further decomposing the image obtained from the first step into an even lower resolution image and detail coefficients. In this example, when decomposed to the end, the entire image can be represented by an average pixel value of 6 and three detail coefficients 2, 1, and -1:
[6 2 1 -1]
Thus, through the above decomposition, a 4-pixel image is represented by one average pixel value and three detail coefficients, which is the Haar wavelet transform process.
In this process, we can see:
1) No information is lost during the transformation process, as the original image can be reconstructed from the recorded data.
2) For this given transformation, various resolutions of the image can be reconstructed from the recorded data.
3) The magnitude of the detail coefficients generated after the transformation is relatively small, which provides a way for image compression, such as discarding some insignificant detail coefficients without affecting the understanding of the reconstructed image.
The above example shows that the process of calculating averages and differences in the transformation of a one-dimensional signal is essentially the process of Haar wavelet decomposition, which is the same for other wavelet functions, although the calculation methods may differ. For multi-dimensional signals, the process can be achieved by first calculating the averages and differences for each row, and then performing the same decomposition for each column. For example, performing Haar wavelet decomposition on the following two-dimensional array X:
First, perform the averaging and differencing process for each row, that is, perform a one-dimensional Haar wavelet transform for each row, resulting in the following array:
Where the first data of each row is the average of that row, and the rest are the detail coefficients of that row.
Then, using the same method, perform the averaging and differencing process for each column, that is, perform a one-dimensional Haar wavelet transform for each column, to obtain the information after Haar wavelet decomposition:
Here, the element in the upper left corner represents the average pixel value of the entire image block, and the rest are the detail coefficients of that image block. Thus, we can set a threshold, improving coding efficiency by treating some detail coefficients below this threshold as 0 to achieve compression. For example, setting the threshold d=5 means treating detail coefficients less than 5 as 0, resulting in the array:
With an increased number of zeros, coding efficiency can be greatly improved, thus achieving compression. Performing the inverse Haar wavelet transform on this array, that is, wavelet reconstruction, can yield an approximate reconstructed array of the original array:
The reconstructed array shows a considerable degree of similarity to the original array, which is acceptable to a certain extent.
## ⛄ 2. Partial Source Code
clear all;
X=imread(‘1.bmp’,’bmp’);
subplot(321);imshow(X);
title(‘Original Image’);
% Three-level wavelet decomposition and display
[c,s]=wavedec2(X,3,’db2′);
ca3=appcoef2(c,s,’db2′,3);
ch3=detcoef2(‘h’,c,s,3);
cv3=detcoef2(‘v’,c,s,3);
cd3=detcoef2(‘d’,c,s,3);
ch2=detcoef2(‘h’,c,s,2);
cv2=detcoef2(‘v’,c,s,2);
cd2=detcoef2(‘d’,c,s,2);
ch1=detcoef2(‘h’,c,s,1);
cv1=detcoef2(‘v’,c,s,1);
cd1=detcoef2(‘d’,c,s,1);
A2=[ca3*4,ch3*4;cv3*4,cd3*4]
% Display decomposition results
k=s(2,1)*2-s(3,1)
ch2=padarray(ch2,[k k],1,’post’);
cv2=padarray(cv2,[k k],1,’post’);
cd2=padarray(cd2,[k k],1,’post’);
A1=[A2,ch2*4;cv2*4,cd2*4];
k=s(2,1)*4-s(4,1)
ch1=padarray(ch1,[k k],1,’post’);
cv1=padarray(cv1,[k k],1,’post’);
cd1=padarray(cd1,[k k],1,’post’);
A=[A1,ch1*4;cv1*4,cd1*4]
min=min(A(:));
max=max(A(:));
subplot(322);imshow(A,[min max]);
title(‘Three-Level Decomposition Image of Wavelet Transform’);
## ⛄ 3. Running Results
## ⛄ 4. MATLAB Version and References
**1. MATLAB Version**
2014a
**2. References**
[1] Li Liming, Yang Lijun, Wang Hong. Two-Dimensional Image Decomposition and Reconstruction Based on Wavelets [J]. Journal of Hunan Metallurgy Vocational and Technical College. 2005, (04)
**3. Note**
This section is extracted from the internet for reference only. If there is any infringement, please contact for removal.
**🍅 Simulation Consulting**
1. Various Intelligent Optimization Algorithm Improvements and Applications**
Production scheduling, economic scheduling, assembly line scheduling, charging optimization, workshop scheduling, departure optimization, reservoir scheduling, three-dimensional packing, logistics site selection, cargo location optimization, bus scheduling optimization, charging pile layout optimization, workshop layout optimization, container ship loading optimization, pump combination optimization, medical resource allocation optimization, facility layout optimization, visual domain base station and drone site selection optimization.
**2. Machine Learning and Deep Learning**
Convolutional Neural Networks (CNN), LSTM, Support Vector Machines (SVM), Least Squares Support Vector Machines (LSSVM), Extreme Learning Machines (ELM), Kernel Extreme Learning Machines (KELM), BP, RBF, Wide Learning, DBN, RF, RBF, DELM, XGBOOST, TCN for wind power prediction, photovoltaic prediction, battery life prediction, radiation source identification, traffic flow prediction, load forecasting, stock price prediction, PM2.5 concentration prediction, battery health status prediction, water optical parameter inversion, NLOS signal recognition, subway stop precision prediction, transformer fault diagnosis.
**3. Image Processing**
Image recognition, image segmentation, image detection, image hiding, image registration, image stitching, image fusion, image enhancement, image compressed sensing.
**4. Path Planning**
Traveling Salesman Problem (TSP), Vehicle Routing Problem (VRP, MVRP, CVRP, VRPTW, etc.), UAV three-dimensional path planning, UAV collaboration, UAV formation, robot path planning, grid map path planning, multimodal transport problems, vehicle collaborative UAV path planning, antenna linear array distribution optimization, workshop layout optimization.
**5. UAV Applications**
UAV path planning, UAV control, UAV formation, UAV collaboration, UAV task allocation.
**6. Wireless Sensor Positioning and Layout**
Sensor deployment optimization, communication protocol optimization, routing optimization, target positioning optimization, Dv-Hop positioning optimization, Leach protocol optimization, WSN coverage optimization, multicast optimization, RSSI positioning optimization.
**7. Signal Processing**
Signal recognition, signal encryption, signal denoising, signal enhancement, radar signal processing, signal watermark embedding and extraction, EMG signals, EEG signals, signal timing optimization.
**8. Power Systems**
Microgrid optimization, reactive power optimization, distribution network reconstruction, energy storage configuration.
**9. Cellular Automata**
Traffic flow, crowd evacuation, virus spread, crystal growth.
**10. Radar**
Kalman filter tracking, trajectory association, trajectory fusion.