Module2 ImageEnhancement Preprocess
Module2 ImageEnhancement Preprocess
Pixel Relationships
Digital Image Representation
• A digital image is a two-dimensional discrete signal.
• A digital image is also an N × N array of elements.
• Each element in the array is a number which represents the sampled
intensity.
Neighbours of a Pixel
A pixel p at coordinates has four horizontal and The four diagonal neighbors of p and four horizontal and
vertical neighbors vertical neighbors of p produce
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 input image, minimum intensity fmin>0 and maximum
intensity fmax<255(L), then fmin and fmax are scaled/stretched to 0
and 255 respectively, thus enhancing the contrast
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
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!