0% found this document useful (0 votes)
89 views31 pages

Sampling and Quantisation

Uploaded by

mukilan1978
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views31 pages

Sampling and Quantisation

Uploaded by

mukilan1978
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Image Sampling and Quantization

• The output of most sensors is continuous in amplitude and


spatial coordinates.
• Converting an analog image to a digital image require
sampling and quantization
• Sampling: is digitizing the coordinate values
• Quantization: is digitizing the amplitude values
Sampling
• Digitization of the spatial coordinates, sample (x, y) at
discrete values of (0, 0), (0, 1), ….

• f(x, y) is 2-D array

 f (0,0) f (0,1)  f (0, M  1) 


 f (1,0) f (1,1) f (1, M  1) 
f ( x, y)  
 
 
 f ( N  1,0) f ( N  1,1) f ( N  1, M  1)

53
Quantization
• Digitization of the light intensity function

• Each f(i,j) is called a pixel

• The magnitude of f(i,j) is represented digitally


with a fixed number of bits - quantization

54
Image Acquisition

Sampling: digitizing the 2-dimensional spatial coordinate values


Quantization: digitizing the amplitude values (brightness level)

55
Sampling and Quantization

Image sampling: discretize an image in the spatial domain


Spatial resolution / image resolution: pixel size or number of pixels

56
Sampling and Quantization
• How many samples to take?

– Number of pixels (samples) in the image


– Nyquist rate

• How many gray-levels to store?

– At a pixel position (sample), number of levels of


color/intensity to be represented

57
How to choose the spatial resolution
Spatial resolution = Sampling locations
Original image
Sampled image

Under sampling, we lost some image details!


Sampling and Quantization
• How many samples to take?

59
Definition of Aliasing
• Aliasing refers to the effect produced when a signal is imperfectly reconstructed
from the original signal.
• Aliasing occurs when a signal is not sampled at a high enough frequency to
create an accurate representation. This effect is shown in the following example
of a sinusoidal function:

• In this example, the dots represent the sampled data and the curve represents
the original signal. Because there are too few sampled data points, the resulting
pattern produced by the sampled data is a poor representation of the original.
Aliasing is relevant in fields associated with signal processing, such as digital audio,
digital photography, and computer graphics.
Aliasing(mixing of two different signals)
• Spatial aliasing in the form of a Moiré pattern.
• In signal processing and related disciplines, aliasing refers to an effect that
causes different signals to become indistinguishable (or aliases of one
another) when sampled. It also refers to the distortion or artifact that
results when the signal reconstructed from samples is different from the
original continuous signal.
• Aliasing can occur in signals sampled in time, for instance digital audio is
referred to as temporal aliasing. Aliasing can also occur in spatially
sampled signals, for instance digital images. Aliasing in spatially sampled
signals is called spatial aliasing.

Properly sampled image of brick wall. Spatial aliasing in the form of a Moiré pattern.
Sampling and Quantization
• How many samples to take?

– The Nyquist Rate

– Samples must be taken at a rate that is twice the


frequency of the highest frequency component to be
reconstructed.

– Under-sampling: sampling at a rate that is too coarse,


i.e., is below the Nyquist rate.

– Aliasing: artefacts that result from under-sampling.

62
How to choose the spatial resolution :
Nyquist Rate
Original image

Sampled image

1mm

2mm

No detail is lost!
Minimum Nyquist Rate:
Spatial resolution
Period Spatial resolution must be less or equal
(sampling rate)
half of the minimum period of the image
or sampling frequency must be greater or
= Sampling locations
Equal twice of the maximum frequency.
Aliased Frequency
x1 (t )  sin( 2t ), f 1
1 x2 (t )  sin(12t ), f 6
0.5

-0.5

-1
0 0.5 1 1.5 2
Sampling rate:
5 samples/sec
1

0.5

-0.5

-1
0 0.5 1 1.5 2

Two different frequencies but the same results !


