Upcoming SlideShare
×

# Image transforms

26,465 views

Published on

This slide show gives a knowledge regarding various image transforms.

28 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Njce! Thanks for sharing.

Are you sure you want to  Yes  No
• VERY GOOD MATERIAL SIR

Are you sure you want to  Yes  No
• nice presentn

Are you sure you want to  Yes  No
• Perhaps the Best possible! Thanks a lot

Are you sure you want to  Yes  No
• Thanks Mangesh! :)

Are you sure you want to  Yes  No
Views
Total views
26,465
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
1,634
6
Likes
28
Embeds 0
No embeds

No notes for slide

### Image transforms

1. 1. DIGITAL IMAGE PROCESSING UNIT-2IMAGE TRANSFORMS by Paresh Kamble
2. 2. IntroductionWhat is Image Transform? Transform IMAGE ANOTHER IMAGE NXN NXN Inverse Transform Coefficient Matrix
3. 3. Introduction• Applying Transform we get another image of same size.• After applying Inverse Transform we get the original image back.• Then what is the use of Image Transformation?
4. 4. IntroductionApplications: Preprocessing - Filtering - Enhancement, etc Data Compression Feature Extraction - Edge Detection - Corner detection, etc
5. 5. IntroductionWhat does the Image Transform do?It represents the given image as a series summation of a set of Unitary Matrices.What is a Unitary Matrix?A Matrix ‘A’ is a unitary matrix if A-1 = A*T where A* is conjugate of A Unitary Matrix --------> Basis Functions
6. 6. IntroductionAn arbitrary continuous signal x(t) can be represented by a series summation of set of orthogonal basis functions.The series expansion is given as: ∞x(t) = Σ cn an(t) infinite series expansion n=0^ N-1x(t) = Σ cn an(t) finite series expansion n=0It gives an approximate representation of x(t).
7. 7. IntroductionIn discrete signalsWe have a series of 1D sequence of samples represented by: ,u(n) ; 0 ≤ n ≤ N-1}We have N number of samples, so we represent this set by a vector ‘u’ of dimension ‘N’.For transformation:We pre-multiply this matrix u by unitary matrix of dimension NxN. v= A.u Where, v -> transformed vector A -> Transformed matrix
8. 8. IntroductionAfter expansion: N-1v(k) = Σ a(k, n) u(n) ; k = 0, 1, ……..N-1 n=0If vector ‘A’ is an unitary matrix we can get back our original vector ‘u’So pre-multiplying v by A-1u = A-1v = A*TvRepresenting above equation in the form of a series summation, N-1u(n) = Σ a*(k, n) v(k) ; n = 0, 1, ……..N-1 n=0
9. 9. IntroductionExpanding matrix a(k, n), it is of the form, *a(0, 0) a(0, 1) a(0, 2) ….a(0, n)+a(k, n) = *a(1, 0) a(1, 1) a(1, 2) …. + *a(2, 0) a(2, 1) a(2, 2) …. + * ….. + [a(k, 0) a(k, n) ]a*(k, n) is the column vector of matrix A*TThese column vectors are usually called the basis vectors of A. N-1u(n) = Σ a*(k, n) v(k) ; n = 0, 1, ……..N-1 n=0Where, u(n) is series summation of basis vectors
10. 10. IntroductionThe concept of representing the vector as a series summation of basis vectors can be expanded to 2D signals(image) as wellConsider any image u(m, n) ; 0 ≤ m, n ≤ N-1 of dimension N x N.Transformation on this image is given by: N-1v(k, l) = Σ ak, l(m, n) u(m, n) 0 ≤ k, l ≤ N-1 m, n = 0Thus, we have N2 number of unitary matrices. N-1u(m, n) = Σ a*k, l(m, n) v(k, l) 0 ≤ m, n ≤ N-1 k, l = 0V = {v(k, l)} is the transform coefficient.
11. 11. IntroductionDuring Inverse Transformation if all coefficients are not considered then an approximate reconstructed image will be generated.^ P-1 Q-1u = Σ Σ v(k, l) a*k, l(m, n) k=0 l=0So, we are considering only P x Q coefficients instead of N2.The sum of squared error will be given by: N-1 ^ € 2= Σ Σ [u(m, n) – u(m, n)]2 m, n = 0This error will be minimized if the set of basis images ak,l(m, n) is complete.Computations required : O(N4)
12. 12. IntroductionTo reduce Computational Complexity:We have to make use of separable unitary transforms ak,l(m, n) is separable if it can be represented in the form ak,l(m, n) = ak(m) . bl(n) ≈ a(k, m) b(l, n)where, { ak(m), k=0, 1, ….N-1} { bl(n), l = 0, 1, …..N-1}they are set of complete orthogonal set of basis vectors.If we represent A ≈ ,a(k, m)- & B ≈ ,b(l, n)- in the form of matrices then both should be unitary so that AA*T = ATA* = IIf this is correct then we say that the transformation is a separable transformation.
13. 13. IntroductionUsually we assume both the matrices A & B to be same.Then the transformation equation changes to N-1v(k, l) = Σ Σ a(k, m) u(m, n) a(l, n) m,n = 0In terms of matrices it is given by:V = AUAT where all the matrices are f the order of N x NBy applying inverse transformation we will have he original matrix from the coefficient matrix.Similarly, inverse transformation can now be written as: N-1u(m, n) = Σ Σ a*(k, m) v(k, l) a*(l, n) k,l = 0U = A*TVA*They are 2D separable transformations.
14. 14. IntroductionV = AUATVT = A[AU]TBy general matrix arithmetic, we knowif two matrices A & U of order N x N when multiplied requires O(N3) computations.Thus it takes O(2N3) computations over all instead of O(N4) when separable transform are not considered.
15. 15. Basis ImagesSuppose if a* denotes kth column of A*T. k If the matrix is defined asA* = a* a*T k, l k lwhere, a* is kth column of A*T lWe can have N-1u(m, n) = ΣΣ v(k,l) a*k,l(m, n) k, l =0
16. 16. Basis ImagesIn matrix form, N-1 U = ΣΣ v(k,l) A*k,l k, l =0It can be observed that our original image matrix now is represented by a linear combination of N square matrices A*k,lwith each having dimension of N x N.The matrices A*k,l is known as the basis images.The aim of transform is to represent the input image in the form of linear combination of a set of basis images.
17. 17. Basis ImagesDFT basis function:
18. 18. Basis ImagesDCT Basisimages
19. 19. Basis ImagesBasis images
20. 20. Basis ImagesEx. 1) A = (1/√2)*1 1+ U = *1 2+ [1 -1] [3 4]V = (½) [1 1][1 2][1 1] [1 -1][3 4][1 -1] = (½) [4 6][1 1] [-2 -2][1 -1] = [5 -1] [-2 0]Basis Images: A* k,l = a*k . a*lA*00 = (½)[1][1 1] = (½)[1 1; 1 1] [1]A*01 = A*10 = (½)[1 -1; 1 -1]A*11 = (½)[1 -1; -1 1]
21. 21. Discrete Fourier TransformAssume f(x) to be a continuous function of some variable x.Then FT of the variable f(x) is given by ∞F,f(x)- = F(u) = ∫ f(x) e-j2πux dx -∞ where, u is the frequency term.Requirement of the function:(i) Function must be continuous.(ii) Function must be integrable.Similarly, IFT is found by ∞F-1,F(u)- = f(x) = ∫ F(u) ej2πux du But F(u) must be integrable. -∞
22. 22. Discrete Fourier TransformF(u) is in general a complex functionIt can therefore be broken down into real & imaginary parts.F(u) = R(u) + jI(u) => |F(u)| ejø(u) where, |F(u)| = [R2(u) + I2(u)]1/2 is Fourier spectrum of f(x); ø = tan-1{I(u)/R(u)} is the phase angle & P(u) = |F(u)|2 = R2(u) + I2(u) is the power spectrum.
23. 23. Discrete Fourier Transform2D Fourier Transform of a continuous signal f(x, y) is given by: ∞ F(u, v) = ∫ ∫ f(x, y) e-j2π(ux + vy) dx dy -∞2D IFT is given below: ∞f(x, y) = ∫ ∫ F(u, v) ej2π(ux + vy) dx dy -∞Where, |F(u, v)| = [R2(u, v) + I2(u, v)]1/2 is Fourier spectrum of f(x, y); ø = tan-1(I(u, v)/R(u, v)) is the phase angle & P(u) = |F(u, v)|2 = R2(u, v) + I2(u, v) is the power spectrum.
24. 24. Discrete Fourier Transformf(x, y) is a 2D signal with magnitude A, then its Fourier Transform is found out. f(x, y) A X x Y y
25. 25. Discrete Fourier Transform ∞ F(u, v) = ∫ ∫ f(x, y) e-j2π(ux + vy) dx dy -∞ X Y =A ∫e-j2πux dx . ∫ e-j2πvy dy 0 0 X Y = A [(e-j2πux)/(-j2πu)]. [(e-j2πvy)/(-j2πv)] 0 0 = AXY [(sin(πux) e-j2πux)/(πux)] [(sin(πvy) e-j2πvy)/(πvy)]Fourier Spectrum of FT:|F(u, v)| = Axy |(sin(πux))/(πux)||(sin(πvy))/(πvy)|
26. 26. Discrete Fourier Transform
27. 27. Discrete Fourier Transform2D DFT of the function g(x, y) of size M x N is expressed as: M-1 N-1 F(u, v) = (1/MN) Σ Σ f(x, y) e-j2π((ux/M)+(vy/N)) --------(1) x=y=0 for, u = 0, 1, 2, ……M-1 v = 0, 1, 2, ……N-1If F(u, v) is given then f(x, y) can be obtained by IDFT M-1 N-1 f(x, y) = Σ Σ F(u, v) ej2π((ux/M)+(vy/N)) ------------(2) u=v=0 for, x = 0, 1, ………M-1 y = 0, 1, ………N-1
28. 28. Discrete Fourier Transform
29. 29. Discrete Fourier TransformProperties of Fourier Transform:1) Separability: N-1 F(u, v) = (1/N) Σ Σ f(x, y) e-j(2π/N)(ux+vy) --------(1) x=y=0 N-1 N-1 = (1/N) Σ e-j(2πux/N) .N.(1/N) Σ f(x, y) e-j(2πvy/N) x=0 y=0 N-1 = (1/N) Σ e-j(2πux/N) .N.F(x, v) x=0 = (1/N) Σ F(x, v) e-j(2πux/N)
30. 30. Discrete Fourier Transform(0,0) N-1 y f(x, y)N-1 x (0, 0) N-1 v xN Row Transformation F(x, v) N-1 (0, 0) N-1 v x F(u, v) Column Transformation N-1 u
31. 31. Discrete Fourier TransformFor Inverse DFT N-1 f(x, y) =(1/N) Σ Σ F(u, v) ej(2π/N)(ux+vy) u=v=0 N-1 N-1 = (1/N) Σ ej(2πux/N) N. (1/N) Σ F(u, v) ej(2πvy/N) u=0 v=0 N-1 = (1/N) Σ N f(u, y) ej(2πux/N) u=0 Row Transformation Column Transformation
32. 32. Discrete Fourier Transform2) Translation Property: For any image f(x, y) if translated by (x0, y0)becomes f(x-x0, y-y0)The translated Fourier Transform is given by:Ft(u, v) = (1/N) Σ Σ f(x-x0, y-y0) e-j(2π/N)(u(x-x0)+v(y-y0)) = (1/N) Σ Σ f(x-x0, y-y0) e-j(2π/N)(ux + vy) ej(2π/N)(ux0 + vy0) = F(u, v) ej(2π/N)(ux0 + vy0)After Translation, the magnitude does not change, it just includes some additional phase difference.Similarly, in IDFT, F(u-u0, v-v0) = f(x, y) ej(2π/N)(u0x + v0y)
33. 33. Discrete Fourier TransformBasics of filtering in Frequency domain:Frequency domain describes the space defined by values of the FT and the frequency variable (u & v).Depending on equation (1) we observe the following salient features:(i) Each term of G(u, v) consists of all values of g(x, y) modified by exponential terms.(ii) We can establish a general connection between frequency component of FT & spatial characteristics of an image.(iii) Slowest varying frequency components (u=v=0) corresponds to the average gray level of the image.
34. 34. Discrete Fourier Transform(iv) As we move away from origin of transform, LF correspond to slowly varying component of an image.(v) As we move further away from origin, the higher frequency begin to correspond to faster & faster gray level changes in image. These are the edges of objects & other components of the images characterized by abrupt changes in gray levels (noise).Filtering in Frequency Domain: Pre Post DFT H(u,v) IDFT processing Processingg(x, y) G(u, v) F(u, v) f(x, y)
35. 35. Discrete Fourier TransformEx. 2) Compute 2D DFT and amplitude spectrum of the following image 5 3 0 2U= 1 7 8 3 4 2 2 2 1 1 1 1 8 5 2 1 F = 1 -j -1 j 1 -1 1 -1 = FT 1 j -1 -j
36. 36. Discrete Fourier Transform3) Periodicity & Conjugate:F(u, v) = F(u, v+N) = F(u+N, v) = F(u+N, v+N) N-1 F(u, v) = (1/N) Σ Σ f(x, y) e-j(2π/N)(ux+vy) x=y=0 N-1 F(u+N, v+N) = (1/N) Σ Σ f(x, y) e-j(2π/N)(ux+vy+Nx+Ny) x=y=0 N-1 = (1/N) Σ Σ f(x, y) e-j(2π/N)(ux+vy) e-j(2π)(x+y) x=y=0 = (1/N) Σ Σ f(x, y) e-j(2π/N)(ux+vy) . 1 = F(u, v)
37. 37. Discrete Fourier TransformConjugate:f(x, y) is realF(u, v) = F*(-u, -v)|F(u, v)| = |F(-u, -v)|
38. 38. Discrete Fourier Transform
39. 39. Discrete Fourier TransformSpectrum obtained by multiplying f(x, y) by (-1)x+y
40. 40. Discrete Fourier Transform4) Rotation: x = r cos θ ; y = r sin θ ; u = ω cos ø ; y = ω sin ø ; ƒ(x, y) => ƒ(r, θ); F(u, v) => F(ω, ø); ƒ(r, θ + θ0)  F(ω, ø + θ0);
41. 41. Discrete Fourier Transform
42. 42. Discrete Fourier Transform5) Distributivity & Scaling:Distributivity:F{f1(x, y) + f2(x, y)} = F{f1(x, y)} + F{f2(x, y)}F{f1(x, y) . f2(x, y)- ≠ F,f1(x, y)} . F{f2(x, y)}True for IDFT also.Scaling: If a & b are scalar quantities.a . f(x, y)  a . F(u, v)ƒ(ax, by)  (1/|ab|) F(u/a , v/b);
43. 43. Discrete Fourier TransformAverage: _ N-1ƒ(x, y) = (1/N2) ΣΣ f(x, y) x, y = 0 N-1F(0, 0) = (1/N) ΣΣ f(x, y) x, y = 0 _ ƒ(x, y) = (1/N) F(0, 0)
44. 44. Discrete Fourier Transform6) Convolution:f(x) . g(x)  F(u) * G(u)f(x) * g(x)  F(u) . G(u)7) Correlation:f(x, y) o g(x, y)  F*(u, v) . G(u, v)f*(x, y) . g(x, y)  F(u, v) o G(u, v)
45. 45. Discrete Fourier TransformFew other properties of DFT:8) It is symmetric.9) It is a fast Transform.10) Its computational capacity is given by N.log2N.11) It has very good compaction for the image.
46. 46. Discrete Cosine TransformIn DCT the forward transformation channel is given by:g(x, y, u, v) = α(u).α(v). cos[(2x+1)uπ/2N]. cos[(2y+1)vπ/2N] = f(x, y, u, v)inverse and forward transformation channel are identical.They are separable as well.Here, α(u) = √(1/N) u=0 √(2/N) u = 1, 2, …..N-1;Similarly the values of α(v) can be found.
47. 47. Discrete Cosine TransformDCT Basis Images
48. 48. Discrete Cosine TransformForward DCT: N-1C(u, v) = α(u).α(v) ΣΣ {f(x, y) cos[(2x+1)uπ/2N]. cos[(2y+1)vπ/2N]} x, y = 0Reverse DCT: N-1f(x, y) = ΣΣ {α(u).α(v) C(u, v) cos[(2x+1)uπ/2N]. cos[(2y+1)vπ/2N]} u, v = 0In DCT, energy is concentrated in a small region.It helps in image compression.
49. 49. Discrete Cosine Transform
50. 50. Discrete Cosine TransformProperties of DCT:(1) It is real orthogonal. C = C* => C-1 = CT(2) It is fast transform.(3) It can be calculated in Nlog2N operations via N-point transform.(4) It is good for energy compaction for highly correlated data.(5) It can be used for designing transform code & wiener filter.(6) It is near substitute for Hotelling & KL transform.(7) It is used for JPEG compression.
51. 51. Discrete Cosine TransformThe NxN cosine transform matrix C = {C(k, n)} also called the DCT is defined as C(k, n) = 1/√N; k = 0; 0 ≤ n ≤ N-1 = √(2/N).cos((π(2n+1)k)/2N); 1 ≤ k ≤ N-1; 0 ≤ n ≤ N-1Ex. 3) Find the 2D DCT matrix for N = 4.
52. 52. Discrete Cosine TransformSol: C = kn 0 1 2 3 0 0.5 0.5 0.5 0.5 1 0.65 0.27 -0.27 -0.65 2 0.5 -0.5 -0.5 0.5 3 0.27 -0.65 0.65 -0.27Ex. 4) Compute 2D DCT of the following image for N = 4 5 3 0 2U=1 7 8 3 4 2 2 2 8 5 2 1 V=?
53. 53. Discrete Sine TransformThe N x N Discrete Sine Transform is given by matrix ψ = {ψ(k, n)}ψ(k, n) = √(2/(N+1)) sin (π{(k+1)(n+1)/(N+1)}), for 0 ≤ k; n ≤ N – 1Properties:(1) It is symmetrical, real & orthogonal. ψ = ψT, ψ = ψ*, ψT = ψ-1.(2) It is faster than DCT.(3) It is calculated by N log2N via 2(N+1) point FFT.(4) It has very good energy compression property for images.(5) It is used for estimating performances in digital image processing problems.
54. 54. Discrete Sine TransformFor N = 4 the Discrete Sine Transform matrix is given by: n 0 1 2 3Ψ= k 0 0.37 0.6 0.6 0.37 1 0.6 0.37 -0.37 -0.6 2 0.6 -0.37 -0.37 0.6 3 0.37 -0.6 0.6 -0.37
55. 55. WalshTransform1D Walsh Transform kernel is given by: n-1g(x, u) = (1/N) ∏ (-1) bi(x) bn-1-i(u) i=0where, N – no. of samples n – no. of bits needed to represent x as well as u bk(z) – kth bits in binary representation of z.Thus, Forward Discrete Walsh Transformation is given by: N-1 n-1W(u) = (1/N) Σ f(x) ∏ (-1) bi(x) bn-1-i(u) x=0 i=0
56. 56. WalshTransform1D Inverse Walsh Transform kernel is given by: n-1h(x, u) = ∏ (-1) bi(x) bn-1-i(u) i=0Thus, Inverse Discrete Walsh Transformation is given by: N-1 n-1f(x) = Σ W(u) ∏ (-1) bi(x) bn-1-i(u) u=0 i=0Thus, both the transforms are identical except the factor of (1/N). Same algorithm is used to perform forward and inverse transformation.
57. 57. WalshTransform2D signals:Forward Transformation kernel is given by: N-1g(x, y, u, v) = (1/N) ∏ (-1) {bi(x) bn-1-i(u) + bi(y) bn-1-i(v)} i=0Inverse Transformation kernel is given by: N-1h(x, y, u, v) = (1/N) ∏ (-1) {bi(x) bn-1-i(u) + bi(y) bn-1-i(v)} i=0
58. 58. WalshTransform2D Forward Walsh Transform is given by N–1 N-1W(u, v) = (1/N) ΣΣ f(x, y) ∏ (-1) {bi(x) bn-1-i(u) + bi(y) bn-1-i(v)} x, y= 0 i=0 N–1 N-1f(x, y) = (1/N) ΣΣ W(u, v) ∏ (-1) {bi(x) bn-1-i(u) + bi(y) bn-1-i(v)} u, v= 0 i=0Here, the algorithm used for calculating the forward transformation is used for calculating the inverse transformation.
59. 59. WalshTransformBasis Function for Walsh Transformation:
60. 60. WalshTransformWalsh Transformation applied on image:
61. 61. WalshTransformProperties :(1)The transform is separable and symmetric.(2)The coefficients near origin have maximum energy and it reduces as we go further away from the origin.(3)It has energy compaction property but NOT so strong as in DCT.
62. 62. WalshTransformTransformation kernelG = (1/N) 0 1 2 3 4 5 6 7 Seq + + + + + + + + 0 + + + + - - - - 1 + + - - + + - - 3 + + - - - - + + 2 + - + - + - + - 7 + - + - - + + - 6 + - - + + - - + 4 + - - + - + + - 5
63. 63. WalshTransformProb. 2) Find the Walsh Transformation kernel G and then find output for the given image. 1 2 3 4F= 4 1 2 3 1 4 2 3 1 2 4 3For N = 4 + + + + G = (1/4) + + - - + - + - + - - +
64. 64. Hadamard Transform1D Forward Transformation kernel is given by: n -1g(x, u) = (1/N) (-1) Σ bi(x) bi(u) i=0 N-1 n-1H(u) = (1/N) Σ f(x) (-1) Σ bi(x) bi(u) x=0 i=01D Inverse Transformation kernel is given by: n-1h(x, u) = (-1) Σ bi(x) bi(u) i=0 N -1 n-1f(x) = Σ H(u) (-1) Σ bi(x) bi(u) u=0 i=0
65. 65. Hadamard Transform2D Forward Transformation kernel is given by: n -1g(x, y, u, v) = (1/N) (-1) Σ {bi(x) bi(u) + bi(y) bi(v)} i=02D Inverse Transformation kernel is given by: n-1h(x, y, u, v) = (1/N) (-1) Σ {bi(x) bi(u) + bi(y) bi(v)} i=0Hadamard Transformation are separable and symmetric. 2D Hadamard Transformation can be implemented assequence of 1D Hadamard Transformation.
66. 66. Hadamard Transform1D hadamard Transform is given by: n -1g(x, u) = (1/N) (-1) Σ bi(x) bi(u) i=0If the term 1/N is neglected then it forms a Hadamard Matrix.
67. 67. Hadamard TransformAnalyzing Hadamard Matrix further: If we analyze the number of sign changes along a particularcolumn.It shows no straight forward relation between the no of signchanges and the values of u.In DFT & DCT we have such direct relationship between u andthe frequency.If we want similar relation in HM then we need some sort ofreordering.This reordering can be obtained by another transformation.
68. 68. Hadamard TransformIt is possible to formulate a recursive relation to formulate theHadamard matrix.To generate the recursive relation we consider a Hadamardmatrix of lowest order of N = 2.H2 = [1 1] [1 -1]Thus, a Hadamard matrix of order 2N can be obtained from aHM of order N by:H2N = [HN HN] [HN H-N]Thus, HM of higher order can be formed from a HM of lowerdimension.
69. 69. Hadamard TransformKernel of such modified transformation is given by: n-1g(x, u) = (1/N) (-1) Σ bi(x) pi(u) i=0where, p0(u) = bn-1(u)p1(u) = bn-1(u) + bn-2(u)p2(u) = bn-2(u) + bn-3(u)- -- -- -pn-1(u) = b1(u) + b0(u)