
Dr. D. J. Jackson Lecture 3-1Electrical & Computer Engineering
Computer Vision &
Digital Image Processing
Basic Image Processing Operations
Dr. D. J. Jackson Lecture 3-2Electrical & Computer Engineering
Distance measures
•Given pixels p, q, and zat (x,y), (s,t) and (u,v) respectively,
•Dis a distance function (or metric) if:
–D(p,q) ≥0 (D(p,q)=0 iff p=q),
–D(p,q) = D(q,p), and
–D(p,z) ≤D(p,q) + D(q,z).
•The Euclidean distance between pand qis given by:
•The pixels having distance less than or equal to some value
rfrom (x,y) are the points contained in a disk of radius r
centered at (x,y)
22 )()(),( tysxqpDe−+−=
Dr. D. J. Jackson Lecture 3-3Electrical & Computer Engineering
Distance measures (continued)
•The D4distance (also called the city block distance)
between pand qis given by:
•The pixels having a D4distance less than some rfrom (x,y)
form a diamond centered at (x,y)
•Example: pixels where D4≤2
tysxqpD −+−=),(
4
2
2 1 2
2 1 0 1 2
2 1 2
2
Note: Pixels with D4=1
are the 4-neighbors
of (x,y)
Dr. D. J. Jackson Lecture 3-4Electrical & Computer Engineering
Distance measures (continued)
•The D8distance (also called the chessboard distance)
between pand qis given by:
•The pixels having a D8distance less than some rfrom (x,y)
form a square centered at (x,y)
•Example: pixels where D8≤2
),max(),(
8tysxqpD −−=
2 2 2 2 2
2 1 1 1 2
2 1 0 1 2
2 1 1 1 2
2 2 2 2 2
Note: Pixels with D8=1
are the 8-neighbors
of (x,y)
Dr. D. J. Jackson Lecture 3-5Electrical & Computer Engineering
Distance measures and connectivity
•The D4distance between two points pand qis the shortest
4-path between the two points
•The D8distance between two points pand qis the shortest
8-path between the two points
•D4and D8may be considered, regardless of whether a
connected path exists between them , because the definition
of these distances involves only the pixel coordinates
•For m-connectivity, the value of the distance (the length of
the path) between two points depends on the values of the
pixels along the path
Dr. D. J. Jackson Lecture 3-6Electrical & Computer Engineering
Distance measures and m-connectivity
•Consider the given arrangement of pixels and assume
–p, p2and p4=1
–p1and p3can be 0 or 1
•If V={1} and p1and p3are 0, the m-distance (p, p4) is 2
•If either p1or p3are 1, the m-distance (p, p4) is 3
•If p1and p3are 1, the m-distance (p, p4) is 4
p3p4
p1p2
p