EC-433 Digital Image Processing Lecture 4 Digital Image Fundamentals Dr. Arslan Shaukat Acknowledgement: Lecture slides material from Dr. Rehan Hafiz, Gonzalez and Woods
Interpolation Required in image resizing such as shrinking and zooming Using known data to estimate data at unknown points
1D Interpolation Linear Interpolation: Fit a linear function piecewise between the points
1D Interpolation Quadratic: Fit a Quadratic Polynomial between the three points
Interpolation Fitting Polynomial to data points
Nearest Neighbor Interpolation Simply replicate the value from neighboring pixels 1 0 1 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1
Nearest Neighbor Interpolation Severe distortion of straight edges 1 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 0 0 0 1 1
Bilinear Interpolation Use the four nearest neighbors to estimate the intensity at a given location
Bicubic Interpolation Involves the 16 nearest neighbors
Comparison of Interpolation Approaches Nearest Neighbor Bi-Linear Bi-Cubic
Basic Pixel Relationships
Neighborhood of a Pixel Co-located in space Not necessarily in intensity value N 4 (p) 4-neighbors Set of horizontal and vertical neighbors (x+1,y), (x-1,y), (x,y+1), (x,y-1) N D (p) diagonal neighbors Set of 4 diagonal neighbors (x+1,y+1), (x+1,y-1), (x-1,y+1), (x-1,y-1) N 8 (p) 8-neighbors Union of N 4 (p) & N D (p)
Neighbors N D (p) N 4 (p) 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Adjacency Two pixels that are neighbours and have the same/(similar) grey-levels are adjacent In a binary image, V = {1} if we are referring to adjacency of pixels with value 1 Two pixels p & q have: 4-Adjacency if q is in the set N 4 (p); p & q belong to V 8-Adjacency if q is in the set N 8 (p); p & q belong to V Diagonal-Adjacency if q is in the set N D (p); p & q belong to V m-adjacency (mixed adjacency): If q is in set N 4 (p); p & q belong to V OR If q is Diagonally-Adjacent BUT p & q DO NOT have any common 4-adjacent neighbours belonging to set V
Adjacency Mixed adjacency is a modification of 8-adjacency and is used to eliminate the multiple path connections that often arise when 8-adjacency is used.
Path A path from pixel p with coordinates (x,y) to pixel q with coordinates (s,t) is a sequence of distinct pixels: (x 0,y 0 ), (x 1,y 1 ),, (x n,y n ), where (x 0,y 0 ) = (x,y), (x n,y n ) = (s,t) (x i,y i ) is adjacent to (x i-1,y i -1 ), for 1 i n n is the length of the path. If (xo, yo) = (xn, yn) closed path 4, 8 and m-paths depending on adjacency m-adjacency pixels m-path Resolves the direction where to go first Preferably m-adjacency
1 1 1 1 8-Path 1 1 1 1 1 1 1 1 1 1
1 1 1 1 m-path 1 1 1 1 1 1 1 1 1 1
1 1 1 1 Closed m-path 1 1 1 1 1 1 1 1 1 1
Connectivity Connectivity in a subset S of an image Two pixels are connected if there is a path between them that lies completely within S Connected Component The set of all pixels in S that are connected to a given pixel Connected Set If S has only one connected component
Connected Components & Connected Set 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Connectivity
Regions In an image sub-section, R is a region if it is a connected set Adjacent Regions Two regions are Adjacent if their union is again a connected set Disjoint Regions Not Adjacent Adjacency to consider: 4 & 8 adjacency
Regions & their adjacency 1 1 1 1 8-Adjacency 1 1 1 1 1 1 1 1 1 1
1 1 1 1 Regions are connected sets The red box is not a region because it is not connected set 1 1 1 1 1 1 1 1 1 1
Labeling Components http://www.cse.msu.edu/~stockman/book/2002/chapters/ch3.pdf
Foreground and Background Let there be K disjoint Regions: R k None touches the image border Let R u be the union of all K-regions Foreground Points in R u Background Complement of Points in R u
1 1 1 1 Light green = Background Yellow = Foreground 1 1 1 1 1 1 1 1 1 1
Inner Boundary Boundary, Contour Set of points of R that are adjacent to points in the complement of R or The set of pixels in R that have at least one neighbor from background Must specify the connectivity Preferably 8-Adjacency
Find the boundary Assuming 4-Adjacency 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Boundary / Contour = GREEN 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Assuming 4-Adjacency Some yellow boxes should be green as well if we consider 8-adjacency Even 8-Adjacency may not form a closed path Assuming 4-Adjacency 1 1 1
To get outer boundary Outer Boundary Let Rc be the background; than Set of points in Rc that are adjacent to points in the R OR The set of pixels in Rc that have at least one neighbor from R Useful for border following algorithms
Inner Boundary / Contour = GREEN Assuming 4-Adjacency 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Assuming 4-Adjacency 4-Adjacent 1 Outer Boundary = Gray 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
8-Adjacnet Outer Boundary = Gray 1 1 Forms closed Path 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
If a region corresponds to the whole image, 1 st and last rows & columns are treated as boundary Difference Edges Intensity Discontinuities Boundaries Closed Path Some Notes