Title: ?????? Digital Image Processing ???? Image Transformation
1?????? Digital Image Processing???? Image
Transformation
- ????Dr.Ji Zhen
- Faculty of Information Engineering, SZU
- 2003.01
2Basic Concepts
- Image information can be transformed into
different spaces by different transforms - T X Y
- X is source space Y is object space
- Reversible
- Computation is simple in Transformed space
- Transform algorithm is simple
3Properties of Image Transforms
- Simplify algorithm. For example
- Convolution in spatial space Multiplication in
frequency space - Some characteristics of image can be recognized
easily in transformed space. For example - In Transformed space, image energy can be more
concentrated, which can be used to compress the
image. - Several transformation can be used to extract
features of images. For example - K-L Transformation
4Contents of Image Transformation
- Basis Images
- The Discrete Fourier Transform (DFT)
- The Discrete Cosine Transform (DCT)
- The Hadamard-Walsh Transform
- The Haar Transform
- The Karhumen-Loeve Transform
- The Discrete Wavelet Transform (DWT)
5Basis Images (??)
- The inverse tow-dimensional transform can be
viewed as reconstructing the image by summing a
set of properly weighted basis images. - A basis image can be generated by inverse
transforming a coefficient matrix containing only
one nonzero element, which is set to unity. - Image transform can be written as
- F(u,v)A f (x,y)
BT - f (u,v)A F(x,y) BT
- Where ,ATa1, a2, ,aN, BTb1, b2, ,bN,
- ai, bi is N1 vector
6Basis Images
7Basis Images
- The basis images can be thought of as a set of
basic components into which any image can be
decomposed. They are also the building blocks
from which any image can be reassembled. - The forward transform does the decomposition by
determining the coefficients. - The inverse transform does the reconstitution by
summing the basis images, weighted by those
coefficients aij.
8Basis Matrix, Basis Image
- Basis matrix is the matrix aibjTN N
- basis image is a matrix defined as
9?????????
- ???? NN ???,?????? N2N 2???????? N N ,?????
NN ??????? - ?????????????????????????????,????????????????????
?????????,???????? - ??????????????????????????????????????????
- ????????????????????????????????????????,??????,?
????????(??????????)??? K-L ??,????????????,??????
?????,?? K-L ???????????
10Discrete Fourier Transform (DFT)
- Image f(x,y),0xM-1,0yN-1
- Transform kernel
- Discrete Fourier Transform of f(x,y)is
11Discrete Fourier Transform (DFT)
- In generally, MN. Transform kernel can be
represented as - Discrete Fourier Transform of f(x,y) can be
represented as
12Modulus?Phase?Power Spectrum
- Let R(u,v)?I(u,v) be real part and imaginary part
of F(u,v) - Modulus
- Phase
- Power Spectrum
13Basis Matrix of The Fourier Transform
- The Fourier TransformABATBTW where
- Basis Matrix
14Basis Images of The Fourier Transform(N8 Phase
Image)
15Transform (Example)
- imgimread('lena.bmp','bmp')
- subplot(121)imshow(img)
- title('original image ')
- fimgfftshift(fft2(img))
- subplot(122) imshow(abs(fimg)/10000)
- title(' transformed image ')
16Transform (Example)
- Azeros(128)
- A(333363,333363)255ones(64)
- Aimread('lena.bmp','bmp')
- m fft2(A)
- m fftshift(m)
- subplot(2,2,1)imshow(A)
- title('Original Image')
- subplot(2,2,3)
- mm log(1abs(m))
- mm mm/max(max(mm))255
- imshow(uint8(mm))
- title('Modulus')
17Transform (Example)
- (cont.)
- subplot(2,2,4)
- ma angle(m)
- ma (ma-min(min(ma)))/(max(max(ma)) -
min(min(ma)) )255 - imshow(uint8(ma))
- title('Phase')
- i,j find(abs(m)max(max(abs(m))))
- m(i,j) m(i,j)2
- s ifft2(m)
- subplot(2,2,2)
- imshow(uint8(abs(s)))
- title('Reconstruction Image')
18Transform (Example)
19Transform (Example)
20Properties of 2-Dimensional Fourier Transform
- 1.Separability
- 2.Linearity
- 3.Scality
- 4.Shift Theorem
- 5.Rotation
- 6.Periodicity and conjugation
- 7.Convolution
- 8.Correlation
- 9.Average
211.Separability
- Transform kernel of 2-Dimensional DFT is
- Separating the transformation into horizontal
and vertical operations. At first,
one-dimensional DFTs can be computed on the rows
of the image. Next, performs columnwise
one-dimensional DFTs on the resulting array.
221.Separability
- The implementation steps for the two-dimensional
DFT may be visualised as shown in the diagram
below
Column Transforms
Row Transforms
f(x,y)
F(x,v)
F(u,v)
Multiply by N
231.Separability
242.Linearity
- DFT is a linear operator
-
- a f1(x,y)b f2(x,y)
aF1(u,v)bF2(u,v)
253.Scality
263.Scality
274.Shift Theorem
284.Shift Theorem
- In digital image processing, it is necessary to
shift the origin of F(u,v) to the center of NN
frequency domain. - Letu0v0N/2,then
294.Shift Theorem
304.Shifting Sample(Frequency Shifting)
315.Rotation
- In polar coordinates, f (x,y) and F(u,v) can be
represented by f(r, ?) and F(w,f) alternatively.
Then - f (r, ? ?0)
F(w,f ?0)
325.Rotation Sample
336.Periodicity and conjugation
- Periodicity
- F(u,v) F(uaN,vbN)
- f (x,y) f (xaN,ybN)
- Where a,b 0, 1, 2,
- Conjugation
- F(u,v) F(-u,-v)
- F(u,v) F(-u,-v)
347.Convolution
- 2-D convolution is defined as
- Thenf(x,y)g(x,y)? F(u,v)G(u,v)
- f(x,y)g(x,y)?F(u,v)G(u,v)
358.Correlation
- 2-D correlation is defined as
- Correlation Theorems
369.Average
- Average of 2D image f (x,y) is defined as
- Let uv0 , then
-
37?????????????
- ??????,????????????????????????????????,??????????
???????,???????????????????????,????????,????????
???? - ??,k ?????,?? 1k40,?? k1
- ????? F(0,0) ?????????,?????,???? F(0,0)
??,????,????????????
38?????????????
- ???????????,??????
- ???????????,?????????????????,?????????????????,??
????????????????? - ????????????????????,????????????,????????????????
?????????????????????????????????,????????????
39Discrete Cosine Transform(DCT)
- Transform kernel of two-dimensional DCT is
- where
- Clearly,the kernel for the DCT is both separable
and symmetric, and hence the DCT may be
implemented as a series of one dimensional DCTs.
40Discrete Cosine Transform(DCT)
- Forward transform and Inverse transform
- where u, v, x, y 0, 1, 2, , N-1
41Discrete Cosine Transform(DCT)
- To enable an application of the concept of the
DCY and its relation to the DFT discussed
earlier, consider the modified basis function
gdctmod(x,u) defined below
As compared to the (unmodified) DFT basis
function
It can be seen that, neglecting the scaling
factors, the modified DCT is similar in form to
the real part of the DFT, but is not identical
due to the extra 2 on the denominator of the cos
argument. In fact we can see that the modified
DCT would be identical (again neglecting the
scaling factors) to the first half (i.e. from u0
to N-1) of the real part of a DFT of size 2N.
Hence it can be seen, as stated earlier, that DCT
analysis implies periodicity of period 2N points
(for a DCT analysis of an N-point signal).
42Transform Matrix of DCT
where
43Transform Matrix of DCT (N8)
44Transform Matrix of DCT (N8)
- N8
- u zeros(N,N)
- u(1,1N) 1.0/sqrt(2.0)
- for i2N
- for j1N
- u(i,j) cos((2j-1)(i-1)pi/(2.0N))
- end
- end
-
- u sqrt(2.0/N)u
- imagesc(u)
- colormap(gray)axis off
45Basis Images of DCT(N8)
46Example of DCT
- a,map imread('lena.bmp','bmp')
- subplot(1,2,1)
- J dct2(a)
- imshow(log(abs(J)),) colormap(jet)
-
-
- J(abs(J)lt50) 0
- K idct2(J)
- subplot(1,2,2)
- imshow(K,0 255)
47Example of DCT
imgimread('lena.bmp','bmp') subplot(121) imshow
(img) title('original image') dcimgdct2(img) s
ubplot(122) imshow(100dcimg/dcimg(1,1)) title('D
CT coefficients')
48Example of DCT
49Example of DCT
- N 8
- I imread('e\cameraman.bmp')I double(I)/255
- N 16
- dctm dctmtx(N)
- mask ones(N,N)
- imageDCT blkproc(I,N N,'P1xP2',dctm,dctm.')
- th max(max(imageDCT))/80
- index find(imageDCTltth)
- imageDCT(index) 0
50Example of DCT
- cont.
- newImage blkproc(imageDCT,N N,'P1(x.P2)P3',
dctm.', mask(1N,1N),dctm) - index find(newImagegt1)
- newImage(index) 1
- index find(newImagelt0)
- newImage(index) 0
- figure
- imshow(newImage)
-
51Example of DCT
52Example of DCT
53???????????
- DCT?????????????????????,????DCT????
- DCT?????,?????????,?????????
- DCT?????
- DCT?IDCT????????,???????????,?????????????????
- DCT???????????,?????????????????
54The Walsh-Hadamard Transform
- Transform kernel of Two-Dimensional DWT
- Transform kernel of Two-Dimensional DHT
- Where bi(x) is the ith number of binary number x
- N 2n
55The Walsh-Hadamard Transform
- The kernel matrix of DHT can be generated from
the block matrix form - The sign change count is called sequency.
- Reorder the rows to make sequency increase
uniformly with row number. This yields a
transform DWT - The sequency of DWT increases uniformly with row
number, much as frequency increases with the
Fourier kernel, which is somewhat easier to
interpret.
56The Walsh Kernel matrix(N8)
57The basis images of DWT(N8)
58The Hadamard kernel matrix(N8)
59The basis images of DHT(N8)
60???-???????
- WHT??????1?-1???,????????????????????????????????
????????,???????????? - WHT???????,??????,??????,??,????????
- WHT????????
- WHT???????,????????,????????????????,DSP?????,???
????????????,?????????????????????????????????,???
?????????????
61The Haar Transform
- The Haar transform is a symmetric, separable
unitary transformation that uses Haar funcitons
for its basis. It exists for N2n,where n is an
integer. - Whereas the Fourier transform basis functions
differ only in frequency, the Haar functions vary
in both scale(width) and position. This gives the
Haar transform a dual scale-position nature that
is evident in its basis functions.
The Haar functions
62The kernel matrix for the Haar transform(N4)
63The kernel matrix for the Haar transform(N8)
64The Haar transform basis images(N8)
65The K-L Transform(Hotelling)
- The K-L transform is variously called Hotelling
transform, the eigenvector transform, or the
method of principal componets. - Suppose image set f1(x,y), f2(x,y), ,
fi(x,y), , fL(x,y) \ - Where the correlation between fi(x,y) is commonly
rather high. - fi(x,y) can be represented as N2-by-1 vector Xi
- xij is the jth row of
image fi(x,y) . -
- i1,2,,L
66The K-L Transform
- The covariance matrix of vector X is defined as,
- Cf E(X-mf)(X-mf)T
- The mean vector mf is mf EX
- mf is N2-by-1 vector, Cf is N2N2 matrix.
- In generally, mf and Cf can be represented
approximately as,
67The K-L Transform
- Let ei and ?i be the eigenvectors and
eigenvalues of Cf . Where i1,2,,N2, Suppose -
- The K-L transform is g A(X-mf)
68The Properties of the K-L transform
- A)The mean vector of g, mg0
- mg EgEA(X-mg)A EX-A mg0
- B) The covariance matrix of g,
- CgA Cf AT
- Cg E(Y-mg)(Y-mg)T EggT
- E(AX-Amg)(AX-Amg)T
- EA(X-mg)(X-mg)TAT
- AE(X-mg)(X-mg)T AT
- A Cf AT
69The Properties of the K-L transform
- C)Cg is a diagonal matrix having the eigenvalues
of Cg along its diagonal. The elements of g are
uncorrelated. - D) The K-L transform is invertible.The original
image can be reconstructed by - A-1 AT
- f A-1f mf
70K-L???????
- K-L???????????,?????????????(???)????????????,????
??????????? - ????,K-L???????,??????????????????
- ????????,??????,???????,????????????
- ???????????????
71K-L???????
- ?????????????k?????????????Cf??A,??g????k??,??
- ????????????,????????f,?????
- ??????