edge detection & image segmentation

Download Edge  Detection  &  Image Segmentation

If you can't read please download the document

Upload: ulfah

Post on 23-Feb-2016

53 views

Category:

Documents


1 download

DESCRIPTION

Edge Detection & Image Segmentation. Dr . Md. Altab Hossain Associate Professor Dept. of Computer Science & Engineering, RU. Edge Detection. Element of Image Analysis. Preprocess Image acquisition, restoration, and enhancement. Intermediate process - PowerPoint PPT Presentation

TRANSCRIPT

Image Processing Fundamentals

Edge Detection & Image SegmentationDr. Md. Altab HossainAssociate ProfessorDept. of Computer Science & Engineering, RU112Edge Detection

PreprocessImage acquisition, restoration, and enhancementIntermediate processImage segmentation and feature extractionHigh level processImage interpretation and recognitionElement of Image Analysis 31. Similarity properties of pixels inside the object are used to grouppixels into the same set.

2. Discontinuity of pixel properties at the boundary between objectand background is used to distinguish between pixels belonging to the object and those of background.

Discontinuity:Intensity changeat boundaryPoint, Line, EdgeSimilarity:Internal pixels sharethe same intensityImage Attributes for Image Segmentation 4Point Detection We can use Laplacian masksfor point detection.

Laplacian masks have the largest coefficient at the center of the maskwhile neighbor pixels have anopposite sign.

This mask will give the high response to the object that has the similar shape as the mask such as isolated points.

Notice that sum of all coefficients of the mask is equal to zero. This is due to the need that the response of the filter must be zero inside a constant intensity area-1-1-18-1-1-1-1-1-1004-1-10-105Point Detection

X-ray image of the turbine blade with porosityLaplacian imageAfter thresholdingLocation of porosityPoint detection can be done by applying the thresholding function:

