Image Transforms and Image Enhancement in Frequency Domain
description
Transcript of Image Transforms and Image Enhancement in Frequency Domain
![Page 1: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/1.jpg)
Image Transforms and Image Enhancement in Frequency Domain
Lecture 5, Feb 25th, 2008
Lexing Xie
thanks to G&W website, Mani Thomas, Min Wu and Wade Trappe for slide materials
EE4830 Digital Image Processing http://www.ee.columbia.edu/~xlx/ee4830/
![Page 2: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/2.jpg)
HW clarification HW#2 problem 1
Show: f - r2 f ¼ A f – B blur(f) A and B are constants that do not matter, it is up
to you to find appropriate values of A and B, as well as the appropriate version of the blur function.
Recap for lecture 4
![Page 3: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/3.jpg)
roadmap
2D-DFT definitions and intuitions DFT properties, applications pros and cons DCT
![Page 4: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/4.jpg)
the return of DFT Fourier transform: a
continuous signal can be represented as a (countable) weighted sum of sinusoids.
![Page 5: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/5.jpg)
warm-up brainstorm Why do we need image transform?
![Page 6: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/6.jpg)
why transform? Better image processing
Take into account long-range correlations in space Conceptual insights in spatial-frequency information.
what it means to be “smooth, moderate change, fast change, …”
Fast computation: convolution vs. multiplication
Alternative representation and sensing Obtain transformed data as measurement in radiology
images (medical and astrophysics), inverse transform to recover image
Efficient storage and transmission Energy compaction Pick a few “representatives” (basis) Just store/send the “contribution” from each basis
?
![Page 7: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/7.jpg)
outline why transform 2D Fourier transform
a picture book for DFT and 2D-DFT properties implementation applications
discrete cosine transform (DCT) definition & visualization Implementation
next lecture: transform of all flavors, unitary transform, KLT, others …
![Page 8: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/8.jpg)
1-D continuous FT
real(g(x)) imag(g(x))
1D – FT
1D – DFT of length N
x
=0
=7
x
![Page 9: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/9.jpg)
1-D DFT in as basis expansion
Forward transform
Inverse transform
basis
n
u=0
u=7
real(A) imag(A)
n
![Page 10: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/10.jpg)
1-D DFT in matrix notations
N=8
n
u=0
u=7
real(A) imag(A)
n
![Page 11: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/11.jpg)
1-D DFT of different lengths
N=32
nu
real(A) imag(A)
N=8
N=16 N=64
![Page 12: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/12.jpg)
performing 1D DFT
real-valued input
Note: the coefficients in x and y on this slide are only meant for illustration purposes, which are not numerically accurate.
![Page 13: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/13.jpg)
another illustration of 1D-DFT
real-valued input
Note: the coefficients in x and y are not numerically accurate
![Page 14: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/14.jpg)
from 1D to 2D1D 2
D
?
![Page 15: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/15.jpg)
Computing 2D-DFT
DFT
IDFT
Discrete, 2-D Fourier & inverse Fourier transforms are implemented in fft2 and ifft2, respectively
fftshift: Move origin (DC component) to image center for display Example:
>> I = imread(‘test.png’); % Load grayscale image>> F = fftshift(fft2(I)); % Shifted transform >> imshow(log(abs(F)),[]); % Show log magnitude >> imshow(angle(F),[]); % Show phase angle
![Page 16: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/16.jpg)
2-D Fourier basis
imagreal
real( ) imag( )
![Page 17: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/17.jpg)
2-D FT illustrated
imag
real
real-valued
![Page 18: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/18.jpg)
notes about 2D-DFT Output of the Fourier transform is a complex number
Decompose the complex number as the magnitude and phase components
In Matlab: u = real(z), v = imag(z), r = abs(z), and theta = angle(z)
![Page 19: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/19.jpg)
Explaining 2D-DFT
fft2
ifft2
![Page 20: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/20.jpg)
![Page 21: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/21.jpg)
circular convolution and zero padding
![Page 22: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/22.jpg)
zero padded filter and response
![Page 23: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/23.jpg)
zero padded filter and response
![Page 24: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/24.jpg)
observation 1: compacting energy
![Page 25: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/25.jpg)
observation 2: amplitude vs. phase
Amplitude: relative prominence of sinusoids Phase: relative displacement of sinusoids
![Page 26: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/26.jpg)
another example: amplitude vs. phase
Adpated from http://robotics.eecs.berkeley.edu/~sastry/ee20/vision2/vision2.html
A = “Aron”
P = “Phyllis”
log(abs(FA)) log(abs(FP))
angle(FA) angle(FP)
ifft2(abs(FA), angle(FP))
FA = fft2(A) FP = fft2(P)
ifft2(abs(FP), angle(FA))
![Page 27: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/27.jpg)
fast implementation of 2-D DFT 2 Dimensional DFT is separable
1D FFT: O(N¢log2N) 2D DFT naïve implementation: O(N4) 2D DFT as 1D FFT for each row and then
for each column
1-D DFT of f(m,n) w.r.t n
1-D DFT of F(m,v) w.r.t m
![Page 28: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/28.jpg)
Implement IDFT as DFT
DFT2
IDFT2
![Page 29: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/29.jpg)
Properties of 2D-DFT
![Page 30: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/30.jpg)
![Page 31: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/31.jpg)
duality result
![Page 32: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/32.jpg)
outline why transform 2D Fourier transform
a picture book for DFT and 2D-DFT properties implementation applications
discrete cosine transform (DCT) definition & visualization implementation
![Page 33: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/33.jpg)
DFT application #1: fast Convolution
? ?O(N2)
Spatial filtering
?f(x.y)*h(x.y)
![Page 34: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/34.jpg)
DFT application #1: fast convolution
O(N2¢log2N) O(N2¢log2N)O(N2)
Spatial filtering
O(N4)f(x.y)*h(x.y)
![Page 35: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/35.jpg)
DFT application #2: feature correlation Find letter “a” in the following image
bw = imread('text.png'); a = imread(‘letter_a.png'); % Convolution is equivalent to correlation if you rotate the convolution kernel by 180degC = real(ifft2(fft2(bw) .*fft2(rot90(a,2),256,256)));
% Use a threshold that's a little less than max.% Display showing pixels over threshold.
thresh = .9*max(C(:)); figure, imshow(C > thresh)
from Matlab image processing demos.
![Page 36: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/36.jpg)
DFT application #3: image filters Zoology of image filters
Smoothing / Sharpening / Others Support in time vs. support in frequency
c.f. “FIR / IIR” Definition: spatial domain/frequency domain Separable / Non-separable
![Page 37: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/37.jpg)
smoothing filters: ideal low-pass
![Page 38: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/38.jpg)
butterworth filters
![Page 39: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/39.jpg)
Gaussian filters
![Page 40: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/40.jpg)
low-pass filter examples
![Page 41: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/41.jpg)
smoothing filter application 1
text enhancement
![Page 42: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/42.jpg)
smoothing filter application 2beautify a photo
![Page 43: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/43.jpg)
high-pass filters
![Page 44: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/44.jpg)
sobel operator in frequency domain
Question:Sobel vs. other high-pass filters?Spatial vs frequency domain implementation?
![Page 45: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/45.jpg)
high-pass filter examples
![Page 46: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/46.jpg)
outline why transform 2D Fourier transform
a picture book for DFT and 2D-DFT properties implementation applications in enhancement, correlation
discrete cosine transform (DCT) definition & visualization implementation
![Page 47: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/47.jpg)
Is DFT a Good (enough) Transform? Theory
Implementation
Application
![Page 48: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/48.jpg)
The Desirables for Image Transforms Theory
Inverse transform available Energy conservation (Parsevell) Good for compacting energy Orthonormal, complete basis (sort of) shift- and rotation invariant
Implementation Real-valued Separable Fast to compute w. butterfly-like
structure Same implementation for forward and
inverse transform Application
Useful for image enhancement Capture perceptually meaningful
structures in images
DFT
???X X ?X Xx X X X
X X
![Page 49: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/49.jpg)
DFT vs. DCT1D-DFT
real(a) imag(a)
n=7
u=0
u=7
u=0
u=7
1D-DCT
a
![Page 50: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/50.jpg)
1-D Discrete Cosine Transform (DCT)
Transform matrix A a(k,n) = (0) for k=0 a(k,n) = (k) cos[(2n+1)/2N] for k>0
A is real and orthogonal rows of A form orthonormal basis A is not symmetric! DCT is not the real part of unitary DFT!
Nk
N
NknkkZnz
NknknzkZ
N
k
N
n
2)(,1)0(
2)12(cos)()()(
2)12(cos)()()(
1
0
1
0
![Page 51: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/51.jpg)
1-D DCT
k
Z(k)
Transform coeff.
1.0
0.0
-1.0
1.0
0.0
-1.0
1.0
0.0
-1.0
1.0
0.0
-1.0
1.0
0.0
-1.0
1.0
0.0
-1.0
1.0
0.0
-1.0
1.0
0.0
-1.0
Basis vectors
100
0
-100
100
0
-100
100
0
-100
100
0
-100
100
0
-100
100
0
-100
100
0
-100
100
0
-100u=0
u=0 to 1
u=0 to 4
u=0 to 5
u=0 to 2
u=0 to 3
u=0 to 6
u=0 to 7
Reconstructions
n
z(n)
Original signal
![Page 52: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/52.jpg)
DFT and DCT in Matrix NotationsMatrix notation for 1D transform
1D-DFT
real(A) imag(A)
1D-DCT
AN=32
![Page 53: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/53.jpg)
From 1D-DCT to 2D-DCT
n=7
u=0
u=7
Rows of A form a set of orthonormal basis A is not symmetric! DCT is not the real part of unitary DFT!
![Page 54: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/54.jpg)
basis images: DFT (real) vs DCT
![Page 55: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/55.jpg)
Periodicity Implied by DFT and DCT
![Page 56: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/56.jpg)
DFT and DCT on LenaDFT2 DCT2
Shift low-freq to the center
Assume periodic and zero-padded …
Assume reflection …
![Page 57: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/57.jpg)
Using FFT to implement fast DCT Reorder odd and even elements
Split the DCT sum into odd and even terms
12
0for )12()1(~
)2()(~
Nn
nznNznznz
)(~)(Re
)(~)(Re 2
)14(cos)(~)(
2)1'44(cos)'(~
2)14(cos)(~)(
2)34(cos)1(~
2)14(cos)(~)(
2)34(cos)12(
2)14(cos)2()()(
2/
1
0
/22/1
0
1
2/'
12/
0
12/
0
12/
0
12/
0
12/
0
NNkj
N
n
NnkjNkjN
n
N
Nn
N
n
N
n
N
n
N
n
N
n
nzDFTek
enzekN
knnzk
NknNnz
Nknnzk
NknnNz
Nknnzk
Nknnz
NknnzkkZ
![Page 58: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/58.jpg)
The Desirables for Image Transforms Theory
Inverse transform available Energy conservation (Parsevell) Good for compacting energy Orthonormal, complete basis (sort of) shift- and rotation invariant
Implementation Real-valued Separable Fast to compute w. butterfly-like
structure Same implementation for forward and
inverse transform Application
Useful for image enhancement Capture perceptually meaningful
structures in images
DFT
???X X ?X Xx X X X
X X
DCTX X ?X XX X X X
![Page 59: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/59.jpg)
Summary of Lecture 5 Why we need image transform DFT revisited
Definitions, properties, observations, implementations, applications
What do we need for a transform DCT
Coming in Lecture 6: Unitary transforms, KL transform, DCT examples and optimality for DCT and KLT, other transform flavors,
Wavelets, Applications Readings: G&W chapter 4, chapter 5 of Jain has been posted
on Courseworks
“Transforms” that do not belong to lectures 5-6:Rodon transform, Hough transform, …
![Page 60: Image Transforms and Image Enhancement in Frequency Domain](https://reader035.fdocuments.net/reader035/viewer/2022062218/5681675c550346895ddc2843/html5/thumbnails/60.jpg)