720 likes | 1.77k Views
Digital Image Processing “Edge Detection”. Edge Detection. What are edges in an image? Edge Detection Edge Detection Methods Edge Operators Matlab Program. What are edges in an image?. Edges are those places in an image that correspond to object boundaries.
E N D
Edge Detection • What are edges in an image? • Edge Detection • Edge Detection Methods • Edge Operators • MatlabProgram
What are edges in an image? • Edges are those places in an image that correspond to object boundaries. • Edges are pixels where image brightness changes abruptly. • Edges are used frequently for segmenting images based on local changes in intencity Brightness Spatial Coordinates
Edge Detection • Convert 2D image into a set of curves • Edge may represents an image and contain shape information
Edge is Where Change Occurs • Edge information in an image is found by looking at the relationship a pixel has with its neighborhoods. • If a pixel’s gray-level value is similar to those around it, there is probably not an edge at that point. • If a pixel’s has neighbors with widely varying gray levels, it may present an edge point. • Change is measured by derivative in 1D • Biggest change, derivative has maximum magnitude • Or 2nd derivative is zero.
Edge detectors • locate sharp changes in the intensity function • edges are pixels where brightness changes abruptly. • Calculus describes changes of continuous functions using derivatives; an image function depends on two variables - partial derivatives. • A change of the image function can be described by a gradient that points in the direction of the largest growth of the image function. • An edge is a property attached to an individual pixel and is calculated from the image function behavior in a neighborhood of the pixel.
The gradient direction gives the direction of maximal growth of the function, e.g., from black (f(i,j)=0) to white (f(i,j)=255). • This is illustrated below; closed lines are lines of the same brightness. • Boundary and its parts (edges) are perpendicular to the direction of the gradient.
The gradient direction is given by: • how does this relate to the direction of the edge? • The edge strength is given by the gradient magnitude Image gradient • The gradient of an image: • The gradient points in the direction of most rapid change in intensity
The discrete gradient • How can we differentiate a digital image f[x,y]? • Option 1: reconstruct a continuous image, then take gradient • Option 2: take discrete derivative (finite difference) How would you implement this as a cross-correlation?
The Sobel operator • Better approximations of the derivatives exist • The Sobel operators below are very commonly used • The standard defn. of the Sobel operator omits the 1/8 term • doesn’t make a difference for edge detection • the 1/8 term is needed to get the right gradient value, however
Gradient operators (a): Roberts’ cross operator (b): 3x3 Prewitt operator (c): Sobel operator (d) 4x4 Prewitt operator
Roberts Operator • Mark edge point only • No information about edge orientation • Work best with binary images • Primary disadvantage: • High sensitivity to noise • Few pixels are used to approximate the gradient
Roberts Operator (Cont.) • First form of Roberts Operator • Second form of Roberts Operator
Prewitt Operator • Looks for edges in both horizontal and vertical directions, then combine the information into a single metric. Edge Magnitude = Edge Direction =
Sobel Operator • Similar to the Prewitt, with different mask coefficients: Edge Magnitude = Edge Direction =
Effects of noise • Consider a single row or column of the image • Plotting intensity as a function of position gives a signal Where is the edge?
Look for peaks in Solution: smooth first Where is the edge?
Derivative theorem of convolution • This saves us one operation:
Laplacian of Gaussian • Consider Laplacian of Gaussian operator Where is the edge? Zero-crossings of bottom graph
2D edge detection filters • is the Laplacian operator: Laplacian of Gaussian Gaussian derivative of Gaussian
Laplacian Operators • Edge magnitude is approximated in digital images by a convolution sum. • The sign of the result (+ or -) from two adjacent pixels provide edge orientation and tells us which side of edge brighter
Laplacian Operators (Cont.) • Masks for 4 and 8 neighborhoods • Mask with stressed significance of the central pixel or its neighborhood
A Matlab Quick Note • Matlab’s image processing toolbox provides edge function to find edges in an image: I = imread('rice.tif'); BW1 = edge(I,'prewitt'); BW2 = edge(I,'canny'); imshow(BW1) figure, imshow(BW2) • Edge function supports six different edge-finding methods: Sobel, Prewitt, Roberts, Laplacian of Gaussian, Zero-cross, and Canny.