0% found this document useful (0 votes)
50 views

Chapter 2 - Digital Image Funtamental

The document discusses fundamentals of digital image processing. It defines key concepts such as: - Digital images are made up of pixels arranged in a grid, with each pixel assigned an intensity value. - Images are converted from continuous to digital form using sampling and quantization. Sampling digitizes coordinate values and quantization digitizes intensity values into discrete levels. - Image resolution refers to both spatial resolution, determined by pixel size and spacing, and intensity resolution, determined by the number of intensity levels (bits per pixel). Higher resolution captures more detail but requires more storage.

Uploaded by

saif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Chapter 2 - Digital Image Funtamental

The document discusses fundamentals of digital image processing. It defines key concepts such as: - Digital images are made up of pixels arranged in a grid, with each pixel assigned an intensity value. - Images are converted from continuous to digital form using sampling and quantization. Sampling digitizes coordinate values and quantization digitizes intensity values into discrete levels. - Image resolution refers to both spatial resolution, determined by pixel size and spacing, and intensity resolution, determined by the number of intensity levels (bits per pixel). Higher resolution captures more detail but requires more storage.

Uploaded by

saif
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 109

Image Processing

Ch2: Digital image


Fundamentals

C. Gonzalez and R. Wood


3rd edition
Digital Image Fundamentals

 Human Visual System


 Image sensing and acquisition
 Image Sampling and Quantization
 Digital Image Representation
 Image Resolution
 Image Interpolation
 Pixel’s Relationships
 Distance Measures
Human Visual System

 Light from objects is imaged on the Retina.


 Light hits the retina, which contains photosensitive
cells called receptors: rods and cones.
 These cells convert the spectrum into a few
discrete values.
Image sensing and acquisition
Sensors
Sensors Array
A sensor: sense the
intensity of striking photon

 The light falls on the object, then the light reflects back after
striking the object and allowed to enter inside the camera.

 When photons of light strike on the chip (sensor) , it is held as a


small electrical charge in each photo sensor.

 The response of each sensor is directly equal to the amount of


light or (photon) energy striked on the surface of the sensor.
Single Sensor
Sensor Strips
Sensor Arrays (CCD array)
Image sampling and quantization
 In order to process the image, it must be saved on computer.

 The image output in real life is continuous voltage waveform.

 But computer deals with digital images not with continuous


images, thus: continuous images should be converted into
digital form.
continuous image (in real life)  digital (computer)
Image sampling and quantization
Image sampling and quantization
continuous image (in real life)  digital (computer)

To do this we use Two processes:

sampling and quantization.

 Sampling: digitizing the coordinate values


 Quantization: digitizing the amplitude values
How does the computer digitize the
continuous image?
How does the computer digitize the continuous image?

Sampling: digitizing coordinates


Quantization: digitizing intensities Gray-level scale that
divides gray-level into 8
discrete levels

Quantization:
converting each
sample gray-
level value into
discrete digital
quantity.

sample is a small white square, located by a vertical tick


mark as a point x,y
How does the computer digitize the continuous image?

Now:
the digital scanned line AB
representation on computer:

The continuous image VS


the result of digital image
after sampling and
quantization
Sampling Example
Sampling Example
DIGITAL IMAGE
REPRESENTATION
What is digital Image?
 digital image: function of 2 variables, f(x,y),
where x and y are spatial coordinates, and f at
any pair of coordinates (x,y) is called intensity or
gray level of the image at that point.

 Pixels (pels): Elements of the digital image ,


each has intensity.

 Intensity of pixel: the amplitude ‫ ﻏزارة‬of gray


level (in gray scale images)

Note: images can be: binary, grayscale, color.


The image consists of
What is digital image? finite number of
pixels ( f(x,y) )

Every pixel Is an
intersection ‫ﺗﻘﺎطﻊ‬
between a row and a
column.

every pixel has


intensity ‫ﻛﺛﺎﻓﺔ‬
pixel
Ex:
f(4,3)= 123
Refers to a pixel existing on
the intersection between row
4 with column 3, and its
intensity is 123.
Remember: images can be: binary, grayscale, color.

Binary Images
Binary images are images that have been
quantized to two values, usually denoted 0
and 1, but often with pixel values 0 and
255, representing black and white.
Binary Images
Grayscale Images -monochromatic
 A grayscale (or graylevel) image is simply
one in which the only colors are shades of
gray (0 – 255)
Grayscale Images -monochromatic
Color Images - chromatic
 Color image: A color image contains pixels
each of which holds three intensity values
corresponding to the red, green, and blue
or( RGB)
Color Images - chromatic
Index Image
Representing digital images

Every pixel has a # of bits.


Digital Image Size
 The size of a digital image is determines by its
