1.DIP Sampling & Quantization

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 45

IMAGE SAMPLING

&
QUANTIZATION

M.V. RAGHUNADH
Assistant Professor, Dept. of ECE
NIT, Warangal – 506004.

[email protected]
Introduction to Digital Image Processing
 Purpose of image processing
– Processing of image data for storage, display & transmission
– Improvement of pictorial information for Human Perception
– Improvement of pictorial information for Machine Perception

 Typical application areas


Television DIP: brightness, contrast, hue & noise adjustment
Satellite DIP: Remote sensing, Climate, Geology, Land/Sea
resource
Medical DIP: Ultra Sound, MRI/PET/CT Scans, X-Rays
Robot Control: Automatic inspection, Unmanned operations-
Autonomous Vehicle (Mars Rover)
Visual Communications: Video-coding/ transmission/
conferencing, Tele-conferencing/shopping
Pattern Recognition: Law Enforcement, Biometric Identification:
Fingerprint/face/iris/speech/writing/signature
Acquisition and display
• Image acquisition is the first key step in digital
image processing.

• Hardware imaging devices: video cameras with


frame grabbers, digital cameras, slide or flat bed
scanners

• Issues: lower noise, greater dynamic range, high


resolution, Sensitivity, color fidelity, Speed

• Acquisition programs: save image in various


formats, Plug-in program packages like Photoshop,
Fovea Pro
What is an image?
• We can think of an image as a function, f,
from R2 to R:
– f( x, y ) gives the intensity at position ( x, y )
– Realistically, we expect the image only to be
defined over a rectangle, with a finite range:
– f : [a,b]x[c,d]  [0,1]
• A color image is just three functions pasted
together. We can write this as a “vector-
valued” function: (fR, fG, fB)
Images as functions
ANALOG Vs DIGITAL

TWO Ways to Process Information:

Analog: Digital:

Gramophone LP Record Optical CD ROM Record

Magnetic Tape Record Magnetic Memory- RAM&ROM

Conventional Radio Web Radio

Slide Rule Digital computer


Digital Images
• A natural image is a continuous, 2-dimensional
distribution of brightness (or some other physical
effect).

• Conversion of natural images into digital form


involves two key processes, jointly referred to as
digitisation:
– Sampling
– Quantisation

• Both operations involve loss of image fidelity i.e.


since they are approximation processes.
Image Representation
Analog image  Sampling  Quantization Digital image

2D array of picture elements (pixels)


Digital Image Coordinate Convention
Digital Image Representation

f(x,y) = Reflectance (x,y) * Illumination (x,y)


Reflectance in [0,1], illumination in [0,inf]
Real   Digital

•Image Intensity
•Image Spectral Distribution (‘color’)
•Image Geometry (Position, Angle, Distortion, …)
•Image Resolution (‘sharpness’ or ‘focus’)

Real Images: Digital Images:


Smooth … Sampled …
Continuous … Discrete …
Variable … Quantized …
Complete … Fixed …
Unlimited … Limited …
What is a digital image?

• We usually operate on digital (discrete) images:


– Sample the 2D space on a regular grid
– Quantize each sample (round to nearest integer)
• If our samples are  apart, we can write this as:
• f[i ,j] = Quantize{ f(i , j ) }
• The image can now be represented as a matrix of integer
values

ј
і
DIGITAL IMAGES
• Electronic Snapshots of a scene
or scanned texts/
documents/photographs/manus
cripts/artwork
• Digital image is sampled
(mapped) grid of dots/ pixels
• Each pixel is assigned a tonal
value (black, white, shades of
gray or color) represented in a
binary code
• Bits of each pixel are stored in a
sequence in memory
• These bits are then read and Pixel Values: As shown in this
interpreted by the computer to bitonal image, each pixel is
produce an analog version for
display or printing. assigned a tonal value, in this
example 0 for black and 1 for
white.
Sampling
• Sampling represents the image by intensity
measurements at regularly spaced sample intervals.

