# DREAM PLAN IDEA IMPLEMENTATION 1. 2 3 Introduction to Image Processing Dr. Kourosh Kiani

## Presentation on theme: "DREAM PLAN IDEA IMPLEMENTATION 1. 2 3 Introduction to Image Processing Dr. Kourosh Kiani"— Presentation transcript:

DREAM PLAN IDEA IMPLEMENTATION 1

2

3 Introduction to Image Processing Dr. Kourosh Kiani Email: kkiani2004@yahoo.comkkiani2004@yahoo.com Email: Kourosh.kiani@aut.ac.irKourosh.kiani@aut.ac.ir Email: Kourosh.kiani@semnan.ac.irKourosh.kiani@semnan.ac.ir Web: www.kouroshkiani.comwww.kouroshkiani.com Present to: Amirkabir University of Technology (Tehran Polytechnic) & Semnan University

Lecture 11 4 Introduction to Edge Detection

Edge : an edge is a significant, local change in the image intensity. Edge Detection : Why we do it.  Humans can recognize an enormous range of objects from just line images.  Human visual system performs some sort of edge detection prior to recognition on color or intensity images.  Drastically reduces data to be processed.  Preserves the structural information.  Edge detection contributes significantly to algorithms for feature detection, segmentation, and motion analysis  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).

What Causes Intensity Changes? Geometric events – surface orientation (boundary) discontinuities – depth discontinuities – color and texture discontinuities Non-geometric events – illumination changes – specularities – shadows – inter-reflections depth discontinuity color discontinuity illumination discontinuity surface normal discontinuity

LetFind

LetFind

Gradient Example 1Gradient Example 1: A scalar field is defined by: T = 10 + x for -10 < x < 10 The field T is displayed graphically in the figure, wherein the brightness of the image at a given location is proportional to the magnitude of T at that location The gradient of T is then given by i. This vector function is plotted below.

Gradient Example 2Gradient Example 2: A scalar field is defined by: T = x 2 for -10 < x < 10 The field T is displayed graphically in the figure, wherein the brightness of the image at a given location is proportional to the magnitude of T at that location The gradient of T is then given by 2xi. This vector function is plotted below.

Gradient Example 3Gradient Example 3: A scalar field is defined by: T = 20 + x + y for -10 < x,y < 10 The field T is displayed graphically in the figure, wherein the brightness of the image at a given location is proportional to the magnitude of T at that location The gradient of T is then given by i + j. This vector function is plotted below.

Gradient Example 4Gradient Example 4: A scalar field is defined by: T = 100 + xy for -10 < x,y < 10 The field T is displayed graphically in the figure, wherein the brightness of the image at a given location is proportional to the magnitude of T at that location The gradient of T is then given by yi + xj. This vector function is plotted below.

Gradient ExampleGradient Example 5 : A scalar field is defined by: T = x 2 y 2 for -10 < x,y < 10 The field T is displayed graphically in the figure, wherein the brightness of the image at a given location is proportional to the magnitude of T at that location The gradient of T is then given by 2xy 2 i + 2x 2 yj. This vector function is plotted below.

Gradient ExampleGradient Example 6 : A scalar field is defined by: T = 1 + sin (2px/6) for -10 < x < 10 The field T is displayed graphically in the figure, wherein the brightness of the image at a given location is proportional to the magnitude of T at that location The gradient of T is then given by (2p/6) cos(2px/6) i. This vector function is plotted below.

Change No Change

Change

Much Change Gradient direction is perpendicular to edge. Gradient Magnitude measures edge strength.

Edge Profiles Sharp discontinuities do not exist in real images because of low-frequency components or the smoothing introduced by image acquisition. Step edges become ramp edges, and line edges become roof edges, where intensity changes are not instantaneous but occur over a finite distance. We concentrate on step (ramp) edges because they are more commonly encountered.

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

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

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). Edge Profiles

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). Edge Profiles

Edge Detection Using Derivatives Often, 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. 2 nd derivative 1 st derivative

Image Derivatives How 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!

Edge Detection Using First Derivative ramp edge roof edge (upward) step edge (downward) step edge (centered at x) 1D functions (not centered at x)

Edge Detection Using Second Derivative Approximate finding maxima/minima of gradient magnitude by finding places where: Can’t always find discrete pixels where the second derivative is zero – look for zero- crossing instead.

Replace x+1 with x (i.e., centered at x): 1D functions: (centered at x+1) Edge Detection Using Second Derivative (cont’d)

Derivative filters

A B

1 st Derivative The formula for the 1 st derivative of a function is as follows: It’s just the difference between subsequent values and measures the rate of change of the function

1 st Derivative (cont…) 5543210006000013100007777 0 006-600012-20007000 f(x) f’(x)

2 nd Derivative The formula for the 2 nd derivative of a function is as follows: Simply takes into account the values both before and after the current value

2 nd Derivative (cont…) 5543210006000013100007777 0000106 -12 60011-411007-700 f(x) f’’(x)

1 st and 2 nd Derivative f(x) f’(x) f’’(x)

Noise Suppression Consider a single row or column of the image Where is the edge??

Where is the edge? Solution: Smoothing Filter Look for peaks in

Effect Smoothing on Derivates Where is the edge??

Effect of Smoothing on Derivatives

Combine Smoothing with Differentiation (i.e., saves one operation)

Main 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).

Main Steps in Edge Detection (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.

Using Second Derivatives For Image Enhancement The 2 nd derivative is more useful for image enhancement than the 1 st derivative – Stronger response to fine detail – Simpler implementation – We will come back to the 1 st order derivative later on The first sharpening filter we will look at is the Laplacian – Isotropic – One of the simplest sharpening filters – We will look at a digital implementation

First and Second-order derivative of f(x,y)  We consider an image function of two variables, f(x,y),  We deal with partial derivatives along the two spatial axes.

The Laplacian is defined as follows: where the partial 1 st order derivative in the x direction is defined as follows: and in the y direction as follows: 2 nd Derivatives – The Laplacian

So, the Laplacian can be given as follows: We can easily build a filter based on this 010 1-41 010 2 nd Derivatives – The Laplacian

Basic Edge Detection 1 Step INPUT IMAGE Edge Enhancement Horizontal [-1 0 1] Vertical [-1 0 1] T But what about susceptibility to noise?

Basic Edge Detection 2 Step INPUT IMAGE Edge Enhancement Horizontal [-1 0 1] Vertical [-1 0 1] T Noise Smoothing

gradient magnitude low threshold high threshold

gradient magnitude low threshold high threshold

1st Derivative Filtering The magnitude of this vector is given by: For practical reasons this can be simplified as:

1st Derivative Filtering (cont…) Now we want to define digital approximations and their Filter Masks For simplicity we use a 3x3 region For example z 5 denotes f(x,y), z 1 denotes f(x-1,y-1) A simple approximation for First Derivative is z1z1 z2z2 z3z3 z4z4 z5z5 z6z6 z7z7 z8z8 z9z9

1st Derivative Filtering A simple approximation for First Derivative is z1z1 z2z2 z3z3 z4z4 z5z5 z6z6 z7z7 z8z8 z9z9 Two other definitions proposed by Roberts use cross- difference If we use

1st Derivative Filtering z1z1 z2z2 z3z3 z4z4 z5z5 z6z6 z7z7 z8z8 z9z9 If we use absolute values then The Masks corresponding to these equations are: Roberts Cross-Gradient Operators

Normally the smallest mask used is of size 3 x 3 Based on the concept of approximating the gradient several spatial masks have been proposed: