Presentation on theme: "Filters, Edge Detection and Sharpening Francesca Pizzorni Ferrarese 28/04/2010."— Presentation transcript:
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 limmagine pomegranateSeeds.jpg Suddividere i 3 canali dellimmagine
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
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.
Smoothing / Blurring Application of the same Gaussian filter to an intensity image (take the red layer of the previous image):
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
Edge Detection Esercizio 2 Scalare limmagine 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)
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.
Edge Stection Esercizio 3
Edge Detection Esercizio proposto Caricare limmagine mappa.jpeg. Trovare il migliore fra i filtri per ledge detection in modo da mettere in evidenza i confini.
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':
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.
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:
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.
Line Detection Esercizio 5 Applying these filters to an image containing differently slanted edges reveals differently emphasized edge types
Line Detection Identificare le linee orizzontali e verticali di linee1 e linee2 utilizzando conv2