CIS303 Advanced Forensic Computing - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

CIS303 Advanced Forensic Computing

Description:

... are based on the work of Jean Baptiste Joseph Fourier. ... the mean grey level in ... are needed to represent changes in grey level across the image. ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 37
Provided by: osirisSun
Category:

less

Transcript and Presenter's Notes

Title: CIS303 Advanced Forensic Computing


1
CIS303Advanced Forensic Computing
  • Dr Giles Oatley

2
The frequency domain
  • Working in the frequency domain gives many more
    opportunities for the image analyst. To convert
    an image between the spatial and the frequency
    domain we use the Fourier transform. This is
    practical because of the Fast Fourier Transform
    algorithm (FFT). Two principle areas of
    application are filtering and focus correction.
  • Sub topics
  • Frequency information in the image
  • Fourier components in 1 and 2 dimensions
  • Applying the FFT in MatLab
  • Low and high pass filters
  • Focus correction

3
Frequency in an image
4
Basic definitions
5
Fourier Series
  • Techniques for the analysis and manipulation of
    spatial frequency are based on the work of Jean
    Baptiste Joseph Fourier.
  • The key idea is that any periodic function,
    however complex, can be represented as a sum of
    sines and cosines.
  • Thus, for a function with period L
  • The set of sine and cosine functions are known as
    the basis functions.
  • A weighted sum of these basis functions is known
    as a Fourier Series.
  • The weighting factors an and bn are the Fourier
    coefficients.

6
Fourier Coefficients
7
The frequency components in a square wave
function Squarewave(n) To calculate display up
to n terms of a Fourier series if ngt50 n
50 end x 0pi/1002pi total 0 for J
0n-1 K 2J1 total total
sin(Kx)/K end y 0.5 2total/pi plot(x,y
) titlestring int2str(n),' Terms' title(titl
estring)
8
Square wave reconstruction
9
The Fourier spectrum for the square wave
10
Extension to two dimensions
  • In two dimensions, the basis functions are 2D
    sine and cosine functions.
  • A Fourier series of a 2D function f(x,y) can be
    written as follows
  • Where u and v are the number of cycles fitting
    into one horizontal and vertical period,
    respectively.
  • This Fourier series can be used to represent any
    image and we can visualise the basis functions as
    basis images.
  • If u0 and v0, the basis image is constant, with
    value a00. The is the mean grey level in the
    image.
  • Higher terms in u and v introduce the
    fluctuations about this mean level that are
    needed to represent changes in grey level across
    the image.

11
Fourier reconstruction in two dimensions
12
The Discrete Fourier Transform (DFT)
  • Fourier theory provides us with a means of
    determining the contribution made by any basis
    function to the representation of some function
    f(x).
  • The contribution is determined by projecting f(x)
    onto that basis function. This procedure is known
    as a Fourier transform (FT).
  • The FT is a generalization of the Fourier series.
    Instead of sines and cosines, as in a Fourier
    series, the Fourier transform uses exponentials
    and complex numbers.
  • When applying the procedure to images, we must
    deal explicitly with the fact that the image is
  • Two-dimensional.
  • Sampled.
  • Of finite extent.
  • These considerations give rise to the Discrete
    Fourier Transform (DFT).

13
Why do we need it?
  • The projection allows us to reconstruct the
    signal as a sum of exponentials!
  • Why is this good? Complex exponentials are
    sinusoids. Most significantly, the operation of
    filtering is very simple once we are in the
    frequency domain - in order to change the amount
    of a certain frequency which is in a signal, we
    just multiply that coefficient by a constant.
  • Thus, DFT is a convenient way of breaking down a
    signal into its frequency components. Best of
    all, efficient algorithms (called Fast Fourier
    Transforms, or FFTs) exist to compute the DFT,
    which allow us to perform efficient filtering by
    taking the DFT, multiplying the frequency
    coefficients, and then reconstructing the signal
    (i.e. taking the inverse DFT.)

14
DFT of an N x N image
Or, (since cos(?)jsin(?) can be written in
exponential form)
Note that F(u,v) is a complex number we are now
dealing with a set of complex coefficients,
rather than two sets of real coefficients, as was
the case with the Fourier series shown on a
previous slide.
15
Notes on the DFT
  • For any particular spatial frequency specified by
    u and v, evaluating the previous equations gives
    us the contribution that the corresponding pair
    of basis images makes to the image.
  • In other words, it tells us how much of that
    particular frequency is present in the image f.
  • To build up a complete picture of the relevant
    importance of different frequencies, we must
    evaluate the equation for all u and v.
  • There also exists an inverse Fourier Transform
    given by

16
More about the DFT/inverse DFT
  • The only essential difference between the DFT and
    the inverse DFT is the sign of the exponent.
  • The forward transform on an NxN image yields an
    NxN array of coefficients.
  • Since the inverse transform reconstructs the
    original image from this set of coefficients,
    they must constitute a complete representation of
    the information available in the image.
  • When we manipulate f(x,y), we say we are
    processing the image in the spatial domain.
  • When we manipulate F(u,v), we say we are
    processing the image in the frequency domain.
  • The transformation from one domain to another
    does not, in itself, result in any information
    loss.

17
The spectra of an image
F(u,v) is a complex number, with real and
imaginary parts. We can thus define the magnitude
and phase of F(u,v)
Thus, magnitude and phase are given by
18
Amplitude and phase spectra
  • The previous equations allow us to decompose an
    array of complex coefficients into arrays of
    magnitudes and phases.
  • Magnitudes amplitudes of the basis images in
    the Fourier representation.
  • Array of magnitudes is the amplitude spectrum.
  • Array of phases is the phase spectrum.
  • When we talk about the spectrum, we normally
    mean the amplitude spectrum, which is more
    significant in terms of interpretation. However,
    both are needed to reconstruct an image from the
    frequency to the spatial domain.
  • Another term used is the power spectrum, or
    spectral density