(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.6

Line Detection Similar to point detection, line detection can be performedusing the mask the has the shape look similar to a part of a line

There are several directions that the line in a digital image can be.

For a simple line detection, 4 directions that are mostly used areHorizontal, +45 degree, vertical and 45 degree.(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.Line detection masks7

Line Detection Example Binary wirebond maskimage Absolute valueof result after processing with-45 line detectorResult after thresholding(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.Notice that 45 degreelines are most sensitive8Definition of EdgesEdges are significant local changes of intensity in an image.Edges typically occur on the boundary between two different regions in an image.

99What Causes Intensity Changes?Geometric events surface orientation (boundary) discontinuitiesdepth discontinuitiescolor and texture discontinuities

Non-geometric eventsillumination changesspecularitiesshadowsinter-reflections

depth discontinuitycolor discontinuityillumination discontinuitysurface normal discontinuity1010Why is Edge Detection Useful?Important features can be extracted from the edges of an image (e.g., corners, lines, curves).These features are used by higher-level computer vision algorithms (e.g., recognition).

1111Where are the edges?

1213Edge normal: unit vector in the direction of maximum intensity change.Edge direction: unit vector to perpendicular to the edge normal.Edge position or center: the image position at which the edge is located.Edge strength: related to the local image contrast along the normal.

Edge DescriptorsModeling Intensity ChangesStep edge: the image intensity abruptly changes from one value on one side of the discontinuity to a different value on the opposite side.

Ramp edge: a step edge where the intensity change is not instantaneous but occur over a finite distance.

1414Modeling Intensity Changes (contd)Ridge edge: the image intensity abruptly changes value but then returns to the starting value within some short distance (i.e., usually generated by lines).

Roof edge: a ridge edge where the intensity change is not instantaneous but occur over a finite distance (i.e., usually generated by the intersection of two surfaces).

1515Main Steps in Edge Detection(1) Smoothing: suppress as much noise as possible, without destroying true edges.(2) Enhancement: apply differentiation to enhance the quality of edges (i.e., sharpening).(3) Thresholding: determine which edge pixels should be discarded as noise and which should be retained (i.e., threshold edge magnitude).(4) Localization: determine the exact edge location. sub-pixel resolution might be required for some applications to estimate the location of an edge to better than the spacing between pixels.

1616Edge Detection Using DerivativesOften, points that lie on an edge are detected by:

(1) Detecting the local maxima or minima of the first derivative.

(2) Detecting the zero-crossings of the second derivative.

2nd derivative1st derivative1717Gray level profileThe 1st derivative-1.5-1-0.500.511.522.533.5-0.200.20.40.60.811.2-1.5-1-0.500.511.522.533.5-0.06-0.04-0.0200.020.040.06-1.5-1-0.500.511.522.533.5-5-4-3-2-1012345x 10-3EdgeEdgeMinimum pointMaximumpoint++--Zero crossingIntensitySmoothed Step Edge and Its Derivatives The 2nd derivative18Image DerivativesHow can we differentiate a digital image?

Option 1: reconstruct a continuous image, f(x,y), then compute the derivative.

Option 2: take discrete derivative (i.e., finite differences)

Consider this case first!19Edge Detection Using First Derivative

(upward) step edge (centered at x) 1D functions(not centered at x) 2020Edge Detection Using Second DerivativeApproximate finding maxima/minima of gradient magnitude by finding places where:

Cant always find discrete pixels where the second derivative is zero look for zero-crossing instead.

21

Replace x+1 with x (i.e., centered at x):

1D functions:(centered at x+1)Edge Detection Using Second Derivative (contd)2222Edge Detection Using Second Derivative (contd)

2323Edge Detection Using Second Derivative (contd)

2424Noise Effect on Images EdgesFirst column: images and gray-level profiles of a ramp edge corrupted by random Gaussian noise of mean 0 and = 0.0, 0.1, 1.0 and 10.0, respectively. Second column: first-derivative images and gray-level profiles. Third column : second-derivative images and gray-level profiles. 25

little noise can have a significant impact on the derivativesImage smoothing should be serious consideration prior to the use of derivatives in applications where noise is likely to be present.25 Edge Detection Using First Derivative (Gradient) The first derivate of an image can be computed using the gradient:

2D functions:

2626The gradient is a vector which has magnitude and direction:

Magnitude: indicates edge strength.

Direction: indicates edge direction.i.e., perpendicular to edge direction

or(approximation)Gradient Representation

2727Approximate Gradient Approximate gradient using finite differences:

2828Approximate Gradient (contd)Cartesian vs pixel-coordinates: - j corresponds to x direction - i to -y direction

2929Approximating Gradient (contd)We can implement and using the following masks:

(x+1/2,y)(x,y+1/2)**

good approximationat (x+1/2,y)good approximationat (x,y+1/2)

3030Approximating Gradient (contd)A different approximation of the gradient:

3 x 3 neighborhood:

3131Approximating Gradient (contd) and can be implemented using the following masks:

3232Another ApproximationConsider the arrangement of pixels about the pixel (i, j):

The partial derivatives can be computed by:

The constant c implies the emphasis given to pixels closer to the center of the mask.

3 x 3 neighborhood:

3333Prewitt OperatorSetting c = 1, we get the Prewitt operator:

3434Sobel OperatorSetting c = 2, we get the Sobel operator:

3535Edge Detection Steps Using Gradient

3636An Example

3737An Example (contd)

3838Comparison of Gradient based Operator

3940The Canny Edge Detector

41The Canny Edge DetectorCanny smoothing and derivatives:

42The Canny Edge DetectorCanny gradient magnitude:

imagegradient magnitudePractical IssuesChoice of threshold.

gradient magnitudelow thresholdhigh threshold4343Practical Issues (contd)Edge thinning and linking.

4444Criteria for Optimal Edge Detection(1) Good detectionMinimize the probability of false positives (i.e., spurious edges).Minimize the probability of false negatives (i.e., missing real edges).

(2) Good localizationDetected edges must be as close as possible to the true edges.

(3) Single responseMinimize the number of local maxima around the true edge.454546Edge Contour ExtractionTwo main categories of methods:local methods (extend edges by seeking the most "compatible" candidate edge in a neighborhood).global methods (more computationally expensive - domain knowledge can be incorporated in their cost function).Edge detectors typically produce short, disjoint edge segments.These segments are generally of little use until they are aggregated into extended edges.We assume that edge thinning has already be done (e.g., non-maxima suppression).47Edge Contour Extraction

48Local Processing Methods

Edge Linking using neighbor49Local Processing MethodsContour extraction using heuristic search

A more comprehensive approach to contour extraction is based on graph searching.Graph representation of edge points:(1) Edge points at position pi correspond to graph nodes.(2) The nodes are connected to each other if local edge linking rules are satisfied.50Local Processing Methods

Contour extraction using heuristic search cont.The generation of a contour (if any) from pixel pA to pixel pB the generation of a minimum-cost path in the directed graph.A cost function for a path connecting nodes p1 = pA to pN = pB could be defined as follows:

Finding a minimum-cost path is not trivial in terms of computation.51Local Processing MethodsContour extraction using dynamic programmingDynamic programmingIt is an optimization method that searches for optima of functions in which not all the variables are simultaneously interrelated.It subdivides a problem recursively into smaller sub-problems that may need to be solved in the future, solving each sub-problem proceeding from the smaller ones to the larger ones and storing the solutions in a table that can be looked up when need arises.Principle of optimality (applied to the case of graph searching): the optimal path between two nodes pA and pB can be split into two optimal sub-paths pApi and pipB for any pi lying on the optimal path pApB.52Global Processing MethodsIf the gaps between pixels are very large, local processing methods are not effective.Global methods are more effective in this case !!Hough Transform can be used to determine whether points lie on a curve of a specified shape (model-based method).Deformable Models (Snakes) can be used to extract the boundaries of objects having arbitrary shapes.Grouping can be used to decide which groups of features are likely to be part of the same object.53Image segmentation

Definition of SegmentationSegmentation: Image segmentation refers to the partition of an image into a set of regions that have a strong correlation with objects or areas of the real world.Complete segmentation (High-level): Region(s) correspond(s) uniquely with image object(s); not an easy task; requires domain specific knowledge; context is known and a priori knowledge is available and used for segmentation.Partial segmentation (Low-level): Regions do not always correspond directly with image objects. Image is divided into separate regions that are homogenous with respect to a chosen property such as brightness, color, texture, motion, etc.54Example-Complete SegmentationThe image is segmented into two regions: face and background.We know that the human face is of some certain color.Several other heuristics using the knowledge of human face can be used.Small holes and isolated regions are eliminated.

55Example-Partial Segmentation

Regions do not directly correspond to objects, but to regionsthat are similar in colorNeeds further processing5657Segmentation CriteriaSegmentation of an image I into a set of regions S should satisfy: Si = SPartition covers the whole image.Si Sj = , i jNo regions intersect. Si, P(Si) = trueHomogeneity predicate is satisfied by each region.P(Si Sj) = false,Union of adjacent regionsi j, Si adjacent Sjdoes not satisfy it.58Image segmentationSo, all we have to do is to define and implement the similarity predicate.But, what do we want to be similar in each region?Is there any property that will cause the regions to be meaningful objects?Example approaches:Histogram-basedClustering-basedRegion growingSplit-and-mergeGraph-basedHistogram-based segmentation

Global Thresholding = Choose threshold T that separates object from background.

59

Simple thresholding is not always possible:Many objects at different gray levels.Variations in background gray level.Noise in image.Histogram-based segmentation

60Local Thresholding-4 Thresholds

Divide image in to regions. Perform thresholding independently in each region.61Adaptive Thresholding

Every pixel in image is thresholded according to the histogram of the pixel neighborhood.62Any feature vector that can be associated with a pixel can be used to group pixels into clusters. Once pixels have been grouped into clusters, it is easy to find connected regions using connected components labeling.Clustering-based segmentation

K-means algorithm can be used for clustering6364Clustering-based segmentation

K-means clustering of color.65Clustering-based segmentationClustering can also be used with other features (e.g., texture) in addition to color.

Original ImagesColor RegionsTexture RegionsRegion Growing

6667Region growingUsually a statistical test is used to decide which pixels can be added to a region.Region is a population with similar statistics.Use statistical test to see if neighbor on border fits into the region population.Let R be the N pixel region so far and p be a neighboring pixel with gray level.Define the mean X and scatter S2 (sample variance) by

68Region growingThe T for a pixel p statistic is defined by

It has a TN-1 distribution if all the pixels in R and the test pixel p are independent and identically distributed Gaussians (i.i.d. assumption).

69Region growingFor the T distribution, statistical tables give us the probability Pr(T t) for a given degrees of freedom and a confidence level. From this, pick a suitable threshold t.If the computed T t for desired confidence level, add p to region R and update the mean and scatter using p.If T is too high, the value p is not likely to have arisen from the population of pixels in R. Start a new region.Many other statistical and distance-based methods have also been proposed for region growing.70Region growing

imagesegmentation

Region growing71Split and Merge Segmentation2 Stage Algorithm:

Stage 1: SplitSplit image into regions using a Quad Tree representation.

Stage 2: MergeMerge "leaves" of the Quad Tree which are neighboring and "similar".

72Quad Tree Representation

73Split and Merge Example

74Graph Based SegmentationSegmentation can be viewed as a graph partitioning problem

75Forming GraphEach pixel is treated as a node in a graph.Each pixel has an edge to its neighbours. (e.g. 8 adjacent neighbours in 2D).Edge weight w(i,j) is a function of the similarity between nodes i and j.high weight vertices are probably part of the same element.Low weight nodes are probably part of different element.76Images as graphsNodes for every pixelEdge between every pair of pixel (or every pair of sufficiently close pixels)Each edge is weighted by the affinity or similarity of the two nodes

wijij77Constructing a Graph from an ImageTwo kinds of vertices

Two kinds of edges

Cut-Segmentation

78What is a cut?A graph G = (V,E) can be partitioned into two disjoint sets, by simply removing edges connecting the two parts.The degree of dissimilarity between these two pieces can be computed as total weight of the edges that have been removed. In graph theoretic language it is called the cut:

79Example cut

80Graph CutEach cut corresponds to some cost (cut ): sum of the weights for the edges that have been removed.

81Graph Based AlgorithmsGraph Cut-Wu and Leahy 1993Segmentation by normalized-cut

82

Interactive Image Segmentation Magic Wand (198?)Intelligent Scissors [Mortensen and Barrett, 1995]GrabCut[Rother et al., 2004] Graph Cuts [Boykov and Jolly, 2001]LazySnapping[Li et al., 2004]

8383Thank You84