The document discusses digital image processing and two-dimensional transforms. It provides an agenda that covers two-dimensional mathematical preliminaries and two transforms: the discrete Fourier transform (DFT) and discrete cosine transform (DCT). It then discusses the DFT and DCT in more detail over several pages, covering properties, examples, and applications such as image compression.
Two Dimensional Mathematical Preliminaries ImageTransforms Many times, image processing tasks are best performed in a domain other than the spatial domain. Key steps: (1) Transform the image (2)Carry the task(s) in the transformed domain. (3)Apply inverse transform to return to the spatial domain First Video
3.
Fourier Series Theorem Anyperiodic function f(t) can beexpressed as aweighted sum (infinite) of sine and cosine functions of varying frequency is called the “fundamentalfrequency
Discrete Cosine Transform A discrete cosine transform (DCT) expresses a finite sequence of data points in terms of a sum of cosine functions oscillating at different frequencies. DCT is a Fourier-related transform similar to the discrete Fourier transform (DFT), but using only real numbers. DCTs are equivalent to DFTs of roughly twice the length, operating on real data with even symmetry. Types of DCT listed below with 11 samples.
Fourier Transform For agive function g(x) of a real variable x, the Fourier transformation of g(x) which is denoted as j2ux - {g(x)} G(u) g(x)e dx - 1 {g(x)} G(u) g(x)e dxj2ux Second Video
Discrete Fourier Transform •Letus discretize a continuous function f(x) into the N uniform samples that generate the sequence f(x0), f(x0+Δx), f(x0+2Δx), f(x0+3Δx), …, f(x0+[N-1]Δx) •Hence f(x) = f(x0+i Δx) •We could denote the samples as f(0), f(1), f(2), …,f(N-1). x0 and 0,1,2,..., N 1 N 1 1 f(x)e j 2ux / N ;u N • The Fourier Transform is F (u) N1 Third Video - Examples f (x) F(u)e j2ux/ N u0
15.
NM 2D Discrete FourierTransform 1 M 1N 1 F(u,v) f (x, y)e j2 (ux/ M vy / N ) x0 y 0 u 0,1,2,...,M 1;v 0,1,2,...,N 1 and M 1N1 1 1 f (x, y) F(u,v)ej2 (ux/ M vy / N ) u 0 v0 Mx Ny u ; v
Properties of 2DFourierTransform • Spatial and Frequency Domain f(t, z) sampled from f(x, y) using the separation between samples as T and Z NZ v MT 1 u 1 • Translation and Rotation Multiplying f(x,y) by the exponential shifts the original of DFT to (u0,v0). Multiplying F(u,v) by the exponential shifts the original of f(x, y) to (x0,y0); f (x x , y y ) F (u, v)e j 2 ( x0u / M y0v / N ) 0 0 F (u u , v v ) f (x, y)e j 2 (u0 x / M v0 y / N ) 0 0
20.
Properties of 2DFourier Transform Periodicity The Fourier transform and inverse are infinitely periodic on the u and v directions. (k1 and k2 are integers). F (u, v) F (u k1M , v) F (u, v k2 N ) F (u k1M , v k2 N ) f (x, y) f (x k1M , y) f (x, y k2 N ) f (x k1M , y k2 N ) To show the origin of F(u,v) at the center we shift the data by M/2 and N/2 f (x, y)(1)x y F (u M / 2, v N / 2)
21.
Properties of 2DFourier Transform Symmetry Any real or complex function can be expressed as the sum of even and odd part w(x, y) we (x, y) wo (x, y) 2 w(x, y) w(x,y) ew (x, y) 2 e w(x, y) w(x,y) w (x, y) Which shows that even functions are symmetric and odd functions are antisymmetric we (x, y) we (x, y) wo (x, y) wo (x, y)
22.
Properties of 2DFourier Transform Symmetry The Fourier transform of a real function f(x,y) is conjugate symmetric F* (u,v) F(u,v) The Fourier transform of a imaginary function f(x,y) is conjugate anti-symmetric F* (u,v) F(u,v) 1 * x0 y 0NM F* (u,v) M 1N1 f (x, y)e j2 (ux / M vy/ N ) Proof NM x0 y 0 1 N1 1 M f * (x, y)ej2 (ux/ M vy/ N ) 1 N1 1 M f (x, y)e j2 ([u]x/ M [v]y / N ) NM F(u,v) x0 y 0
Sampling and FourierTransform 1.Converting continuous function/signal into a discrete one. 2.The sampling is uniform at T intervals The sampled function and the value of each Sample are : ~ f (t)f (t) f (t)s (t) (t nT)T n fk f (t) (t kT )dt f (kT)
Discrete Fourier Transform 2 •we have studied the DFT • due to its computational efficiency the DFT is very popular • however, it has strong disadvantages for some applications – it is complex – it has poor energy compaction • energy compaction – is the ability to pack the energy of the spatial sequence into as few frequency coefficients as possible – this is very important for image compression – we represent the signal in the frequency domain – if compaction is high, we only have to transmit a few coefficients – instead of the whole set of pixels
40.
Discrete Cosine Transform •A much better transform, from this point of view, is the DCT – in this example we see the amplitude spectra of the image above – under the DFT and DCT – note the much more concentrated histogram obtained with the DCT • why is energy compaction important? – the main reason is image compression – turns out to be beneficial in other applications 3
42.
Image compression • Animage compression system has three main blocks – a transform (usually DCT on 8x8 blocks) – a quantizer – a lossless (entropy) coder • each tries to throw away information which is not essential to understand the image, but costs bits
45.
• The transformthrows away correlations – if you make a plot of the value of a pixel as a function of one of its neighbors – you will see that the pixels are highly correlated (i.e. most of the time they are very similar) – this is just a consequence of the fact that surfaces are smooth Image compression
46.
Image compression • asecond advantage of working in the frequency domain – is that our visual system is less sensitive to distortion around edges – the transition associated with the edge masks our ability to perceive the noise – e.g. if you blow up a compressed picture, it is likely to look like this – in general, the compression errors are more annoying in the smooth image regions 4 6
47.
Image compression • threeJPEG examples 36KB 5.7KB 1.7KB – note that the blockiness is more visible in the torso
48.
Image compression • importantpoint: – does not save any bits – does not introduce any distortion • both of these happen when we throw away information • this is called “lossy compression” and implemented by the quantizer • what is a quantizer? – think of the round() function, that rounds to the nearest integer – round(1) = 1; round(0.55543) = 1; round (0.0000005) = 0 – instead of an infinite range between 0 and 1 (infinite number of bits to transmit) – the output is zero or one (1 bit) – we threw away all the stuff in between, but saved a lot of bits – a quantizer does this less drastically
49.
Quantizer • it isa function of this type – inputs in a given range are mapped to the same output • to implement this, we – 1) define a quantizer step size Q – 2) apply a rounding function x Q x roundq – the larger the Q, the less reconstruction levels we have – more compression at the cost of larger distortion – e.g. for x in [0,255], we need 8 bits and have 256 color values – 4 levels and only need 2 bits
50.
Quantizer • note thatwe can quantize some frequency coefficients more heavily than others by simply increasing Q • this leads to the idea of a quantization matrix • we start with an image block (e.g. 8x8 pixels)
Quantizer • note thathigher frequencies are quantized more heavily Q mtx increasing frequency – in result, many high frequency coefficients are simply wiped out DCT quantized DCT
54.
Quantizer • this savesa lot of bits, but we no longer have an exact replica of original image block DCT quantized DCT inverse DCT original pixels
55.
Quantizer • note, however,that visually the blocks are not very different original decompressed – we have saved lots of bits without much “perceptual” loss – this is the reason why JPEG and MPEG work
56.
Image compression • threeJPEG examples 36KB 5.7KB 1.7KB – note that the two images on the left look identical – JPEG requires 6x less bits
57.
Energy compaction • Thetwo extensions are DFT DCT – note that in the DFT case the extension introduces discontinuities – this does not happen for the DCT, due to the symmetry of y[n] – the elimination of this artificial discontinuity, which contains a lot of high frequencies, – is the reason why the DCT is much more efficient
58.
2D-DCT n2n2 1D-DCT • 1) create intermediate sequenceby computing 1D-DCT of rows • 2) compute k1 f [ k1 , n 2 ] n1 x[ n1 , n 2 ] 1D-DCT of columns n2 k2 1D-DCT k1 f [ k 1 , n 2 ] 5 8 k1 C x [ k 1 , k 2 ] • the extension to 2D is trivial • the procedure is the same