• Two important criteria:-


– Sampling interval
• distance between sample points or pixels
– Tessellation
• the pattern of sampling points

• The number of pixels in the image is called the


resolution of the image. If the number of pixels is too
small, individual pixels can be seen and other
undesired effects (e.g. aliasing) may be evident.
Discretizing the image
-- Tessellation and Quantization
• There are only three ways to tessellate the plane
with a regular polygons:

• Squares: The most common method.

• Regular hexagons: a useful method due to less


rotational dependence.

• Equilateral triangles: not commonly used.


Sampling and Quantization
Continuous image
Continuous scan line from A to B

Digital scan line


Sampling & Quantization
Real vs. Digital
• Real Image == 2D Light Intensity map: I(x,y)
• Digital Image == 2D grid of numbers: I(m,n)

I(x,y) I(m,n)
(pixels)

x,y m,n
Digital Images As Vectors
• ‘Stack up’ pixel values: VERY LONG vector
– 1 digital image == 1 point in N-dim. Space
– Nearby points == Similar images
– All possible digital images:
a grid of N-D points I00
I(m,n)
I01
I= I02
– Space of all practical …
digital images: I10
• ~8Meg dimensions I11
(2Mpix * RGBA)
I00 I01 I02 I03 I04 I05 m,n I12
• discrete, quantized

Sampling as a Grid / Array Formatting
‘Digital’ Images: 2D Grid of Numbers
• NO intrinsic meaning, but widely assumed to represent
Point Samples of a “smoothed” 2D intensity surface
Uniform sampling pattern (but not always)
( weasel - word ! )

x
Digital Images As Vectors
• Sensible element-by-element operations:
– Add, subtract, scale two images:
0.5 + (I1 - I2 ) = out

I1 - I2 = out
SAMPLING

More the samples  Better the Approximation/Resemblance

The Samples
Digital images
Pick a sample color from
Sampling each box/cell of grid to record

Each sample (cell) is called


The finest the a pixel - picture element
sampling much finer sampling yet
-the clearer the image
Quantisation
• Quantisation uses an ADC (Analogue to Digital
Converter) to transform brightness values into a range
of integer numbers, 0 to M, where M is limited by the
ADC and the computer.
- m= log2M is the number of bits used to represent the
value of each pixel.

• This determines the number of grey levels.

• Too few bits results in steps between grey levels being


apparent.
Quantization (bit allocation)

• Example: "rounding to the nearest integer“

• Non-uniform (variable bit allocation)


– Based on the statistics of the source
(Laplacian Quantizer)

– Based on the human visual system


(perceptually-tuned quantization)

– Either Rounding or Truncation operation on pixel values


QUANTIZATION
•A computer can not record the pixel values with infinite precision.
•Original pixel values are randomly valued
•Hence the pixel values must be quantized
Quantization
• Each sample value is replaced by the nominal value of its
quantization level.
• a sample value a nominal value
• More quantization levels gives a more accurate
representation
Quantization
• Does not necessarily have to be Uniform or Linear

Wider
Quantization
level

Narrower
Quantization
level
Coding
• Quantized samples could then be represented digitally by a
string of 0’s and 1’s -- 0010 0011 0011 0000 1010 1011

• Assign a codeword to each quantized sample

0101
0110
0111
1000
1001
1010
1011
1100
1101
Image Resolution
 Ability to recognize small features and locate boundaries requires enough
pixels
 Too few grey levels produce visible “ false contouring" artefacts in
smoothly varying regions.

A Girl image with 256


and 4 grey levels.

left hand image produced by


combining Bands 1 (B), 2 (G)
& 3 (R)

right hand image produced by


intensity channel of this color
image mixed with Band 8 improved sharpness of detail is
panchromatic image evident
• SPATIAL RESOLUTION is the ability to distinguish fine spatial
detail. The spatial sampling frequency is often a good indicator
of resolution.
• dots-per-inch (dpi) or pixels-per- inch (ppi) are common to
express resolution for digital images.

