DIP Lec3
DIP Lec3
PROCESSING
LECTURE # 3
DIGITAL IMAGE
FUNDAMENTALS-I
1
3 Topics to
Cover
❑ Sampling and Quantization
❑ Image Scaling
✔ Image Zooming
✔ Image Shrinking
2
Image Digitization
4
✔ Sampling, and
✔ Quantization.
❑An image captured by a sensor is expressed as a continuous function f(x,y) of two co-
ordinates in the plane.
❑Image digitization means that the function f(x,y) is sampled into a matrix with M rows and N
columns.
❑The image quantization assigns to each continuous sample an integer value. The continuous
range of the image function f(x,y) is split into k intervals.
❑The finer the sampling (i.e., the larger M and N) and quantization (the larger K) the better the
approximation of the continuous image function f(x,y).
3
Sampling
5
❑A continuous image function f(x,y) can be sampled using a discrete grid of sampling
points in the plane.
❑Two neighboring sampling points are separated by distance Δx along the x axis
and Δy along the y axis. Distances Δx and Δy are called the sampling interval and the
matrix of samples constitutes the discrete image
4
Sampling
6
5
Quantization
7
❑The transition between continuous values of the image function (brightness) and
its digital equivalent is called quantization.
❑The number of quantization levels should be high enough for human perception of fine
shading details in the image.
❑After Sampling and Quantization we get the following f : [1; : : : ;N] [1; : : : ;M] 🡪
[0, ....., L]
6
Sampling and Quantization
8
Digitizing the
amplitude
values
Digitizing
the
coordinate
values
7
Sampling and Quantization
9
8
Spatial and Gray level Resolution
10
❑ Spatial Resolution in
resolution Space
✔ A measure of the smallest visible detail in an image stated with dots (pixels) per unit distance, dots
per inch (dpi)
9
Spatial and Gray level Resolution
11
Row Column
s s
❑ b= M x N x k or b= N^2 x k
11
Spatial and Gray level Resolution
13
13
Spatial and Gray level Resolution
15
14
Spatial and Gray level Resolution
16
15
Spatial and Gray level Resolution
17
❑The representation of an image with insufficient number of gray levels produces false edges
or boundaries in an image, a phenomenon known as False Contouring or Contouring
defect
❑False Contouring is quite visible in images displayed using 16 or less gray levels as
shown in the images of the skeleton in the previous slide
16
Spatial and Gray level Resolution
18
17
Spatial and Gray level Resolution
19
18
Aliasing and Moire Patterns
20
19
21 IMAGE
SCALING
20
Image Scaling
22
21
Image Scaling via Interpolation
23
✔ Non-adaptive.
22
Adaptive vs Non-Adaptive Algorithm
24
❑Adaptive methods change depending on what they are interpolating (sharp edges vs. smooth texture)
❑It include many algorithms in licensed software such as: Qimage, PhotoZoom Pro, Genuine
Fractals and others.
❑Non-adaptive algorithms treat all pixels equally, they include: nearest neighbor, bilinear,
bicubic, pixel replication etc..
❑The more adjacent pixels they include, the more accurate they can become, but this comes at the
expense of much longer processing time.
23
Image Scaling
25
✔ Nearest neighbor is the simplest and fastest implementation of image scaling technique.
It is very useful when speed is the main concern
✔ Nearest neighbor is the most basic and requires the least processing time of all
the interpolation algorithms because it only considers one pixel
24
Image Scaling
26
❑Pixel Replication
✔ Pixel replication is applicable when we want to increase the size of an image an integer number of
times.
✔ For example to double the size of an image we can duplicate each column, this doubles the size of
image in horizontal direction. Then we duplicate each row of the enlarged image to double the size
in the vertical direction
✔ The same procedure can be applied to enlarge the image by any integer number of times
(triple, quadruple and so on)
✔ The gray level assignment of each pixel is predetermined by the fact that new locations are exact
duplicate of old locations
25
Image Scaling
27
❑ The diagram below is for a case when all known pixel distances are equal, so
the interpolated value is simply their sum divided by four.
❑ In case the distance varies then the closer pixels are given more weightage in
the calculation
26
Image Scaling
28
❑The key idea is to perform linear interpolation first in one direction, and then again in the
other direction.
❑Suppose that we want to find the value of the unknown function f at the point P = (x,
y).
27
Image Scaling
29
where R1 = (x,y1),
where R2 = (x,y2).
29
Image Scaling
31
30
Image Scaling
32
✔ Image shrinking is done in the similar manner as zooming with one difference as now
the process of pixel replication is row column deletion. Now we can delete
every second column and row for shrinking
31
33 Basic Relationship between
pixels
32
Basic Relationship between Pixels
34
❑Neighborhood
❑ Connectivity
❑ Adjacency
❑ Paths
❑ Regions and
boundaries
33
Pixels Neighborhood
35
✔ 8 neighbors of p, denoted
34
Connectivity & Adjacency
36
❑Two pixels are said to be connected if they are adjacent in some sense
▪ For example, in a binary image with values 0 and 1, two pixels may be 4-neighbors, but
they are said to be connected only if they have the same value
❑In a binary image, V={1} if we are referring to adjacency of pixels with value 1
❑In gray scale image the idea is same but set V contains more elements. For example, in
the adjacency of pixels with the range of possible gray level values 0 to 255, set V could be
any subset of these 256 values
35
Connectivity & Adjacency
37
❑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)
• q is in the set ND(p) and the set N4(p) ∩ N4(q) has no pixels whose values are from V
q € ND(p) and N4(p) ∩ N4(q) = Ø
36
Path
38
❑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 (xo, yo), (x1, y1), …, (xn, yn)
❑We can define 4-, 8-, and m-paths based on the type of adjacency used.
37
Connectivity & Adjacency
39
❑Let S represents 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
between them consisting entirely of pixels in S
❑If it only has one connected component, then set S is called Connected set
38
Examples: Adjacency and Path
40
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
39
Examples: Adjacency and Path
41
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
8-
adjacent
40
Examples: Adjacency and Path
42
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
8- m-
adjacent adjacent
41
Examples: Adjacency and Path
43
V = {1, 2}
0 1 1 0 1 1 01 1
0 2 0 0 2 0 02 0
0 0 1 0 0 1 00 1
8- m-
adjacent adjacent
The 8-path from (1,3) to The m-path from (1,3) to
(3,3): (3,3):
(i) (1,3), (1,2), (2,2), (1,3), (1,2), (2,2), (3,3)
(3,3)
(ii) (1,3), (2,2),
(3,3) 42
43
Connected Component Labeling
44
44
Connected Component Labeling
45
45
Connected Component Labeling
46
46
Connected Component Labeling
47
47
Connected Component Labeling
48
❑At end of the scan all pixels with value 1 are labeled
❑In the second passthrough the image replace each label by the
label assigned to its equivalence classes.
48
Connected Component Labeling
49
49
Regions & Boundaries
50
❑Let R represent a subset of pixels in an image
✔ The boundary of the region R is the set of pixels in the region that have one or more neighbors that are
not in R.
✔ If R happens to be an entire image, then its boundary is defined as the set of pixels in the first and last
rows and columns of the image.
✔ An image contains K disjoint regions, Rk, k = 1, 2, …, K. Let Ru denote the union of all the K regions,
and let (Ru)c denote its complement
❑For pixels p, q and z with coordinates (x, y), (s, t), and (v, w), respectively, D is a distance
function or metric if
❑It is often useful in image processing to be able to calculate the distance between two pixels in an
image, but this is not as straightforward as it seems.
❑The presence of the pixel grid makes several so-called distance metrics possible which often
give different answers to each other for the distance between the same pair of points. We
consider the three most important ones.
✔ Euclidean distance
✔ City-block distance or D4 distance.
✔ D8 distance or chessboard distance.
51
Distance measures
52
❑ Euclidean distance
✔ If the two pixels p and q that we are considering have coordinates (x,y) and (s,t), then the
Euclidean distance between p and q is given by:
52
Distance measures
54
✔This metric assumes that in going from one pixel to the other it is only possible to travel directly
along pixel grid lines. Diagonal moves are not allowed.
✔The distance between two points is the sum of the absolute differences of their coordinates
D4(p, q)= | x - s | + | y - t |
✔The pixels having a distance D4 from (x, y) less than or equal to some value r form a diamond
centered at (x, y). E.g the pixels with D4 distance <=2 from (x, y) (the center point) form the following
contours of constant distance
53
Distance measures
55
✔ This metric assumes that you can make moves on the pixel grid as if you were
a King making moves in chess, i.e. a diagonal move counts the same as a horizontal
move
✔ The distance between two pixels is the greatest of their differences of their coordinates
✔ The pixels having a D8 distance from (x, y) less than or equal to some
value r from a squared centered at (x, y). E.g the pixels with D8 distance <=2 from (x, y)
(the center point) form the following contours of constant distance
54
Distance measures and
56
Connectivity
❑ Consider the following arrangement of pixels and assume that p,p2 and p4 have value 1 and
p1 and p3 have value 0 or 1:
p3 p4
p1 p2
❑ If p1 and p3 are zero, the length of the shortest m-path (Dm distance) between p and p4 is
❑ If p1=1 and p3=0 then p2 and p will no longer be m-adjacent and the length of the shortest m- path
becomes [Path will be p p1 p2 p4]
❑ If p1=0 and p3=1 then the length of the shortest m-path will be
❑ Finally if both p1 and p3 are 1 then the length of the shortest m-path between p and p4 is
[Path will be p p1 p2 p3 p4]
55
Image Operation on Pixel basis
58
❑As we know images are represented in the form of matrices with Rows and
Columns arrangements
❑ For example, if you want to add two images a and b then the resultant
image will be formed in a way that the first element will be formed by
the addition of the first pixel in a with the first pixel in b and so on for each
pixel
❑ The logical operators AND, OR and NOT are applied on only one image at a
time 56
References
59
1.DIP by Gonzalez
2.http://en.wikipedia.org/wiki/Bilinear_interpolation
3.http://en.wikipedia.org/wiki/Bicubic_interpolation
4.http://en.wikipedia.org/wiki/Connected-component_labeling
5.http://www.mathworks.com/help/toolbox/images/f18-34186.html
6.http://homepages.inf.ed.ac.uk/rbf/HIPR2/distance.htm
57