filters, edge detection and sharpening francesca pizzorni ferrarese 28/04/2010

17
Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Upload: natalie-mccurdy

Post on 27-Mar-2015

218 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Filters, Edge Detection and Sharpening

Francesca Pizzorni Ferrarese28/04/2010

Page 2: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Introduction Any operation in the spatial domain

corresponds to an operation that can be described in the frequency domain, and hence filters tend to be explained in both domains. Esercizio 1

Caricare l’immagine pomegranateSeeds.jpg Suddividere i 3 canali dell’immagine

Page 3: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Filters Common 2D filters can be built in Matlab by using built-in

function fspecial (special filters). fspecial(filtername, paramaters, ...) = matrix of values

representing the filter. fspecial defines the following common filters:

average : averaging filter disk : circular averaging filter gaussian : Gaussian lowpass filter laplacian : filter approximating the 2-D Laplacian operator log : Laplacian of Gaussian filter motion : motion filter prewitt : Prewitt horizontal edge-emphasizing filter sobel : Sobel horizontal edge-emphasizing filter unsharp : unsharp contrast enhancement filter

Filters are applied to multi-dimensional images (RGB images = 3D matrices) using function imfilter , and are applied to intensity images (2D matrices) using function filter2

Page 4: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Smoothing / Blurring

The process of smoothing or blurring and image supresses noise and small fluctuations. In the frequency domain, this process refers to the supression of high frequencies.

A smoothing filter can be built in Matlab by using function fspecial (special filters): build a gaussian filter matrix of 7 rows and 7

columns, with standard deviation of 5.

Page 5: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Smoothing / Blurring Application of the same Gaussian filter to an

intensity image (take the red layer of the previous image):

Page 6: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Edge Detection The process of edge detection attenuates high

fluctuations in color, i.e. dramatic change in intensity. In the frequency domain, this process refers to the attenuation of high frequencies.

Matlab includes the built-in function edge designed for edge detection. It supports the following types of edge detectors:

sobel prewitt roberts log (laplacian) canny zerocross

Page 7: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Edge Detection Esercizio 2

Scalare l’immagine pomegranate Extract edges for each color layer (red, green, and

blue), and place the edge intensity images in a matrix which will resemble a multi-dimensional color (RGB) image (use ‘sobel’)

Page 8: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Edge Detection We can also show the composite (color) edge

images, which combine information from all three channels. The figure shows a color edge image and a combined

intensity image.

Page 9: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Edge Stection Esercizio 3

Page 10: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Edge Detection Esercizio proposto

Caricare l’immagine mappa.jpeg. Trovare il migliore fra i filtri per l’edge detection in modo da mettere in evidenza i confini.

Page 11: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Sharpening The process of sharpening is related to edge

detection - changes in color are attenuated to create an effect of sharper edges.

Using a fspecial , we create a filter for sharpening an image. The special filter is ironically named 'unsharp':

Page 12: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Sharpening The process of sharpening an image is quite

interesting and ironic: In order to sharpen an image, it is first blurred, edges are detected in the blurred version, and finally added to the blurred image to create a sharper image. Esercizio 4

Creare il filtro gaussiano 5x5

Values in a Gaussian filter are used as weights to mix a given input pixel and its neighboring pixels to create an output pixel which has been "smudged" with its neighborhood. Accordingly, the center value is the largest, corresponding to an input pixel. Values decrease towards the edge of the filter matrix, corresponding to neighboring pixels.

Page 13: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Sharpening The matrix must be normalized such that the

sum of values is equal to one. If the sum of weights is smaller or greater than one, the brightness of the image is decreased or increased. Convolve image using the filter Create a filter for edge detection. We will use a

Laplacian filter. We will use a Laplacian filter. Note that the sum of values

is equal to zero, which means that overall brightess is not preserved. In fact, the resulting image is mostly black with only a few lines denoting edges.

Finally, we add the edge image to the blurred image to create the final sharp version:

Page 14: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Sharpening

Page 15: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Line Detection Line detection is a special type of edge

detection. In edge detection, a pixel is attenuated, if there is a dramatic change in color in any direction. For line detection, the direction in which a color change is considered is restricted.

The following tables outline a Laplacian for edge detection, and their line detection counterparts.

Page 16: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Line Detection Esercizio 5

Applying these filters to an image containing differently slanted edges reveals differently emphasized edge types

Page 17: Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010

Line Detection Identificare le linee orizzontali e verticali di linee1

e linee2 utilizzando conv2