dimensions ( M x N ) multiplied by the number of
bits k required to store the intensity levels (L = 2k).

image size = M x N x k (bits)

 Typical values of b are:


 k = 1: black and white (binary) images.
 k = 8: grayscale (256 gray levels), or indexed color images
 k = 24: RGB color image.
Representing digital images
Pixels!
 Every pixel has # of bits (k)

 Q: Suppose a pixel has 1 bit, how many gray levels can it represent?
Answer: 2 intensity levels only, black and white.
1 Bit (0,1)  0:black , 1: white

 Q: Suppose a pixel has 2 bit, how many gray levels can it represent?
Answer: 4 gray intensity levels
2 Bit (00, 01, 10 ,11).
Now ..
if we want to represent 256 intensities of grayscale, how many bits do we
need?
Answer: 8 bits  which represents: 28=256

so, the gray intensities ( L ) that the pixel can hold, is calculated according
to according to number of bits it has (k).
L= 2k

and they are integers in the interval [0, L-1]


Image Size
(200 × 200) 8-bit (200 × 200) 1-bit binary (200 × 200) 8-bit binary
grayscale image image image

2 intensities: 2 intensities:
256 intensities
Black(0) and white(1) Black(0) and
Size= 200×200×8 white(255)
size= 320,000 bit Size= 200×200×1 Size= 200×200×8
size= 40,000 bit size= 320,000 bit
Image Size
(200 × 200) 24-bit color image

8-bit Red 8-bit Green 8-bit Blue

Size= 200×200×8×3
Size= 960,000 bit
Number of storage of bits:
N * M: the no. of pixels in all the image.
K: no. of bits in each pixel
L: grayscale levels the pixel can represent
L= 2K
all bits in image= N*N*k
Number of storage of bits:
EX: Here: N=32, K=3, L = 23 =8
# of pixels=N*N = 1024 . (because in this example: M=N)
# of bits = N*N*K = 1024*3= 3072

N=M in this table, which means no. of horizontal pixels= no. of


vertical pixels. And thus:
# of pixels in the image= N*N
SPATIAL AND INTENSITY
RESOLUTION
Spatial Resolution

The spatial resolution of an image is


determined by how sampling was carried
out.
 Spatial resolution simply refers to the
smallest discernable detail in an image
 Vision specialists will often talk about pixel
size
 Graphic designers will talk about dots per inch
(DPI)

08/07/2020 36
Spatial Resolution
Reducing Spatial Resolution
(subsampling)
The lower resolution images are smaller than the original

Same # of bits in all


images (same gray level)
different # of pixels

subSampling is performed by deleting rows and columns from the original image.
Spatial and gray-level resolution

Re sampling
(pixel replication)
A special case of nearest
neighbor zooming.

Resampling is performed by row and column duplication


Checkerboard Effect
 Checkerboard effect caused when
spatial resolution of images are
very low.

 If we compare the original image


with the other images, we find
checkerboard patterns at the
edges.

 This effect is visible in the


128×128 and more pronounced
in 64×64 and 32×32.
Checkerboard Effect
Intensity Resolution
 Intensity level resolution refers to the number of
intensity levels used to represent the image.

 The more intensity levels used, the finer the


level of detail discernable in an image.

 Intensity level resolution is usually given in


terms of the number of bits used to store each
intensity level
8 bits, L=256 7 bits, L=128
Reducing IR
Here we keep the number of samples
constant and reduce the number of intensity
6 bits, L=64 5 bits, L=32

In this example,
all images has 452*374 pixels, but different #
of bits per pixel (as shown in yellow)

4 bits, L=16 3bits, L=8


different # of bits in all images
(different gray level)
same # of pixels

 Remember that:
2 bits, L=4 1 bits, L=2
every pixel has # of bits k
And # of gray levels is L=2k
More pixels  more resolution
More bit/pixel  more accuracy
False Contouring
 Effect of False Contouring – Under the low
intensity resolution it has an imperceptible set
of very fine ridge like structure in areas of
smooth gray levels ( particularly in the skull).

 This effect cause by the use of an insufficient


number of gray levels in smooth areas of a
digital image, is called False Contouring.

 False contouring is generally is quiet visible in


images displayed using 16 or less uniformly
spaced gray levels
IMAGE INTERPOLATION
Image Interpolation
Image Interpolation is the process of using known data to
estimate values at unknown location.

Image interpolation is used for zooming, shrinking,


rotating, geometric corrections.

 Zooming + shrinking are Image resizing tasks and come


under image re-sampling methods and we will study
them in the following

08/07/2020 61
Zooming (over sampling) images
Zooming requires 2 steps:

 The creation of new pixel locations.


 The assignment of gray levels to these new
locations.

Two techniques for zooming:

1. Nearest neighbor interpolation


