DWT Image compression basics
This page of MATLAB source code covers DWT image compression. It explains basic steps for DWT based image compression matlab source code.
Before we move to image compression basics let us go through lossless and lossy data compression techniques. This is needed as in order to compress the image, initially input image of size 256x256 pixels is converted to raw data information.
Input image for DWT based compression

There are four basic steps for image compression and image restoration as outlined below.
STEP-1. Applying the transform (Haar or Daubechies-6 wavelet)
STEP-2. Choosing a soft threshold or hard threshold
STEP-3. Compression methods-Run Length Coding referred as RLE or DPCM(Differential Pulse Code Modulation)
STEP-4. Applying the Inverse Transform to recover the compressed image
DWT image compression MATLAB Code
% CLOSE ALL closes all the open figure windows.
close all;
X=imread('lenna256x256.gif');
X=X(1:256,1:256);
figure;
%load woman;
%subplot(2,1,1);
imshow(uint8(X));
% STEP-1: wavelet transform (rowwise) ...haar wavelet...traditional approach...
f=X;
[m n]=size(X);
k=n/2;
%k=n;
for i=1:1:m
for j=1:1:k
f(i,j) =X(i,2*j)+X(1,2*j-1);
f(i,j+k) = X(i,2*j) - X(i,2*j-1);
end
end
X = f;
k=m/2; %wavelet transform column wise
%k=m;
for j=1:1:n
for i=1:1:k
X(i,j) = uint8((f(2*i,j)+f(2*i-1,j))/2);
X(i+k,j)= uint8((f(2*i,j)-f(2*i-1,j))/2);
end
end
Y=X;
figure; imshow(Y(1:128,1:128));
Image compression output after step-1

threshold=70;
[m n]=size(Y);
for i=1:m
for j=1:n
if(Y(i,j)
else
%Y(i,j)=Y(i,j); % HARD THRESHOLD
Y(i,j)=sign(Y(i,j))*(abs(Y(i,j))-threshold);% SOFT THRESHOLD
end
end
end
Y1=Y;
figure; imshow(Y1(1:128,1:128));
Image compression output after step-2

Similarly perform step-3 to further apply compression to the image data obtained in step-2
%%STEP-3: Compression using coding technique(RLC Coding)
%%Coding Run Length coding
%%Original image data(8 bit)
%%127 127 127 127 129 129 129
%%Run length encoded image data
%%127 4 129 3
%%IMPLEMENT: Every such sequence we replace with a zero value followed by it's length.
At last perform the reverse operation as carried out in step1 to step-3 to recover the compressed image back to its input shape. This is referred as Inverse Transform.
Useful Links to MATLAB codes
Refer following as well as links mentioned on left side panel for useful MATLAB codes.
PTS for PAPR reduction
OFDM Preamble generation
Time off estimation corr
Freq off estimation corr
channel estimation
11a WLAN channel
11g WLAN channel
15.3 UWB channel
RF and Wireless tutorials
WLAN 802.11ac 802.11ad wimax Zigbee z-wave GSM LTE UMTS Bluetooth UWB IoT satellite Antenna RADAR