COMP 9517 Computer Vision Binary Image Analysis 4/15/2018 COMP 9517 S2, 2009
Binary Image Analysis How to do this? ? 4/15/2018 COMP 9517 S2, 2009
Binary Image Analysis How to obtain binary images from scale-level images? How to extract connected groups of pixels (components)? How to process the separate components? How to extract properties of components for use in high-level tasks? 4/15/2018 COMP 9517 S2, 2009
Binary Image Definition: A binary image is a digital image with all pixel values 0 or 1 Foreground: a subset of image pixels that are of interest in an image analysis task Background: the rest of the image A binary image B can be obtained from a gray-scale image or colour image through a selection operator: Thresholding: subset of gray tones or colour space Classification, segmentation, etc 4/15/2018 COMP 9517 S2, 2009
Binary Image Example A gray-scale image contains the character “C” Threshold t=200 to obtain a binary image 1s denote foreground pixels, 0s background pixels 1 4/15/2018 COMP 9517 S2, 2009
Binary Image Analysis Thresholding: convert gray scale image to binary image Labelling: connected component labelling Counting: object counting Thinning & Thickening: join and/or separate components Component Properties: extract features for higher level processes 4/15/2018 COMP 9517 S2, 2009
Applications Document analysis Industrial machine vision Counting, recognition, localisation and inspection tasks 4/15/2018 COMP 9517 S2, 2009
Thresholding Binary image can be obtained from gray-scale images by thresholding Choose foreground and background based on the distribution of gray tones Types of thresholding: threshold above: p ≥ the threshold t threshold below: p < t threshold inside: t1 ≤ p < t2 threshold outside: p < t1 or p ≥ t2 4/15/2018 COMP 9517 S2, 2009
How to choose the thresholds The basis for choosing a threshold is the histogram of the gray-tone image The histogram h of gray-tone image I is defined by Where m spans the gray-level values. 4/15/2018 COMP 9517 S2, 2009
Compute A Histogram Compute the histogram H of gray-scale image I Procedure histogram(I,H) { //Initialise the bins of the histogram to zero. for i=0 to MaxVal H[i] = 0; //Compute values by accumulation. for r=0 to MaxRow for c=0 to MaxCol { grayval = I[r,c]; H[grayval] = H[grayval] + 1; } 4/15/2018 COMP 9517 S2, 2009
Threshold from Histogram Bimodal: one mode corresponding to dark pixels the other one corresponding to light pixels choose any value in the valley between two modes Overlapped modes – more difficult t t 4/15/2018 COMP 9517 S2, 2009
Pixel and Neighbourhoods Not only the value of a pixel but also its neighbours are used 4-neighbours and 8-neighbours N4[r,c]: {[r-1,c],[r+1,c],[r,c-1], and [r,c+1]} N8[r,c]: N4[r,c] + {[r-1,c-1], [r-1,c+1], [r+1, c-1], and [r+1,c-1]} A pixel [r’,c’] neighbours a pixel [r,c] if [r’,c’] lies in the selected type of neighbourhood of [r,c] N W * E S NW N NE W * E SW S SE 4/15/2018 COMP 9517 S2, 2009
Masks Mask: a set of pixel positions and corresponding values called weights Origin of a mask: usually the centre of the mask 1 1 2 4 1 4/15/2018 COMP 9517 S2, 2009
Applying a Mask Convolution: apply a mask to an image yields same size output image for each pixel, place the mask on the image with the mask origin on that pixel value of pixel under the mask multiplied by the corresponding mask weight summed up to a single output value for the pixel 4/15/2018 COMP 9517 S2, 2009
Example of Applying a Mask 40 80 640 800 1120 1280 40 50 70 80 1 2 4 the sum of the weights 4/15/2018 COMP 9517 S2, 2009
Example of Applying a Mask 40 80 *1 *2 *4 40 80 640 40 80 40 80 *1 *2 *4 640 800 1 2 4 4/15/2018 COMP 9517 S2, 2009
Connected Component Labelling Definition: a connected component labelling of a binary image B is a labelled image LB in which the value of each pixel is the label of its connected component. 1 1 2 3 4/15/2018 COMP 9517 S2, 2009
Recursive Labelling B is the original binary image; LB will be the labelled connected component image. Recursive_connected_components(B, LB) { LB = negate(B); label = 0; Find_components(LB, label); } Find_components(LB,label){ for (r=0 to MaxRow) for (c=0 to MaxCol) if (LB[r, c]==-1){ label = label + 1; Search(LB, label, r, c); Search(LB, label, r, c) { LB[r, c] = label; Nset = neighbours(r, c); for ([r’, c’] in Nset) if (LB[r’, c’]==-1) Search(LB, label, r, c); 4/15/2018 COMP 9517 S2, 2009
Recursive Labelling 4/15/2018 COMP 9517 S2, 2009 1 2 * 3 4 1 -1 1 -1 1 1 -1 1 -1 1 -1 1 2 -1 1 2 -1 4/15/2018 COMP 9517 S2, 2009
Binary Image Morphology Morphology refers to form, structure and the shape of a region in computer vision Mathematical morphology: set operations Structuring element: a shape presented by a binary image, any size and arbitrary structure Common structuring element: Box, Disk & Ring 1 1 1 4/15/2018 COMP 9517 S2, 2009
Basic Morphology Operations Dilation: enlarges a region Erosion: makes a region smaller Closing: closes up internal holes and eliminate bays on boundaries Opening: gets rid of juts 4/15/2018 COMP 9517 S2, 2009
Dilation Definition: the dilation of a binary image B by structuring element S is denoted by and is defined by S is swept over B When the origin of S touches 1 in B, S is ORed to the output image 4/15/2018 COMP 9517 S2, 2009
Dilation 1 1 1 S 1 1 1 1 B 1 1 1 4/15/2018 COMP 9517 S2, 2009
Erosion Definition: the erosion of a binary image B by structuring element S is denoted by B S and is defined by B S S is swept over B When every element of S covers a 1-pixel in B, the pixel in B corresponding to the origin of S is ORed to the output image 4/15/2018 COMP 9517 S2, 2009
Erosion 1 1 S 1 1 1 1 B 1 1 4/15/2018 COMP 9517 S2, 2009
Closing Definition: The closing of a binary image B by structuring element S is denote by and is defined by 1 S 1 1 1 B 4/15/2018 COMP 9517 S2, 2009
Opening Definition: the opening of a binary image B by structuring element S is denoted by and is defined by 1 S 1 1 1 B 4/15/2018 COMP 9517 S2, 2009
Conditional Dilation Remove noise by erosion, but want to keep entire components Definition: give an original binary image B, a processed binary image C and a structuring element S, let and . The conditional dilation of C by S with respect to B is defined by where the index m is the smallest index satisfy 4/15/2018 COMP 9517 S2, 2009
Conditional Dilation C is repeatedly dilated by S, and each result is reduce to only the pixels that were 1s in B 1 1 V S 1 1 1 1 B C AND 4/15/2018 COMP 9517 S2, 2009
Other Morphological Algorithms Boundary extraction 4/15/2018 COMP 9517 S2, 2009
Basic Morphological Algorithms Region Filling 4/15/2018 COMP 9517 S2, 2009
Applications of Morphology Opening & closing to separate components and remove holes Thresholding Opening + Closing 4/15/2018 COMP 9517 S2, 2009
Applications of Morphology Industrial inspection – identify defects hole_ring, hole_mask, gear_body, sampling_ring_spacer, sampling_ring_width, tip_spacing , defect_cue a b c d f g h e 4/15/2018 COMP 9517 S2, 2009
Applications of Morphology Feature extraction Extract shape corners Original image B Resultant opening R Corner image C=B-R 4/15/2018 COMP 9517 S2, 2009
Region Properties Properties of the regions as input to higher- level procedures for decision making Area: Centroid: Perimeter 4/15/2018 COMP 9517 S2, 2009
Region Properties Perimeter length Circularity Mean radial distance Standard deviation of radial distance 4/15/2018 COMP 9517 S2, 2009
Region Properties Bounding box and extremal points Extremal axis length 4/15/2018 COMP 9517 S2, 2009
Region Properties Second-order row moment Second-order column moment Second-order mixed moment 4/15/2018 COMP 9517 S2, 2009
Region Adjacency Graphs Definition: a region adjacency graph(RAG) is a graph in which each node represents a region of the image, and an edge connects two nodes if the two regions are adjacent. 1 2 -1 3 -2 -3 1 -1 2 -3 3 -2 4/15/2018 COMP 9517 S2, 2009
References Shaoo, P.K., and others. 1988. A survey of thresholding techniques. Compu. Vision, Graphics, and Image Proc. V.41:233-260. Rosefeld,A., and J.L. Pfaltz, 1966. Sequential operations in digital picture processing. Journal of the Association for Computing Machinery, Vol. 13: 471-494. Serra, J. 1982. Image Analysis and Mathematical Morphology. Academic Press, New York. 4/15/2018 COMP 9517 S2, 2009
Acknowledgement Some material, including images and tables, were drawn from the textbook and Digital Image Processing by Gonzalesz and Woods. 4/15/2018 COMP 9517 S2, 2009