Sampling and Quantization
• How many gray-levels to store?

65
Effect of Spatial Resolution

256x256 pixels 128x128 pixels

64x64 pixels 32x32 pixels


Effect of Spatial Resolution

(Images from Rafael C. Gonzalez and Richard E


Wood, Digital Image Processing, 2nd Edition.
Aliasing and Moiré Pattern
• All signals (functions) can be shown to be made up of a linear
combination sinusoidal signals (sines and cosines) of different
frequencies.
• For physical reasons, there is a highest frequency component
in all real world signals.
• Theoretically,
– if a signal is sampled at more than twice its highest frequency
component, then it can be reconstructed exactly from its samples.
– But, if it is sampled at less than that frequency (called undersampling),
then aliasing will result.
– This causes frequencies to appear in the sampled signal that were not
in the original signal.
– The Moiré pattern shown in Figure 2.24 is an example. The vertical low
frequency pattern is a new frequency not in the original patterns.
Moire Pattern Effect : Special Case of
Sampling

Moire patterns occur when frequencies of two superimposed


periodic patterns are close to each other.

(Images from Rafael C. Gonzalez and Richard E


Wood, Digital Image Processing, 2nd Edition.
Aliasing and Moiré Pattern

• Note that subsampling of a digital image will cause undersampling if the


subsampling rate is less than twice the maximum frequency in the digital
image.
• Aliasing can be prevented if a signal is filtered to eliminate high
frequencies so that its highest frequency component will be less than
twice the sampling rate.
• Gating function: exists for all space (or time) and has value zero
everywhere except for a finite range of space/time. Often used for
theoretical analysis of signals. But, a gating signal is mathematically
defined and contains unbounded frequencies.
• A signal which is periodic, x(t) = x(t+T) for all t and where T is the period,
has a finite maximum frequency component. So it is a bandlimited signal.
• Sampling at a higher sampling rate (usually twice or more) than necessary
to prevent aliasing is called oversampling.
Effect of Spatial Resolution

(Images from Rafael C. Gonzalez and Richard E


Wood, Digital Image Processing, 2nd Edition.
Can we increase spatial resolution by
interpolation ?

Down sampling is an irreversible process.


(Images from Rafael C. Gonzalez and Richard E
Wood, Digital Image Processing, 2nd Edition.
Image Quantization

Image quantization:
discretize continuous pixel values into discrete numbers

Color resolution/ color depth/ levels:


- No. of colors or gray levels or
- No. of bits representing each pixel value
- No. of colors or gray levels Nc is given by

Nc  2 b

where b = no. of bits


Quantization function

Nc-1

Nc-2
Quantization level

1
0
Light intensity
Darkest Brightest
Effect of Quantization Levels

256 levels 128 levels

64 levels 32 levels
Effect of Quantization Levels (cont.)

16 levels 8 levels

In this image,
it is easy to see
false contour.

4 levels 2 levels
How to select the suitable size and pixel depth of images

The word “suitable” is subjective: depending on “subject”.

Low detail image Medium detail image High detail image

Lena image Cameraman image

To satisfy human mind


1. For images of the same size, the low detail image may need more pixel depth.
2. As an image size increase, fewer gray levels may be needed.
(Images from Rafael C. Gonzalez and Richard E
Wood, Digital Image Processing, 2nd Edition.
Human vision: Spatial Frequency vs
Contrast
Human vision: Distinguish ability for
Difference in brightness

Regions with 5% brightness difference


Sampling Theorem and Aliasing Effect

• Shannon sampling theorem states that if a function is sampled


at a rate equal to or greater than twice its highest frequency,
it is possible to recover completely the original function from
its samples.
Basic Relationship of Pixels

(0,0) x

(x-1,y-1) (x,y-1) (x+1,y-1)

(x-1,y) (x,y) (x+1,y)


y

(x-1,y+1) (x,y+1) (x+1,y+1)

Conventional indexing method

You might also like