19
Log amplitude
  • Note that the dynamic range of Fourier spectra is
    usually much higher than that of a typical
    display device, so that only the brightest parts
    of the image are visible on the display screen.
  • To compensate for this we often display the
    following

Where c is a scaling constant and the logarithmic
function performs the desired compression. This
greatly facilitates visual analysis of Fourier
spectra.
20
Example
Using phase only
21
Fast Fourier transform (FFT)
  • Calculating a single value of F(u,v) involves a
    summation over all pixels in the image.
  • For an NxN image, the number of complex
    multiplications and additions for a DFT is
    proportional to N2.
  • Assuming that the multiplication of a complex
    number takes 1µs, it would take 71 minutes to
    compute the FFT of a 256x256 image, 12 days for a
    1024x1024 image.
  • Fortunately, a much faster method exists the
    Fast Fourier Transform, or FFT.
  • The 2-D FFT algorithm takes advantage of the
    separability of the Fourier transform, which
    allows us to perform a 1-D FFT along each row of
    the image, followed by another 1-D FFT down each
    column.
  • The FFT also uses the fact that a Fourier
    transform of length N can be written as the sum
    of two Fourier transforms of length N/2.

22
Advantage of FFT
Overall cost of FFT procedure is Nlog2N
operations, compared to N2.
N N2 Nlog2N Ratio N2/Nlog2N
64 4,096 384 11
256 65,536 2,048 32
1024 1,048,576 10,240 102
4096 16,777,216 49,152 341
23
Steps to display a Fourier transform
24
Using the FFT
  • The transform works most efficiently when the
    image dimensions are powers of 2 (e.g. 128, 256
    etc.). It will however work with other
    dimensional ranges.
  • It generates an amplitude and phase for each
    frequency component. Both are equally important
    but usually only the amplitude component is
    displayed because the phase is difficult to
    interpret visually.
  • As an alternative to amplitude and phase the
    transform can be expressed as a set of complex
    numbers Z X iY. In this case it is usually
    the intensity which displayed.
  • The transform is a periodic function of which
    only one cycle is displayed. The transform also
    assumes that the original image is periodic with
    only one cycle visible. Occasionally this can
    cause unwanted artefacts on the processed image.
  • Left by itself the FFT will produce a graph in
    which the zero frequency appears in the corners
    and the highest frequency in the centre. MATLAB
    provides a simple function to rectify this.

25
Demonstration FFT in MatLab
function FFTDemo(SW) To demonstrate the 2D Fast
Fourier Transform SW is the width (pixels) of a
white stripe in a 256 x 256 square A
zeros(256,256) if SW gt 50 SW 50 end LL
128 - round(SW/2) UL 128
round(SW/2) A(1255,LLUL) 1 subplot(1,2,1),
imshow(A) F fft2(A) F1 fftshift(F) F2
abs(F1) subplot(1,2,2), imshow(F2,-1
8,'notruesize') colormap(jet)
colorbar improfile
26
A thin line and its FFT
27
A small square and its FFT
28
Link between spatial and frequency domains
  • Two Fourier transform relationships that
    constitute a basic link between the spatial and
    frequency domains are convolution and
    correlation.
  • They are of fundamental importance to
    understanding image processing techniques based
    upon the Fourier transform.
  • For any computer-based system, increasing the
    kernel size for the above operations soon means
    it is more efficient to perform the operations in
    the Fourier domain.
  • i.e. the time needed to perform the FFT
    transformations from the spatial to the frequency
    domain and back is shorter than that needed to
    perform the operations in the spatial domain.

29
Convolution in the frequency domain
  • The equivalent to spatial domain convolution is a
    single multiplication of each pixel in the
    magnitude image by the corresponding pixel in a
    transform of the kernel.
  • Thus, convolution in the spatial domain is
    exactly equivalent to multiplication in the
    frequency domain.

The main application is in filtering. Note that
in correlation, a similar relationship exists i.e.
The main application of correlation is in
template matching.
30
Steps for filtering in the frequency domain
31
Low pass filters
32
Examples of Butterworth low pass filters
C 50 n 5
C 50 n 1
33
Demonstration program part 1
function MothDemo(cutoff,order) To demonstrate
the 2D Fast Fourier Transform on a real object A
imread('moth9.gif') B double(A)/255 subplot(
2,2,1), imshow(B) Calculate and display its
Fourier transform F fft2(B) F1
fftshift(F) F2 abs(F1) subplot(2,2,2)
imshow(F2,-1 32)colormap(gray) Get the image
size row col size(B)
34
Demonstration program part 2
Now define the appropriate Butterworh
Filter bwlpf zeros(row,col) centre_row
round(row/2) centre_col round(col/2) for v
1col for u 1row bwlpf(u,v) 1 / (1
(sqrt((u-centre_row)2 (v-centre_col)2)/cutoff)
(2order)) end end bwlpf fftshift(bwlpf) su
bplot(2,2,3) imshow(bwlpf) F F .
bwlpf F_lpf real(ifft2(F)) subplot(2,2,4)
imshow(F_lpf)
35
Results on the moth image
36
The high pass filter
C 50 n 1
C 50 n 5
Write a Comment
User Comments (0)
About PowerShow.com