Module 2 24
Module 2 24
g[m, n] = f [m, n] ± k
• Image Negative
Basic Intensity Transformation Functions -
Gray Level Transformations
• Gamma Correction
• Log Transform
Piecewise-Linear Transformation Functions
• Contrast stretching
Contrast stretching is a process that expands the range of intensity
levels in an image so that it spans the full intensity range of the
recording medium or display device.
Contrast Stretching
• For an 8 bit input image, minimum intensity fmin>0 and maximum
intensity fmax<255(L-1), then fmin and fmax are scaled/stretched to
0 and 255 respectively, thus enhancing the contrast
f (m, n) − f min
g (m, n) = ( L − 1)
f max − f min
Here, L is the number of gray levels in the image.
• For the input image, perform contrast stretching
Histogram Processing – Contrast
Enhancement
• The histogram of a digital image with intensity levels in the range
[0, L-1] is a discrete function h(rk)= nk where rk is the kth intensity
value and nk is the number of pixels in the image with intensity rk.
Histogram Equalization
• Algorithm
Step 1: Compute a running sum of histogram values.
Step 2: Normalize by dividing by total number of pixels.
Step 3 : Multiply these values by the maximum gray – level values and
then round the result to the closest integer
Step 4 : Map the original values to the results from step3 by a one –to-
one correspondence.
Problem -1
• Perform histogram equalisation of the image
Problem -1
• Perform histogram equalisation of the image
Spatial Filtering
• Spatial filtering involves passing a weighted mask, or kernel over the
image.
• Followed by replacing the original image pixel value corresponding
to the centre of the kernel with the sum of the original pixel values
in the region corresponding to the kernel multiplied by the kernel
weights.
Spatial Filtering – Linear Operations
Linear Filtering
• In linear filtering, each pixel in the input image is replaced by a
linear combination of intensities of neighbouring pixels.
• Linear filtering can be used to smoothen an image as well as
sharpen the image.
• Image Smoothening is equivalent as low pass filtering of the image
Filter/kernel
Spatial Filtering - Numerical
• Perform Image Smoothening/Mean/Average/Low Pass filtering of
the given image matrix. Try using a 3x3 kernel for your operation.
6
Spatial Filtering - Numerical
• Perform Image Sharpening/High pass filtering of the given image
matrix. Try using a 3x3 kernel for your operation.
6
Order-Statistic (Non-linear) Filters
• Order-statistic filters are nonlinear spatial filters that rank pixels in
the image region and replace the centre pixel value with the ranking
result.
• The widely used Non-linear filters are:
• Median Filter (50th percentile)
• Minimum Filter (0th percentile)
• Maximum Filter (100th percentile)
Median Filtering (Non-Linear)
• All pixels in the neighborhood of the pixel in the original image
which are identified by the mask are sorted in the ascending (or)
descending order.
• The median of the sorted value is computed and is chosen as the
pixel value for the processed image.
Minimum Filters
• All pixels in the neighborhood of the pixel in the original image
which are identified by the mask are sorted in the ascending (or)
descending order.
• 0th percentile results in the so-called Min filter
• This filter is useful for finding the darkest points in an image.
Maximum Filters
• All pixels in the neighborhood of the pixel in the original image
which are identified by the mask are sorted in the ascending (or)
descending order.
• 100th percentile results in the so-called max filter
• This filter is useful for finding the brightest points in an image.
Order Statistic Filter - Results
Circuit Board Image with Median Filtering Max Filtering Min Filtering
Salt and Pepper Noise (kernel size 3×3) (kernel size 3×3) (kernel size 3×3)
Order Statistic Filter - Numerical
Perform Median filtering of the given input image matrix.
• Compute the median value of the marked pixel. Try using 3x3 mask
Order Statistic Filter - Numerical
Perform Median filtering of the given input image matrix.
• Compute the median value of the marked pixel. Try using 3x3 mask
Geometric Transforms / Spatial Transformation
• As the name implies, it means changing the
geometry of an image.
• Geometric transforms permit the elimination
of geometric distortion that occurs when an
image is captured.
• A spatial transformation of an image is a
geometric transformation of the image
coordinate system.
• In a spatial transformation each point (x, y) of
image A is mapped to a point (u, v) in a new
coordinate system.
TRANSLATION
Translation is a transformation that moves an object in space without
changing its shape or orientation. In homogeneous coordinates,
translation can be represented by a matrix that appends the
translation vector to the original coordinates. For example, in 2D, a
translation matrix would look like:
ROTATION
SCALING
SHEARING
WHY GEOMETRIC TRANSFORMATION ?
APPLICATION OF GEOMETRIC
TRANSFORMATION
Image Interpolation
• Image interpolation is the process of estimating the values of an
image at locations that are not part of the original pixel grid.
• Image interpolation is a useful tool for image processing and
computer vision, but it also has some limitations.
• It cannot create new details or information that are not present in
the original image, and it can introduce errors or artifacts in the
interpolated image.
Image Interpolation
• It is often used for tasks such as resizing, rotating, or distorting an
image.
• Image interpolation can be done using different methods, such as
nearest neighbor, linear, bilinear, cubic, or spline interpolation.
• Bilinear interpolation is used to compute an output pixel value
based on a weighted average of its four nearest pixels. It is mainly
used when scaling up an image, rotating it, or performing 3D
rendering.
Image Interpolation - Example
Nearest Neighbours Interpolation
Linear Interpolation
Bi-Linear Interpolation
• Bilinear interpolation is an extension of the linear interpolation for
interpolating functions of the two variables (x and y) on a 2D grid.
• The key idea is to perform linear interpolation first in one direction,
and then in the other direction.
• It considers the closest n×n neighborhood of known pixel values
surrounding an unknown pixel.
• It then takes the weighted average of these 4 pixels to arrive at the
final interpolated value.
How Bilinear Interpolation Works
Try this!