2. Bilinear interpolation
3. Bicubic interpolation
Nearest Neighbor Interpolation
 The creation of new pixel locations.
 The assignment of gray levels to these new locations.

+ ve : Nearest neighbor is fast


-ve: it produces a
checkerboard effect like this!
Nearest Neighbor Interpolation 6×6

 First, the texture is taken, 3×3


represented by a point at
the center of each of the
pixels.

 Then stretched to the


size of the final scaled
image and overlaid onto
it. 7×7

 Next, for each point in 3×3


the scaled image, the
nearest point in the
texture is found.
Nearest Neighbor Interpolation
Nearest Neighbor Interpolation
Example:Suppose A 2x2 pixels image will be enlarged 2 times by the
nearest neighbor method:

1. Stretch the original image to the size of the new scaled image
2. overlaid the stretched grid of the original image onto the new scaled
image.
3. For any point in the overlay, look for the closest pixel in the original
image, and assign its gray level to the new pixel in the grid. (copy)

? ? ? ?

50 100 ? ? ? ?

180 250 ? ? ? ?

? ? ? ?
original image
New scaled image
Nearest Neighbor Interpolation
? ? ? ? ? ? ? ?
50 100 50 100
50 100 ? ? ? ? ? ? ? ?
180 250 ? ? ? ? ? ? ? ?
180 250 180 250
original image ? ? ? ? ? ? ? ?

Stretch the original New scaled image overlaid the


image to the size of stretched original
the new scaled image image onto it.

50 50 100 100
50 100
Next, for each point in 50 50 100 100
the scaled image, the
nearest point in the 180 180 250 250
texture is found. 180 250
180 180 250 250
Nearest Neighbor Interpolation
 Pixel replication (re sampling) is a special case that is
applicable when the size of the image needs to be increased
an integer number of times (like 2 times not 1.5 for
example).
 Example: if we want to enlarge the following image from
2×2 into 4×4
50 50 100 100
50 100
50 100 50 100 50 50 100 100
Duplicate Duplicate
rows Column 180 180 250 250
180 250 180 250
180 250 180 180 250 250
Shrinking
 Similar to image zooming.
Shrinking an image an integer number of times

 Pixel replication is replaced by row&column


deletion.
Bilinear Interpolation:
 Here we use the 4 nearest neighbours to estimate the
intensity at a given location.
 Let (x,y) denote the coordinates of the location to which
we want to assign an intensity value and let v(x,y) denote
that value, then:

 Here the 4 coefficients are determined from the 4


equations in 4 unknowns using the 4 nearest neighbours
of point (x,y).

08/07/2020 71
Bilinear Interpolation
 The closer point has more influence than the farther point.
 Thus, the weights are normalized distances between the unknown
point and each of the end points.
Bilinear Interpolation

0.5 0.5

0.2

0.8

0.5 0.5
Bicubic Interpolation:
 Involves 16 nearest neighbours of a point.

 Bicubic Interpolation method determines the gray level


value (or color) from the weighted average of the 16
closest pixels to the specified input coordinates.

 The image is sharper and more clarity than that produced


by Nearest neighbor and Bilinear Interpolation .

 It needs much more calculation and time to find weighting..

08/07/2020 74
PIXEL’S RELATIONSHIPS
Some basic relationships between pixels
Neighbors of a pixel
Relationships Between Pixels: Neighbors of a Pixel

08/07/2020 78
Neighbors of a pixel
Neighbors of a pixel
Neighbors of a pixel
Adjacency
Adjacent pixels:
0 0 0 0 0 They must be neighbors
and have gray value
0 1 1 1 0
from the same set V
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0

Not adjacent adjacent


Adjacency
V: set of gray level values (L), (V is a subset of L.)

3 types of adjacency

 4- adjacency: 2 pixels p and q with values from V are 4- adjacent if q is in the


set N4(p)
 8- adjacency: 2 pixels p and q with values from V are 8- adjacent if q is in the
set N8(p)
 m- adjacency: 2 pixels p and q with values from V are madjacent if
1. q is in N4(p), or
2. q is in ND(p) and the set N4(p) ∩ N4(q) has no pixels whose
values are from V
Adjacency
Example on m-adjacency
Let V = {2,3}, then:

3 1 3 3 1 3 (q)

3 2 (q) 4 3 (p) 2 4

(p) 2 0 1 2 0 1

p and q are not m-adjacent p and q are m-adjacent


Digital Path
A (digital) path (or curve) from pixel p with coordinates (x,
y) to pixel q with coordinates (s, t) is a sequence of
distinct pixels with coordinates:

where

are adjacent for

In this case, n is the length of the path.


86
Digital Path
 We can define 4-, 8-, or m-paths depending on the type of