Pixels: Individual pixels can be seen by zooming in an image


The resolution of a digital camera refers to the number of
samples (pixels) that the camera takes in

You need
No. of samples Resolution Print Size at least 150 ppi
(pixels per inch)
For printing
0.3 M 640 x 480 3x4 inches

1M 1152 x 864 5x7 inches

1.2 M 1280 x 960 5x7 inches

2.1 M 1600 x 1200 8x10 inches

3.3 M 2048 x 1536 11x14 inches


• PIXEL DIMENSIONS are horizontal & vertical measurements

• Determined by multiplying width & height by the dpi.

• A digital camera has pixel dimensions expressed as its


resolution (e.g., 2,048 by 3,072)

• Calculate the dpi dividing a document's dimension into the


corresponding pixel dimension against which it is aligned

Example:

An 8" x 10" document that is scanned


at 300 dpi has the pixel dimensions of
2,400 pixels (8" x 300 dpi) by 3,000
pixels (10" x 300 dpi).
BIT DEPTH is determined by the number of bits used to define each pixel.
 Digital images- black and white, (bitonal), grayscale, or color.
• Bitonal image is represented by 1 bit pixels, which can represent two tones
(typically black and white), using ‘0’ for black and ‘1’ for white
• Grayscale image is composed of multibit pixels( 2 to 8 bits)
– Ex: A 2-bit depth image has four possible representations:
00 - Black, 11-White, 01 - Dark gray and 10 - Light gray.
An 8 bit depth image has 256 tones assigned to each pixel.
• Color image: has a bit depth ranging from 8 to 24.
– 8 bits are often used for Red, 8 for Green, and 8 for Blue. Combinations
of those bits are used to represent other colors. Ex: A 24-bit image offers
16.7 million (2 24 ) color values.

Bit Depth: Left to right –


1-bit bitonal,
8-bit grayscale, and
24-bit color images.
• DYNAMIC RANGE is the range of tonal difference between the
lightest light and darkest dark of an image.
• FILE SIZE is calculated by multiplying the surface area of a
document (height x width) to be scanned by the bit depth and
the dpi 2 . Divide this figure by 8 to get in Bytes.
• File size naming convention: in increments of
210 (1,024) or more:
• 1 Kilobyte (KB) = 1,024 Bytes
• 1 Megabyte (MB) = 1,024 KB
• 1 Gigabyte (GB) = 1,024 MB
• 1 Terabyte (TB) = 1,024 GB
FILE FORMATS: Pixel bits that comprise the image plus a
header information on how to read and interpret the file. File
formats vary in terms of resolution, bit-depth, color capabilities,
and support for compression and metadata.
Color Image
Color Dots image Red Channel image

Green Channel image


COLOR DIGITAL IMAGES

2D Arrays of pixels of varying color and intensity

Color Model: how to specify the color of a pixel (coding!)


Additive
mixing
R,G,B: colors represented by a number triplet,
specifying the Red(R), Green(G) and Blue(B) intensities
Color
Y, CR, CB: for digital images and videos difference
Subtractive
mixing C,M,Y,K : for printing and arts
Cyan - no Red

Magenta - no Green

Yellow - no Blue

K - Black ink
Color Quantization
• Some display hardware stores 8 bits per pixel
• => it can display at most 256 distinct colors at a time
• To display a full-color image, the computer must
choose an appropriate set of representative colors
and map the image into these colors

This process is called


Quantization phases
• Sample the original image for color
statistics
• Select color map based on those
statistics
• Map the colors to their representative
in the color map
• Redraw the image, quantizing
each pixel Algorithm

Mapping

The Median Cut Algorithm

• The concept – to use each of the colors


in the color map to represent an equal
number of pixels in the original image

• The algorithm repeatedly subdivides color


space into smaller and smaller
rectangular boxes

You might also like