Upload
audra-jacobs
View
226
Download
0
Embed Size (px)
Citation preview
DCT
3. Discrete Cosine transform (DCT) The discrete cosine transform (DCT) is the basis
for many image compression algorithms they use only cosine function only. Assuming an N*N image , the DCT equation is given by
α(v)α(u),
2N
1)vπ(2c cos
2N
1)uπ(2r cos c)I(r,α(u)α(v)v)D(u,
0u if N1
0u if N2
1N
0r
1N
0c
0u if 2N
1)uπ(2vcos
N2
0u if N1
v)D(u,
where u= 0,1,2,…N-1 along rows and v= 0,1,2,…N-1 along columns
In matrix form for DCT the equation become as
• One clear advantage of the DCT over the DFT is that there is no need to manipulate complex numbers.• the DCT is designed to work on pixel values ranging from -0.5 to 0.5 for binary image and from -128 to 127 for gray or color image so the original image block is first “leveled off” by subtract 0.5 or 128 from each entry pixel values.
the general transform equation for DCT is TD I DA
Properties of DCT
Original image DCT
Derive the DCT coefficient matrix of 4 * 4 block image
)8
21πcos(
4
2)
8
15πcos(
4
2)
8
9πcos(
4
2)
8
3πcos(
4
2
)8
14πcos(
4
2)
8
10πcos(
4
2)
8
6πcos(
4
2)
8
2πcos(
4
2
)8
7πcos(
4
2)
8
5πcos(
4
2)
8
3πcos(
4
2)
8
πcos(
4
21/21/21/21/2
D
0.27-0.650.65-0.27
0.50.5-0.5-0.5
0.65-0.27-0.270.65
0.50.50.50.5
D
33323130
23222120
13121110
03020100u0u1u2u3
v0 v1 v2 v3
EX1: Calculate the DCT transform for the image I(4,4)
0101
1010
0101
1010
I
0.5-0.50.5-0.5
0.50.5-0.50.5-
0.5-0.50.5-0.5
0.50.5-0.50.5-
I off leveled
0.27-0.650.65-0.27
0.50.5-0.5-0.5
0.65-0.27-0.270.65
0.50.50.50.5
A
0.5-0.50.5-0.5
0.50.5-0.50.5-
0.5-0.50.5-0.5
0.50.5-0.50.5-
*
0.27-0.50.65-0.5
0.650.5-0.27-0.5
0.65-0.5-0.270.5
0.270.50.650.5
*
0.27-0.650.65-0.27
0.50.5-0.5-0.5
0.65-0.27-0.270.65
0.50.50.50.5
A
0.9200.380
0.92-00.38-0
0.9200.380
0.92-00.38-0
*
1.71-00.71-0
0000
0.71-00.29-0
0000
A
D I
TD
TD D I
D I TD
Derive the DCT coefficient matrix of 8 * 8 block image
77767574 73727170
67666564 63626160
57565554 53525150
47464544 43424140
37363534
27262524
17161514
07060504
33323130
23222120
13121110
03020100
)16
105πcos(
8
2)
16
91πcos(
8
2)
16
77πcos(
8
2)
16
63πcos(
8
2 )
16
49πcos(
8
2)
16
35πcos(
8
2)
16
21πcos(
8
2)
16
7πcos(
8
2
)16
90πcos(
8
2)
16
78πcos(
8
2)
16
66πcos(
8
2)
16
54πcos(
8
2)
16
42πcos(
8
2)
16
30πcos(
8
2)
16
18πcos(
8
2)
16
6πcos(
8
2
)16
75πcos(
8
2)
16
65πcos(
8
2)
16
55πcos(
8
2)
16
45πcos(
8
2 )
16
35πcos(
8
2)
16
25πcos(
8
2)
16
15πcos(
8
2)
16
5πcos(
8
2
)16
60πcos(
8
2)
16
52πcos(
8
2)
16
44πcos(
8
2)
16
36πcos(
8
2 )
16
28πcos(
8
2)
16
20πcos(
8
2)
16
12πcos(
8
2)
16
4πcos(
8
2
)16
45πcos(
8
2)
16
39πcos(
8
2)
16
33πcos(
8
2)
16
27πcos(
8
2
)16
30πcos(
8
2)
16
26πcos(
8
2)
16
22πcos(
8
2)
16
18πcos(
8
2
)16
18πcos(
8
2)
16
15πcos(
8
2)
16
12πcos(
8
2)
16
9πcos(
8
2
8
1
8
1
8
1
8
1
)16
21πcos(
8
2)
16
15πcos(
8
2)
16
9πcos(
8
2)
16
3πcos(
8
2
)16
14πcos(
8
2)
16
10πcos(
8
2)
16
6πcos(
8
2)
16
2πcos(
8
2
)16
7πcos(
8
2)
16
5πcos(
8
2)
16
3πcos(
8
2)
16
πcos(
8
2
8
1
8
1
8
1
8
1
D
0.0975- 0.2778 0.4157- 0.4904 0.4904- 0.4157 0.2778- 0.975
0.1913 0.4619- 0.4619 0.1913- 0.1913- 0.4619 0.4619-0.1913
0.2778 - 0.4904 0.0975- 0.4157- 0.4157 0.0975 0.4904-0.2778
0.3536 0.35360.35360.3536 0.3536 0.35360.35360.3536
0.41570.09750.49040.27780.4619 0.19130.19130.46190.49040.41570.27780.09750.3536 0.35360.3536 0.3536
0.27780.49040.09750.41570.46190.19130.19130.46190.0975 0.27780.41570.3536 0.35360.35360.3536
0.4904-
D
So the (DCT) matrix of 8*8 image
inverse discrete cosine transform (IDCT)
the general inverse transform equation for DCT is
D ADI T
1.71-00.71-0
0000
0.71-00.29-0
0000
*
Calculate the IDCT transform for the image I(4,4)
0.27-0.650.65-0.27
0.50.5-0.5-0.5
0.65-0.27-0.270.65
0.50.50.50.5
*
0.27-0.50.65-0.5
0.650.5-0.27-0.5
0.65-0.5-0.270.5
0.270.50.650.5
I
1.71-00.71-0
0000
0.71-00.29-0
0000
A
A D
TD
0.920.92-0.920.92-
0000
0.380.38-0.380.38-
0000
*
0.27-0.50.65-0.5
0.650.5-0.27-0.5
0.65-0.5-0.270.5
0.270.50.650.5
I
0.5
0.5-0.50.5-0.5
0.50.5-0.50.5-
0.5-0.50.5-0.5
0.50.5-0.50.5-
I
0101
1010
0101
1010
I
wavelet
FilteringAfter the image has been transformed into the frequency domain , we may want to modify the resulting spectrum
1. high-pass filter:- use to remove the low- frequency information which will tend to sharpen the image
2. low-pass filter:- use to remove the high- frequency information which will tend to blurring or smoothing the image
3. Band-pass filter:- use to extract the(low , high) frequency information in specific parts of spectrum
4. Band-reject:- use to eliminate frequency information from specific part of the spectrum
4. Discrete wavelet transform (DWT)Definition:-The wavelet transform is
really a family transform contains not just frequency information but also spatial information Numerous filters can be used to implement the wavelet transform and the two commonly used are the Haar and Daubechies wavelet transform .
Wavelet families 1.Haar wavelet2.Daubechies families
(D2,D3,D4,D5,D6,…..,D20)3. biorthogonal wavelet4.Coiflets wavelet5.Symlets wavelet6.Morlet wavelet
The discrete wavelet transform of signal or image is calculated by passing it through a series of filters called filter bank which contain levels of low-pass filter (L) and high- pass (H) simultaneously . They can be used to implement a wavelet transform by first convolving them with rows and then with columns. The outputs giving the detail coefficients (d) from the high-pass filter and course approximation coefficients (a) from the low-pas filter .
decomposition algorithm
2. Convolve the high-pass filter with the rows of image and the result is (H) band with size (N/2,N).
1.Convolve the low-pass filter with the rows of image and the result is (L) band with size (N/2,N).
Implement DWT -:
3. Convolve the columns of (L) band with low-pass filter and the result is (LL) band with size (N/2,N/2).
4. Convolve the columns of (L) band with high-pass filter and the result is (LH) band with size (N/2,N/2).
5. Convolve the columns of (H) band with low-pass filter and the result is (HL) band with size (N/2,N/2).
6. Convolve the columns of (H) band with high-pass filter and the result is (HH) band with size (N/2,N/2).
Original image I( N*N)
High-pass filter
High-pass filter
Low-pass filter
Low-pass filter
High-pass filter
Low–pass filter
High-pass filter
High-pass filter
Low-pass filter
Low-pass filter
High-pass filter
Low-pass filter
Level 1 (N/2, N/2)
Level 2 (N/4*N/4)
rowscolumn
columnrows
This six steps of wavelet decomposition are repeated to further increase the detailed and approximation coefficients decomposed with high and low pass filters . in each level we start from (LL) band .the DWT decomposition of input image I(N,N) show as follow for two levels of filter bank
Haar wavelet transform
The Haar equation to calculate the approximation coefficients and detailed coefficients given as follow if si represent the input vector
high–pass filter for Haar waveletH0 = 0.5H1= - 0.5
2
ssa 1ii
i
2
ssd 1ii
i
approximation coefficients detailed coefficients
Low –pass filter for Haar waveletL0 = 0.5L1= 0.5
Calculate the Haar wavelet for the following image
117 101 170152161138104 132
120 111 151154154143125 136
113 144 184179168162140 151
108 151 152145159181156 134
110 151 10095114135154 121
135 169 112110107108134 147
149 150 163156129132125 159
135 107 156150141149132 135
I=
L109 121 151156.5
115.5 134 143.5154128.5 151 167.5173.5129.5 168.5 143152130.
5144.5 110.5104.5
152 121 129.5108.5149.5 129.5 161142.5121 140.5 145145.5
H4.5-178 190-94.5 7.5
-5.5-11-15.5 16.57-12.5-21.5 9
9.59.5-20.5 -10.5-1.513-17 -17.5-13.5-2.5-0.5 2
-4.5-8.514 10.5
L109 121 151156.5
115.5 134 143.5154128.5 151 167.5173.5129.5 168.5 143152130.
5144.5 110.5104.5
152 121 129.5108.5149.5 129.5 161142.5121 140.5 145145.5
12.25-136.25 13.25
0.75-11.75-18.5 12.75
411.25-18.75 -14
-9-5.56.75 6.25
1
-3.25
-0.5
-10.75
14.25
-6.5 3.751.25
-8.75 12.2510.75
11.75 -9.5-2
-5.5 7.75-1.5
1
2.25-41.75 5.75
-6.250.753 3.75
5.5-1.75-1.75 3.5
-4.53-7,75 -4.25
112.25
129
141.25
135.25
127.5 147.25155.25
159.75 155.25162.75
132.75 120106.5
135 153.25144
H4.5-178 190-94.5 7.5
-5.5-11-15.5 16.57-12.5-21.5 9
9.59.5-20.5 -10.5-1.513-17 -17.5-13.5-2.5-0.5 2
-4.5-8.514 10.5
1
Then convolution the columns of result with low and high -pass filters
in the next level we start with (LL1) band
After apply convolution rows of (LL1) band with law-pass ,high pass filters
Then convolution the columns of result with low and high -pass filters
H24-7.625
3.75-15.375
-6.754.24
-4.6250.125
1112.25 127.5 147.25155.25
129 159.75 155.25162.75141.25 132.75 120106.5135.25 135 153.25144
L2119.875 151.25144.375 159
137 113.25135.125 148.75
HL2
HH2
3.875-11.5LL2
132.125 155.125136.062 130.937 -5.6872.1875
0.1253.875
LH2
-12.25 -3.8750.9375 -17.687 -1.0622.0625
So the decomposition for two levels are
1
2.25-136.25 13.25
0.75-11.75-18.5 12.75
411.25-18.75 -14
-9-5.56.75 6.25
1
-3.25 -6.5 3.751.25
-0.5 -8.75 12.2510.75
-10.75 11.75 -9.5-2
14.25 -5.5 7.75-1.5
1
2.25-41.75 5.75
-6.250.753 3.75
5.5-1.75-1.75 3.5
-4.53-7,75 -4.25
LL2 HL2
LH2 HH2
132.125 155.125 3.875-11.5
136.062 130.937 -5.6872.1875
-12.25 -3.875 0.1253.875
0.9375 -17.687 -1.0622.0625
inverse Haar wavelet transform To reconstructs the original image we use
the following equations idiaiS idia1iS
First begin with (LL2) band and apply the above equations with each corresponded element of (HL2) band rows , and the same work apply between LH2 and HH2 rows
120.625
143.625 159 151.25
138.25133.87
4 125.25136.62
4-8.375
-16.125 -3.75 -4
3 -1.125 -18.749
-16.625
LL2 HL2
LH2 HH2
132.125
155.125
-11.5 3.875136.06
2130.93
72.1875 -5.687
-12.25 -3.875 3.875 0.125
0.9375-
17.6872.0625 -1.062
Then apply the above equations with columns of new matrix as showing 120.62
5143.62
5159 151.25
138.25 133.874
125.25136.62
4
-8.375 -16.125
-3.75 -4
3 -1.125-
18.749-
16.625
1
112.25
129
141.25
135.25
132.75 120106.5
135 153.25144
127.5 147.25155.25
159.75 155.25162.75
1
1
2.25-136.25 13.25
0.75-11.75-18.5 12.75
411.25-18.75 -14
-9-5.56.75 6.25
1
2.25-41.75 5.75
-6.250.753 3.75
5.5-1.75-1.75 3.5
-4.53-7,75 -4.25
1
112.25 127.5 147.25155.25
129 159.75 155.25162.75
141.25 132.75 120106.5
135.25 135 153.25144
-3.25 -6.5 3.751.25
-0.5 -8.75 12.2510.75
-10.75 11.75 -9.5-2
14.25 -5.5 7.75-1.5
118.5 106 140.5114.5 157.5 153 134160.5
118.5 106 140.5114.5 157.5 153 134160.5
110.5 147.5 171.5148 163.5 162 142.5168
122.5 160 121.5144 110.5 102.5 134106
142 128.5 140.5129.5 135 153 147159.5
-1.5 -5 -2.5-10.5 3.5 -1 -29.5
2.5 -3.5 -9.5-8 4.5 17 8.516
-12.5 -9 13.510 3.5 -7.7 -13-6
6.5 22 -8.5-2.5 -6 3 123.5
120
117
113
108
117 101 170152161138104 132120 111 151154154143125 136113 144 18
4179168162140 151
108 151 152145159181156 134110 151 10095114135154 121135 169 112110107108134 147149 150 163156129132125 159135 107 156150141149132 135
I=
99 103 100 112 98 95 92 72
101 120 121 103 87 78 64 49
92 113 104 81 64 55 35 24
77 103 109 68 56 37 22 18
62 80 87 51 29 22 17 14
56 69 57 40 24 16 13 14
55 60 58 26 19 14 12 12
61 51 40 24 16 10 11 16
I=
Home work