Computer Vision Lecture 2 PDF

Summary

This document is a lecture on computer vision, specifically focusing on digital filters. It covers various filtering techniques aimed at reducing noise and enhancing images. The lecture delves into the concepts of convolution, linear filters (mean, triangular, Gaussian), and non-linear filters (median).

Full Transcript

COMPUTER VISION DR. HEBA HAMDY Lecture 2 DIGITAL FILTERS CONTENTS ◼ In this set of slides, we will discuss what convolution and noise mean and then discuss these important smoothing filters. ◼ Linear filters: ◼ Uniform (mean) filter ◼ Triangular filter...

COMPUTER VISION DR. HEBA HAMDY Lecture 2 DIGITAL FILTERS CONTENTS ◼ In this set of slides, we will discuss what convolution and noise mean and then discuss these important smoothing filters. ◼ Linear filters: ◼ Uniform (mean) filter ◼ Triangular filter ◼ Gaussian filter ◼ Non-linear filters: ◼ Median filter ◼ Max ◼ Min DIGITAL FILTERS ◼ An image can be filtered in the spatial or frequency domain. ◼ Filtering in the spatial domain involves convolving the image with a filter function. ◼ Convolution is used in many different operators, particularly smoothing filters and feature detectors. ◼ Filtering in the frequency domain is done by transforming the image into that domain, multiplying it with the frequency filter function and re-transforming the result into the spatial domain. WHAT IS CONVOLUTION? ◼ Convolution is a mathematical operation fundamental to many operators. ◼ The inputs to the convolution process are the image we want to perform the operation on and a 2D array of numbers called the kernel (or the Image mask). ◼ The values stored in the kernel determine the nature of the operation. kernel HOW IS CONVOLUTION PERFORMED? ◼ The convolution is performed by sliding the kernel over the image, generally starting at the top left corner, so as to move the kernel through all the positions. HOW IS CONVOLUTION PERFORMED? ◼ The value of an output pixel is calculated by multiplying together the kernel value and the underlying image pixel value for each of the cells in the kernel, and then adding all these numbers together. ◼ A pixel at location [x,y]T in the output image can be calculated as: where ◼ K represents a kernel of size mxn. ◼ I]y,x[ ta ytisnetni tupni eht si )y,x(1T ◼ I(x,y) is the output intensity at [x,y]T ◼ K(x,y) is the kernel applied at [x,y]T IMAGE NOISE ◼ What is noise? ◼ Digital-camera or paper-scanned images may contain noise that degrades their quality (due to the existence of dust on the lens or faulty elements in camera, etc.). ◼ Whenever existing, noise should be reduced or dealt with as a part of a vision system. NOISE REDUCTION BY SMOOTHING ◼ Smoothing operation is meant to reduce noise in images and/or to prepare an image for further processing; an operation that we may find useful for vision systems. ◼ There are many types of noise. Among these types of noise: ◼ Salt and pepper noise. ◼ Gaussian noise. SALT AND PEPPER NOISE ◼ Salt and pepper noise is a random or independent noise. ◼ In this type of noise, the color (or intensity) of a noisy pixel has no relation to the color (or intensity) of the surrounding pixels. ◼ It is called salt and pepper noise because it appears as black and white dots. Salt and pepper noise GAUSSIAN NOISE ◼ In Gaussian noise, an amount of noise is added to every part of the image where each pixel in the image will be changed from its original value by a small amount. ◼ Here the noise is dependent on the image data. ◼ The plot of the amount of distortion produces a Gaussian distribution of noise. Gaussian noise SMOOTHING FILTERS ◼ Noise can be reduced by smoothing filters. ◼ Smoothing filters may be split into two types: ◼ Linear Filters: ◼ Uniform (mean) filter ◼ Triangular filter ◼ Gaussian filter ◼ Non-linear Filters: ◼ Median Filter. ◼ Kuwahara filter UNIFORM (MEAN) FILTER ◼ The idea is simple; replace each pixel in the output image with the mean or average of its neighbors including itself. ◼ The convolution kernel determines the shape (rectangular or circular) and the size of the neighborhood. ◼ All the coefficients (or weights) in this kernel have identical weights. ◼ The smoothing effect depends on the kernel size. The larger the kernel the larger the smoothing effect is. ◼ We have to choose the kernel size so as to compromise between noise reduction by smoothing and blurring the image. UNIFORM (MEAN) FILTER ◼ Notice that in all cases, the filter is normalized. ◼ Divide by the sum of kernel’s weights to normalize. MEAN FILTER: AN APPLICATION ◼ The left image contains Gaussian noise. ◼ The right images are after smoothing using 3x3 and 5x5 mean filters. 5x5 mean filter 3X3 MEAN FILTER: AN EXAMPLE ◼ Given below is the upper left corner of an 8-bit gray-scale image. If this image is passed through a 3x3 mean filter, what would be the result of the filtering operation? 5X5 MEAN FILTER: AN EXAMPLE ◼ Given below is the upper left corner of an 8-bit gray-scale image. If this image is passed through a 5x5 mean filter, what would be the result of the filtering operation? MEAN FILTER ◼ If I1 and I2 are two images then: ◼ Example: Show the above property on the following two upper left corners of two gray-scale images. MEAN FILTER MEAN FILTER TRIANGULAR FILTER ◼ This filter is similar to the uniform filter in terms of calculating the average. The difference is that the weights of the kernel are of different values. ◼ Again, notice that in all cases the filter is normalized. TRIANGULAR FILTER: AN EXAMPLE ◼ Given below is the upper left corner of an 8-bit gray-scale image. If this image is passed through a 5x5 pyramidal filter, what would be the result of the filtering operation? TRIANGULAR FILTER: AN EXAMPLE ◼ Given below is the upper left corner of an 8-bit gray-scale image. If this image is passed through a 5x5 cone filter, what would be the result of the filtering operation? GAUSSIAN FILTER ◼ This is also known as Gaussian blur. ◼ The kernel characterizing this filter represents the shape of a Gaussian (`bell-shaped') hump. Gaussian shape ◼ The Gaussian distribution in 1-D has the form: But we want it in where  is the standard deviation of 2D the distribution. GAUSSIAN FILTER This is a continuous Gaussian function! GAUSSIAN FILTER ◼ The continuous Gaussian function needs to be discretized in order to be applied to digital images. Discretize GAUSSIAN FILTER ◼ Below is a representation of a 5x5 kernel approximating a Gaussian with a s of 1.0. DISCRETE APPROXIMATION OF THE GAUSSIAN KERNELS 3X3, 5X5, 7X7 GAUSSIAN FILTER: AN APPLICATION ◼ The left image is a gray-scale image that is passed through different Gaussian filters using different  and kernel sizes. MEDIAN FILTER ◼ This filter is used to reduce noise while preserving details. ◼ This is similar to the mean filter but instead of replacing the output pixel with the average of the neighborhood, it replaces the pixel with the median of its neighborhood. ◼ The median is calculated by sorting the values in the neighborhood and picking the middle value to replace the output pixel. ◼ If the number of pixels in the neighborhood is even, the average of The two middle numbers is used. ◼ Notice that, unlike previous filters with odd number of neighborhood pixels, the value selected will be exactly equal to one of the existing intensities. MEDIAN FILTER: AN APPLICATION ◼ The left image contains Gaussian noise. The right image is after applying 3x3 median filter. 3x3 Median Filter MEDIAN FILTER: AN EXAMPLE ◼ Given below is the upper left corner of an 8-bit gray-scale image. If this image is passed through a 3x3 median filter, what would be the result of the filtering operation? MEDIAN FILTER: AN EXAMPLE ◼ Given below is the upper left corner of an 8-bit gray-scale image. If this image is passed through a 5x5 median filter, what would be the result of the filtering operation? Work it out yourself! 3X3 MEAN FILTER: AN EXAMPLE ◼ Unlike the previous filters, median filter is a non-linear filter. This means that if I1 and I2 are two imagesthen: ◼ Example: Show the above property on the following two upper left corners of two gray-scale images. MEDIAN FILTER MEDIAN FILTER MAX FILTER SELECTS THE LARGEST VALUE WITHIN AN ORDERED WINDOW OF PIXELS VALUES AND REPLACES THE CENTRAL PIXEL WITH THE LARGEST VALUE (LIGHTEST ONE). MIN FILYER

Use Quizgecko on...
Browser
Browser