adjacency specified.
Digital Path
Let V = {2,3}, then the 4-path doesn’t exist between p and q
in the following image:

3 1 1 3
(q)

1 3 2 4

3 2 1 4

(p) 2 0 0 1
Digital Path
Let V = {2,3}, then there are many 8-paths between p and q
in the following image:

3 1 1 3 3
(q)
3 1 1
(q)

1 3 2 4 1 3 2 4

3 2 1 4 3 2 1 4

(p) 2 0 0 1 (p) 2 0 0 1
Digital Path
Let V = {2,3}, then there are one m-paths between p and q
in the following image:

3 1 1 3
(q)

1 3 2 4

3 2 1 4

(p) 2 0 0 1
Digital Path (Example)
Connectivity
 S: a subset of pixels in an image.

 Two pixels p and q are said to be connected in S if there


exists a path between them consisting entirely of pixels in S.

 For any pixel p in S, the set of pixels that are connected to it


in S is called a connected component of S.

 If S has only one connected component, it is called a


connected set.

4-adjacency: 3 connected components


8-adjacency: 2 connected components
Connectivity
Let V ={1}

Based on 4-adjacency Based on 8-adjacency

1 1 0 0 1 1 0 0
1 1 0 0 1 1 0 0
0 0 1 1 0 0 1 1
0 0 1 1 0 0 1 1
1 1 0 0 1 1 0 0

3 connected component 1 connected component


Example on Connectivity

4-adjacency: 6 connected components


8-adjacency: 3 connected components
Example: Connectivity in Matlab
[l,n] = bwlabel(bw, conn)

4-adjacency: 3
connected components

4-adjacency: 4
connected components
Regions and Boundaries
 R: a subset of pixels in an image.
 R is a region of the image if R is a
connected set.

 The boundary of a region R is the


set of pixels in the region that have
one or more neighbors that are not
in R.

The circled pixel is NOT a member


of boundary if 4-connectivity is used
between region and background. It
is if 8-connectivity is used.
Regions and Boundaries
 R: a subset of pixels in an image.
 R is a region of the image if R is a
connected set.

 The boundary of a region R is the set of


pixels in the region that have one or more
neighbors that are not in R.
The circled pixel is NOT a member of
boundary if 4-connectivity is used between
region and background. It is if 8-
connectivity is used.
Foreground and background
Suppose that the image contains K disjoint
regions Rk none of which touches the
image border .
Ru : the union of all regions .
(Ru)c : is the complement .

so Ru is called foreground , and (Ru)c : is


the background .
Foreground and Background

R1 U R2 U R3 U ….. U Rk = Foreground

(R1 U R2 U R3 U ….. U Rk )C= Background


DISTANCE MEASURES
Distance measures
If we have 3 pixels: p,q,z:
p with (x,y)
q with (s,t)
z with (v,w)
Then:

D(p,q) = 0 iff p = q
D(p,q) = D(q,p)
D(p,z) ≤ D(p,q) + D(q,z)

 Euclidean distance between p and q: De(p,q) = [(x-s)2 + (y-t)2]1/2

 D4 distance: D4(p,q) = |x-s| + |y-t|

 D8 distance: D8(p,q) = max (|x-s| , |y-t|)


 D4 and D8 distances between p and q are independent of any paths
that might exist between the points.
 For m-adjacency, Dm distance between two points is defined as the
shortest m-path between the points.
Distance measures
Distance measures
Distance measures
Example

Compute the distance between the two pixels


using the three distances : 1 2 3
q:(1,1) q
1
P: (2,2)
2 p
Euclidian distance : ((1-2)2+(1-2)2)1/2 = sqrt(2). 3
D4(City Block distance): |1-2| +|1-2| =2
D8(chessboard distance ) : max(|1-2|,|1-2|)= 1
(because it is one of the 8-neighbors )
Distance Measures

Example :
Use the city block distance to prove 4-
neighbors ? 1 2 3
1
2 d
Pixel A : | 2-2| + |1-2| = 1 3
a p c
Pixel B: | 3-2|+|2-2|= 1
b
Pixel C: |2-2|+|2-3| =1
Pixel D: |1-2| + |2-2| = 1

Now as a homework try the chessboard


distance to proof the 8- neighbors!!!!
Example: Distance Measures
1 2 3 4

1 3 1 1 3 D4 = | 1-4| +|2-4|
(q)
D4 = 3 + 2 = 5
2 1 3 2 4
D8 = max(| 1-4|,|2-4|)
3 3 2 1 4 D8 = max(3, 2) = 3

4 2 (p) 2 0 1
Euc = ((1-4)2 + (2-4)2)1/2
Euc = (32 +22 )1/2
Euc = (9 + 4)1/2
= 3.6
Example: Distance Measures

You might also like