Module 2 Linear Filter Ppt
Module 2 Linear Filter Ppt
• Some of the common types of filter are: Box Filter (or Averaging Filter),
Gaussian Filter, Median filter, Sobel Filter
• The choice of filter depends on the specific task and the characteristics of
the image being processed
Image:
[0 1 2 2 1]
[1 0 2 1 0]
[2 2 0 1 2]
[2 1 1 0 2] Filtered Image:
[1 0 2 2 0] [1 1 1 1 1]
Averaging Filter (3x3): [1 1 1 1 1]
[1 1 1 1 1]
[ 1/9 1/9 1/9 ]
[1 1 1 1 1]
[ 1/9 1/9 1/9 ] [1 1 1 1 1]
[ 1/9 1/9 1/9 ]
New pixel value = (0 * (1/9) + 1 * (1/9) + 2 * (1/9) + 1 * (1/9) + 0 * (1/9) + 2 * (1/9) + 2 * (1/9) + 1 * (1/9) + 0 * (1/9)) =
(10/9) = 1.11 (rounded to the nearest integer)
Key properties of Linear Filter
Linearity:
• The output of the filter is a linear combination of the input signal's values.
• Mathematically, if you have an input signal x[n] and a linear filter h[n], the
output y[n] is given by y[n] = x[n] * h[n], where * represents convolution.
• Also,
Shift Invariance:
• Shift the location of image and then apply a filter or apply a filter and then
shift
Convolution use the flipped kernel to slide over the image or signal,
calculating the sum of element-wise products at each position
Correlation the kernel is not flipped before being slide over the input.
Used to calculate the similarity between the image
Use of Correlation For template matching
Handling Pixels close to the boundaries
Convolution properties
Box Filter
• The simplest filter to implement is the moving average or box filter which is
used as a method for reducing noise and removing small-scale details
from an image.
• It's widely used in various applications, such as image denoising, image
resizing, and preprocessing steps in computer vision and image analysis.
• The box filter operation is equivalent to convolving the image with a kernel
of all ones and then scaling the result by dividing it by the number of
elements in the kernel, which is K * K.
Bartlett Filter:
• A smoother image can be obtained by separably convolving the image with a
piecewise linear “tent” function (also known as a Bartlett filter).
• It is often used for smoothing or averaging values over a finite window or region.
• Here the convolution operation is performed in two separate steps: one in the
horizontal direction and another in the vertical direction.
• 3x3 version of the Bartlett filter is referred to as a "bilinear kernel as the bilinear
kernel is created by combining two linear functions in both the horizontal and
vertical directions.
• The Bartlett filter uses a rectangular or square-shaped kernel, where each
element typically has an equal weight. The kernel size can vary (e.g., 3x3, 5x5,
etc.), but the weights are uniform, resulting in simple averaging.
Sobel filter
• It's used to highlight edges in an image by calculating the gradient or change in
intensity across the image.
• The filter operates by convolving the image with a pair of 3x3 kernels.
• Horizontal Central Difference: This filter looks for changes in intensity levels from
left to right. It's like checking how quickly the brightness changes as you move
horizontally across the image.
• Vertical Tent Filter: This filter helps to smooth the results. It basically takes an
average of pixel values in a vertical direction, which reduces noise and makes the
result clearer.
• The central difference filter highlights areas where the brightness changes
significantly from left to right (indicating a vertical edge), and the tent filter smooths
out the result.
Gaussian Filter
• A Gaussian filter is a type of linear filter based on the Gaussian distribution
(also known as the normal distribution) and is particularly effective at
reducing high-frequency noise while preserving the overall structure of the
data.
• The filter is characterized by a bell-shaped curve, and it's often used to
create a softer or more visually pleasing appearance in images.
• The 1D Gaussian Filter is defines as
• G(x) is the value of the Gaussian function at position x
• σ (sigma) is the standard deviation, which controls the spread of the
Gaussian curve.
• To apply the Gaussian filter to a 2D image, you convolve the image with a
2D Gaussian kernel. The kernel is a discretized version of the Gaussian
function and is given by:
• The Sobel and corner operators are simple examples of band-pass and oriented filters
• More sophisticated kernels can be created by first smoothing the image with a (unit area)
Gaussian filter, and then taking the first or second derivatives. Such filters are known
collectively as band-pass filters, since they filter out both low and high frequencies
We have gaussian filter,
Bandpass filters are designed to pass a certain range of frequencies while blocking others.
Laplacian of Gaussian (LoG) filter is discussed as a bandpass filter.
• The Laplacian of Gaussian (LoG) filter is used for edge detection and feature
extraction. The formula for the LoG filter is given as: