“One picture is worth more than
ten thousand words”-Anonymous
Digital Image
Processing -
Basics
FCV (CSE: 3172)
Images
• Images are two-dimensional functions
f ( x, y)
• x, y are the spatial coordinates
• f is the intensity/amplitude at (x, y)
(0,0) y
x f(x, y)
Digital video
• Sequence of 2D images
• f(x, y, t)
• x , y are the spatial coordinates and t is the time.
time
What is the purpose of image processing?
• Enhance the picture for be for better clarity
• Images in –Images out
• Extract information from images
• Images in –Image attributes out
• Picture storage and transmission
• Encoder: Images in –Image attributes out
• Decoder: Image attributes in –Images out
PCS Swamy, Dept. of CSE, MIT, Manipal
Image processing examples
• Restoration of images from Hubble Space Telescope
• http://hubblesite.org/sci.d.tech/nuts_.and._bolts/optics/costar/index.s
html
PCS Swamy, Dept. of CSE, MIT, Manipal
Image processing examples
• Image enhancement
Before After
PCS Swamy, Dept. of CSE, MIT, Manipal
Image processing examples
• Quality control in industrial environment
PCB Bottles
Cornflakes
PCS Swamy, Dept. of CSE, MIT, Manipal
Image processing examples
• Image compression for storage and transmission
• Store 8X-10X more pictures in memory in digital cameras
• Take less time to transmit pictures from Mars to Earth
Original -532 kB JPEG -66 kB(1:8 compression)
PCS Swamy, Dept. of CSE, MIT, Manipal
Types of Images
PCS Swamy, Dept. of CSE, MIT, Manipal
Radiation from EM spectrum
• EM waves = a stream of massless (photon) particles, each
traveling in a wavelike pattern and moving at the speed of light.
• Spectral bands are grouped by energy per photon
• Gamma rays, X-rays, Ultraviolet, Visible, Infrared, Microwaves, Radio
waves
Gamma-ray imaging
• Positron emission tomography
PCS Swamy, Dept. of CSE, MIT, Manipal
X-ray imaging
• X-rays discovered in 1895
• Nobel Prize for Physics awarded to W. C. Rontgen(1901)
PCS Swamy, Dept. of CSE, MIT, Manipal
X-ray imaging –CT scans
• Computed tomography (CT)
• First system built in 1971
• Nobel Prize for Medicine awarded to
G. Hounsfieldand A. Cormack(1979)
PCS Swamy, Dept. of CSE, MIT, Manipal
3D Reconstruction
• http://www.ai.mit.edu/people/leventon/Research/9810-MICCAI-Ped/node1.html
PCS Swamy, Dept. of CSE, MIT, Manipal
Imaging in visible and infrared bands
• Color images
• “multispectral” image
R
B
PCS Swamy, Dept. of CSE, MIT, Manipal
Imaging in visible and infrared bands
• Another way to visualize
R
PCS Swamy, Dept. of CSE, MIT, Manipal
Imaging in visible and infrared bands
• Multispectral imaging
PCS Swamy, Dept. of CSE, MIT, Manipal
Imaging in Microwave band
• Radar imaging
• all-weather, day-or-night capability
PCS Swamy, Dept. of CSE, MIT, Manipal
Imaging in Radio band
• Magnetic resonance imaging (MRI)
• Magnetic resonance imaging discovered in 1973.
• Nobel Prize for Medicine awarded to P. C. Lauterburand P.
Manseld, 2003
PCS Swamy, Dept. of CSE, MIT, Manipal
Other imaging modalities
• Ultrasound imaging
PCS Swamy, Dept. of CSE, MIT, Manipal
Generated images by computer
• Fractals : an iterative
reproduction of a basic
pattern according to
some mathematical
rules
• 3-D computer modeling
PCS Swamy, Dept. of CSE, MIT, Manipal
The human eye
Digital Colour Retinal Image
(576×768 pixels, 24 bit RGB
with JPEG compression)
• http://webvision.med.utah.edu/sretina.html
Image Acquisition Process
Intensity function
• Image refers to a 2D light-intensity function, f(x,y)
• Amplitude of f at spatial coordinates (x,y) gives the intensity
(brightness) of the image at that point.
• Light is a form of energy thus f(x,y) must be nonzero and finite.
0 < f (x, y) < ∞
f (x, y) = i(x, y)r(x, y)
PCS Swamy, Dept. of CSE, MIT, Manipal
Image Sampling and Quantization
Digitizing
the
coordinate
values Digitizing
the
amplitude
values
Digital images – Sampling and quantization
Digital images
Basic Relationships Between Pixels
• Neighbors of a pixel p at coordinates (x,y)
➢ 4-neighbors of p, denoted by N4(p):
(x-1, y), (x+1, y), (x,y-1), and (x, y+1).
➢ 4 diagonal neighbors of p, denoted by ND(p):
(x-1, y-1), (x+1, y+1), (x+1,y-1), and (x-1, y+1).
➢ 8 neighbors of p, denoted N8(p)
N8(p) = N4(p) U ND(p)
How many levels of gray required?
Majority of image typically quantized to 256 levels
Storage requirements for images
• Image size: N × M
• Number of levels: 2k
• Number of colors (components): C
Size = N × M × k × c
• Examples:
• B&W (gray-level, monochorme) images:
• N=M=512, k = 8, c = 1 –Size = 2,097,152 bits = 256 kByte
• Color images:
• N=M=1024, k = 8, c = 3 –Size = 31,457,280 bits = 3.75 MByte
Image size and spatial resolution
Image size and spatial resolution (cont’d)
Varying the number of gray levels
Varying the number of gray levels (cont’d)
Isopreference curves
PCS Swamy, Dept. of CSE, MIT, Manipal
• Interpolation — Process of using known data to
estimate unknown values
e.g., zooming, shrinking, rotating, and geometric
correction
Image
• Interpolation (sometimes called resampling)
Interpolation • an imaging method to increase (or decrease)
the number of pixels in a digital image.
• Some digital cameras use interpolation to
produce a larger image than the sensor captured
or to create digital zoom
PCS Swamy, Dept. of CSE, MIT, Manipal
Image Interpolation
• Nearest neighborhood interpolation
• Bilinear interpolation
v(x,y)=ax+by+cxy+d
• Bicubic interpolation
3 3
f3 ( x, y) = aij xi y j
i =0 j =0
PCS Swamy, Dept. of CSE, MIT, Manipal
Nearest Neighbour
Interpolation
PCS Swamy, Dept. of CSE, MIT, Manipal
Neighborhood
Basic Connectivity
Relationships
Between Adjacency
Pixels
Paths
Distance measures
PCS Swamy, Dept. of CSE, MIT, Manipal
Basic Relationships Between Pixels
• Neighbors of a pixel p at coordinates (x,y)
➢ 4-neighbors of p, denoted by N4(p):
(x-1, y), (x+1, y), (x,y-1), and (x, y+1).
➢ 4 diagonal neighbors of p, denoted by ND(p):
(x-1, y-1), (x+1, y+1), (x+1,y-1), and (x-1, y+1).
➢ 8 neighbors of p, denoted N8(p)
N8(p) = N4(p) U ND(p)
PCS Swamy, Dept. of CSE, MIT, Manipal
Basic Relationships Between Pixels
• Adjacency
Let V be the set of intensity values
➢4-adjacency: Two pixels p and q with values from V are 4-adjacent if q is in
the set N4(p).
➢8-adjacency: Two pixels p and q with values from V are 8-adjacent if q is in
the set N8(p).
PCS Swamy, Dept. of CSE, MIT, Manipal
Basic Relationships Between Pixels
• Adjacency
Let V be the set of intensity values
➢m-adjacency: Two pixels p and q with values from V are m-
adjacent if
(i) q is in the set N4(p), or
(ii) q is in the set ND(p) and the set N4(p) ∩ N4(q) has no pixels whose
values are from V.
PCS Swamy, Dept. of CSE, MIT, Manipal
Examples: Adjacency and Path
V = {1, 2}
0 1 1 0 1 1 0 1 1
0 2 0 0 2 0 0 2 0
0 0 1 0 0 1 0 0 1
PCS Swamy, Dept. of CSE, MIT, Manipal
Basic Relationships Between Pixels
• Path
➢ A (digital) path (or curve) from pixel p with coordinates (x0, y0) to pixel q with coordinates
(xn, yn) is a sequence of distinct pixels with coordinates
(x0, y0), (x1, y1), …, (xn, yn)
Where (xi, yi) and (xi-1, yi-1) are adjacent for 1 ≤ i ≤ n.
➢ Here n is the length of the path.
➢ If (x0, y0) = (xn, yn), the path is closed path.
➢ We can define 4-, 8-, and m-paths based on the type of adjacency used.
PCS Swamy, Dept. of CSE, MIT, Manipal
Basic Relationships Between Pixels
• Connected in S
Let S represent a subset of pixels in an image. Two pixels p with
coordinates (x0, y0) and q with coordinates (xn, yn) are said to be
connected in S if there exists a path
(x0, y0), (x1, y1), …, (xn, yn)
Where i, 0 i n, ( xi , yi ) S
PCS Swamy, Dept. of CSE, MIT, Manipal
Basic Relationships Between Pixels
• We call R a region of the image if R is a connected set
• Two regions, Ri and Rj are said to be adjacent if their
union forms a connected set.
• Regions that are not to be adjacent are said to be
disjoint.
PCS Swamy, Dept. of CSE, MIT, Manipal
Distance Measures
• Given pixels p, q and z with coordinates (x, y), (s, t), (u, v) respectively,
the distance function D has following properties:
a. D(p, q) ≥ 0 [D(p, q) = 0, iff p = q]
b. D(p, q) = D(q, p)
c. D(p, z) ≤ D(p, q) + D(q, z)
PCS Swamy, Dept. of CSE, MIT, Manipal
Distance Measures
The following are the different Distance measures:
a. Euclidean Distance :
De(p, q) = [(x-s)2 + (y-t)2]1/2
b. City Block Distance:
D4(p, q) = |x-s| + |y-t|
c. Chess Board Distance:
D8(p, q) = max(|x-s|, |y-t|)
PCS Swamy, Dept. of CSE, MIT, Manipal
Arithmetic Operations
• Arithmetic operations between images are array operations.
The four arithmetic operations are denoted as
s(x,y) = f(x,y) + g(x,y)
d(x,y) = f(x,y) – g(x,y)
p(x,y) = f(x,y) × g(x,y)
v(x,y) = f(x,y) ÷ g(x,y)
PCS Swamy, Dept. of CSE, MIT, Manipal
Example: Addition of Noisy Images for Noise Reduction
Noiseless image: f(x,y)
Noise: n(x,y)
Corrupted image: g(x,y)
g(x,y) = f(x,y) + n(x,y)
Reducing the noise by adding a set of noisy images, {gi(x,y)}
K
1
g ( x, y ) =
K
g ( x, y )
i =1
i
PCS Swamy, Dept. of CSE, MIT, Manipal
An Example of Image Subtraction: Mask Mode Radiography
Mask h(x,y): an X-ray image of a region of a patient’s body
Live images f(x,y): X-ray images captured at TV rates after injection of the contrast medium
Enhanced detail g(x,y)
g(x,y) = f(x,y) - h(x,y)
The procedure gives a movie showing how the contrast medium propagates through the various
arteries in the area being observed.
PCS Swamy, Dept. of CSE, MIT, Manipal
PCS Swamy, Dept. of CSE, MIT, Manipal
An Example of Image Multiplication and Division
PCS Swamy, Dept. of CSE, MIT, Manipal
Image Transform
PCS Swamy, Dept. of CSE, MIT, Manipal
Example: Image Denoising
PCS Swamy, Dept. of CSE, MIT, Manipal