DIP Unit 2
DIP Unit 2
S=T*r
Let,
R = f(x,y)
S = g(x,y)
‘r’ and ‘s’ are used to denote gray levels of f and g at(x,y)
1. Linear
2. Logarithmic
3. Power – law
Logarithmic transformations
Logarithmic transformation is divided into two types:
1. Log transformation
2. Inverse log transformation
S = c log(r + 1)
Here, s and r are the pixel values for input and output image. And c is
constant. In the formula, we can see that 1 is added to each pixel value this
is because if pixel intensity is zero in the image then log(0) is infinity so, to
have minimum value one is added.
Formula:
S = cr ^ γ
All display devices have their own gamma correction. That is why images are
displayed at different intensity.
What is a Histogram?
A histogram is a graphical representation of the distribution of pixel intensity
values in an image. The horizontal axis represents the intensity values (from
0 to 255 for an 8-bit image), and the vertical axis represents the frequency of
these values.
1. Histogram Equalization
Purpose: Enhances the contrast of an image by spreading out the
most frequent intensity values.
How it Works: It transforms the intensity values so that the
histogram of the output image is approximately uniform. This is
achieved by using the cumulative distribution function (CDF) of
the pixel values.
Applications: Useful in medical imaging, satellite imagery, and
other fields where contrast enhancement is crucial.
2. Histogram Matching (Specification)
Purpose: Adjusts the histogram of an image to match a specified
histogram.
How it Works: It involves transforming the pixel values of the
input image so that its histogram matches the histogram of a
reference image.
Applications: Used in image comparison and quality control.
3. Histogram Stretching
Purpose: Increases the contrast of an image by stretching the
range of intensity values.
How it Works: It linearly scales the pixel values to cover the full
intensity range (0 to 255 for an 8-bit image).
Applications: Enhances images with low contrast due to poor
lighting conditions
4. Histogram Sliding
Purpose: Adjusts the brightness of an image.
How it Works: It shifts the histogram to the right or left,
increasing or decreasing the brightness of the image.
Applications: Useful for correcting images that are too dark or too
bright.
Arithmetic Operations
Arithmetic operations involve basic mathematical calculations applied to the
pixel values of an image. These operations are useful for tasks like blending,
masking, noise reduction, and brightness adjustments.
1. Image Addition:
Adds the pixel values of two images. This can be used to increase the
brightness of an image or blend two images together.
Formula : s(x, y) = f(x, y) + g(x, y)
Where f(x, y) and g(x, y) are the pixel values of two images at
coordinates (x, y), and s(x, y) is the output pixel value.
2. Image Subtraction:
Subtracts the pixel values of one image from another, useful for
detecting changes between images or highlighting differences (e.g.,
background subtraction in motion detection).
Formula : s(x, y) = f(x, y) – g(х,у)
Where s(x, y) is the resulting image, highlighting only the changes.
3. Image Multiplication (Scaling):
Multiplies pixel values by a constant, often used to adjust the contrast
or intensity levels in an image.
Formula:S(x, y) = c × f(x, y)
Where c is a constant multiplier.
4. Image Division:
Divides the pixel values of an image by another image or a constant,
used for normalization or to create effects like shading correction.
Formula: s(x, y) = f(x,y)/ g(x,y)
Logical Operations
Logical operations involve bitwise operations on pixel values, such as AND,
OR, XOR, and NOT. These are especially useful for creating masks,
segmenting regions, or combining images in a specific manner.
Used for masking, where only the common (overlapping) parts of two images
are kept.
OR Operation:
Combines two images by including pixels from either image, useful for
merging different regions of interest.
XOR Operation:
NOT Operation:
Spatial Filtering
Spatial Filtering technique is used directly on pixels of an image. Mask is
usually considered to be added in size so that it has specific center pixel.
This mask is moved on the image such that the center of the mask traverses
all image pixels.
What is a Spatial Filter?
A spatial filter is a digital signal processing technique used to manipulate
images, by removing or enhancing specific frequency components or spatial
frequencies. It is a type of image filtering aimed at spatially filtering an
image, which means filtering pixels based on its surrounding pixels. Spatial
filtering is a common technique in image processing, where it is used to
enhance the quality of images, remove noise, or extract specific features.