Ch-2 Digital Image Processing Topics
Ch-2 Digital Image Processing Topics
Education
1
Chapter Two
2
Outline
Digital Image Processing Topics
Sampling and Quantization
Image Transforms
3
Sampling and Quantization
4
Cont.
The sampling rate determines the spatial
resolution of the digitized image, while the
quantization level determines the number
of grey levels in the digitized image.
A magnitude of the sampled image is
expressed as a digital value in image
processing.
The transition between continuous values
of the image function and its digital
equivalent is called quantization.
5
Cont.
6
2D Sampling: From analogue images to digital
images (pixels)
Sampling of an image is basically sampling of a
8
Quantization: From continuous image signal to discrete
image signal
image amplitude).
10
Steps to Convert Analog to Digital Media
11
Cont.
Quantization
it converts a sampled signal into a signal that can
take only a limited number of values (or bit depth).
The digitization/quantization process approximates
the bit depth with a fixed number of values.
To represent N numbers, we need log2N bits.
• For example, an 8 bit quantization represents 28=256
possible values.
• What about a 16 bit quantization? It handles almost more
than 65, 000 possible values
Degree of Quantization:
What determines the number of bits we need to digitize an
image?
12
Cont.
Compression:
There are probably some further
14
Image Transform
Transform
IMAGE ANOTHER IMAGE
NxN NxN
Inverse Transform
Coefficient Matrix
15
Cont.
Image transform is representation of a 2D
signal(image signal holds 2D visual information)
The efficient representation of visual information
lies at the foundation of many image processing
tasks which include image filtering, image
compression and feature extraction.
Efficiency of representation: the ability of capture
significant information of an image in a small
description.
Efficient image transforms are extensively used
in image processing and image analysis
16
Cont.
17
Cont.
18
Need for image transform
Mathematical convenience
Every action in the time domain will have an impact
in the frequency domain
For more image extraction
Note:
Transform theory plays a fundamental role in image
processing, as working with the transform of an
image instead of the image itself may give us more
insight into the properties of the image.
Two-dimensional transforms are applied to image
enhancement, restoration, encoding and description.
19
Cont.
20
Varies image transforms
21
Fourier Transform
22
THE TWO-DIMENSIONAL FOURIER
TRANSFORM
23
Discrete Fourier Transform(DFT)
Where K=0,1,……..N-1
24
2D-Discreter Fourier Transform(2D-DFT)
M 1 N1
T (u , v) f ( x, y )e j 2 ( ux / M vy / N )
x 0 y 0
M 1 N1
1
f ( x, y )
MN
T (u, v)e
u 0 v 0
j 2 ( ux / M vy / N )
25
Implementation
We use the numpy.fft.fft2() and fftshift()
functions to transform an image to the
frequency domain.
import numpy as np
import cv2
dft = np.fft.fft2(img)
dft_shift = np.fft.fftshift(dft)
magnitude_spectrum = 20 * np.log(np.abs(dft_shift))
plt.imshow(magnitude_spectrum, cmap='gray')
plt.title("Magnitude Spectrum")
26
plt.show()
Discrete Cosine Transform (DCT)
img = cv2.imread('image.jpg',
cv2.IMREAD_GRAYSCALE)
img_float = np.float32(img) / 255.0
dct = cv2.dct(img_float)
plt.imshow(dct, cmap='gray')
plt.title("DCT of Image")
plt.show()
28
Haar Transform
36