U2
U2
UNIT 2
2.1 INTRODUCTION TO COLOR SPACES
Color spaces are the mathematical representation of a set of colors. There are many color
models. Some of them are RGB, CMYK, YIQ, HSV, and HLS, etc. These color spaces are
directly related to saturation and brightness. All of these color spaces can be derived using
RGB information using devices such as cameras and scanners.
• 8 older technologies. 8 bit color format is one of the most famous image format. It has
256 different shades of colors in it. It is commonly known as Grayscale image.The
range of the colors in 8 bit vary from 0-255. Where 0 stands for black, and 255 stands
for white, and 127 stands for gray color.
RGB stands for Red, Green, and Blue. This color space is widely used in computer graphics.
RGB are the main colors from which many colors can be made.
CMYK stands for Cyan, Magenta, Yellow and Black. CMYK color model is used in
electrostatic and ink-jet plotters which deposits the pigmentation on paper. In these model,
specified color is subtracted from the white light rather than adding blackness. It follows the
Cartesian coordinate system and its subset is a unit cube.
HSV stands for Hue, Saturation, and Value (brightness). It is a hexcone subset of the
cylindrical coordinate system. The human eye can see 128 different hues, 130 different
saturations and number values between 16 (blue) and 23 (yellow).
An HSV color model is the most accurate color model as long as the way humans perceive
colors. How humans perceive colors is not like how RGB or CMYK make colors. They are
just primary colors fused to create the spectrum. The H stands for Hue, S stands for Saturation,
and the V stand for value. Imagine a cone with a spectrum of red to blue from left to right, and
from the centre to the edge, the color intensity increases. From bottom to up, the brightness
increases. Hence resulting white at the center up layer. A pictographic representation is also
shown below.
• Hue: Hue tells the angle to look at the cylindrical disk. The hue represents the color.
The hue value ranges from o to 360 degrees.
• Saturation: The saturation value tells us how much quantity of respective color must be added.
A 100% saturation means that complete pure color is added, while a 0% saturation means no
color is added, resulting in grayscale.
• Value: The value represents the brightness concerning the saturation of the color. the value 0
represents total black darkness, while the value 100 will mean a full brightness and depend on
the saturation.
Advantages:
The advantage of HSV is that it generalizes how humans perceive color. Hence it is the most
accurate depiction of how we feel colors on the computer screen. Also, the HSV color space
separates the luma from the color information. this allows us to perform the operations
mentioned above in the applications section, as the histogram equalization will only be required
for intensity values.
Applications:
• HSV model is used in histogram equalization.
• Converting grayscale images to RGB color images.
• Visualization of images is easy as by plotting the H and S components we can vary the V
component or vice-versa and see the different visualizations.
During the early days of color television, black-and-white sets were still expected to display
what were originally color images. YIQ model separated chrominance from luminance.
Luminance information is contained on the Y-channel, whereas color information is carried on
I and Q channels (in-phase and in-quadrature) , in-short YIQ(Luminance, In-phase,
Quadrature). In addition to providing a signal that could be displayed directly on black-and-
white TVs, the system provided easy coding and decoding of RGB signals which was not
directly possible.
Due to the fact that the Y-channel carries a lot of luminance information, it has a bandwidth
assigned to it of 4Mhz, I-channel has a bandwidth assigned to it of 1.5Mhz, and Q-channel has
a bandwidth of 0.6Mhz.
Advantages:
• The advantage of this model is that more width can be assigned to the Y-component
(Luminance) because the human visual system is more sensitive to changes in
luminance than to changes in hue or saturation.
• For display on a screen, color television sets map these channels Y, I, and Q to R, G,
and B.
Disadvantages:
• Due to the high implementation costs for true I and Q decoding, few television sets do
it.
• To accommodate the bandwidth variances between I and Q, each of I and Q needs a
distinct filter.
• Due to different bandwidths, the “I” filter has a time delay to match the “Q” filter’s
long delay.
• In black-and-white TV only Only Y can be noticed.
NOTE:
• Gamma encoding of images is used to optimize the usage of bits when encoding an
image, or bandwidth used to transport an image, by taking advantage of the non-linear
manner in which humans perceive light and color.
• Alpha Channel - which specifies the opacity for a color. The value of an <alpha-
value> is given as either a <number> or a <percentage> . If given as a number, the
useful range is 0 (fully transparent) to 1.0 (fully opaque), with decimal values in
between; that is, 0.5 indicates that half of the foreground color is used and half of the
background color is used.
Lightness, Brightness And Transparency
1. Brightness Adjustment:
• Addition/Subtraction: Increase or decrease the intensity of all pixels by adding or
subtracting a constant value.
• Multiplication/Division: Scale the intensity values by multiplying or dividing them by
a constant factor.
2. Contrast Adjustment:
• Linear Contrast Stretching: Rescale the intensity values to cover the full dynamic
range.
• Histogram Equalization: Adjust the distribution of pixel intensities to enhance
contrast.
3. Gamma Correction:
• Adjust the gamma value to overall brightness and contrast of an image.
4. Thresholding:
• Convert a grayscale image to binary by setting a threshold value. Pixels with values
above the threshold become white, and those below become black.
5. Bit-plane Slicing:
• Decompose an image into its binary representation by considering individual bits.
6. Color Mapping:
• Apply color transformations to change the color balance or convert between color
spaces (e.g., RGB to grayscale).
7. Inversion:
• Invert the intensity values of pixels, turning bright areas dark and vice versa.
8. Image Arithmetic:
• Perform arithmetic operations between pixels of two images, such as addition,
subtraction, multiplication, or division.
Simple Adaptive Median filter (AMF) , Decision Based Median Filter (DBMF) , Decision Based
Untrimmed Median Filter (DBUTM)
Linear image filters are essential tools in image processing, particularly when it comes to noise
reduction. These filters operate by applying a convolution operation on an image, using a predefined
kernel or filter mask. The beauty of linear filters lies in their simplicity and effectiveness in reducing
various types of noise, such as salt-and-pepper noise or Gaussian noise. Convolution is the mathematical
operation where the filter mask is successively overlaid on each pixel of the image, and the product of
the filter’s coefficients and the corresponding pixel values is computed. This process is repeated for
every pixel, resulting in a new filtered image.
One of the significant advantages of linear image filters for noise reduction is their ability to process
images in near-real-time, making them suitable for applications where computational efficiency is
crucial. Linear filters can be implemented using simple mathematical operations, allowing for fast
processing on both hardware and software platforms. Despite their effectiveness in many scenarios,
linear filters may struggle with more complex and nonlinear noise patterns, where non-linear filters
come into play.
1. Mean filtering is elegantly simple: each pixel in an image is substituted with the average value
derived from neighboring pixels confined within a specified window or kernel. The size of this kernel
determines the degree of smoothing, with larger kernels inducing more potent smoothing effects at the
potential cost of finer detail loss. This process proves effective in removing pixel values that diverge
significantly from their surroundings. While a standard 3×3 square kernel is frequently employed, the
utilization of larger kernels — like 5×5 squares — can intensify the smoothing for more substantial
noise reduction. However, mean filtering’s suitability is not universal; images containing sharp edges
or intricate details may experience edge blurring due to the averaging procedure.
While mean filtering holds its place in preprocessing images for subsequent intricate tasks like edge
detection or object recognition, its significance is underscored in image restoration and enhancement
processes. Notably, in domains like medical imaging, mean filtering’s application contributes to
enhanced diagnostic precision and improved visual quality.
2. Gaussian filtering is a critical tool in image processing, for noise reduction. By applying a
Gaussian kernel, the filter gives central pixels more weight than surrounding regions, effectively
reducing noise while preserving image structure. The essential parameter σ controls the filter’s scope
and subsequent smoothing. Gaussian filters are excellent at removing random, subtle image noise
patterns, making them vital in many image processing applications. the Gaussian filter has its
limitations. It tends to blend noise into the result, causing indiscriminate smoothing along edges.
The Gaussian smoothing operator is a 2-D convolution operator that is used to `blur' images
and remove detail and noise. In this sense it is similar to the mean filter, but it uses a different
kernel that represents the shape of a Gaussian (`bell-shaped') hump. This kernel has some
special properties which are detailed below.
where, σ is the standard deviation of the distribution. We have also assumed that the
distribution has a mean of zero (i.e. it is centered on the line x=0). The distribution is illustrated
below in Figure 1
Sigma defines the amount of blurring. High sigma values require significantly more calculations per
pixel.
In 2-D, an isotropic (i.e. circularly symmetric) Gaussian has the form:
Once a suitable kernel has been calculated, then the Gaussian smoothing can be performed
using standard convolution methods. The convolution can in fact be performed fairly quickly
since the equation for the 2-D isotropic Gaussian shown above is separable into x and y
components. Thus the 2-D convolution can be performed by first convolving with a 1-D
Gaussian in the x direction, and then convolving with another 1-D Gaussian in the y direction.
The y component is exactly the same but is oriented vertically.
Figure 4 One of the pair of 1-D convolution kernels used to calculate the full kernel shown in Figure
3 more quickly.
The Gaussian filter not only has utility in engineering applications. It is also attracting attention from
computational biologists because it has been attributed with some amount of biological plausibility, e.g.
some cells in the visual pathways of the brain often have an approximately Gaussian response.
3. The Sobel filter, introduced by Irwin Sobel and Gary M. Feldman in 1968, is a crucial tool in
image processing and computer vision. Its primary purpose is to detect edges within images, playing a
foundational role in various edge detection algorithms. Sobel filter significantly contributes to tasks
such as object detection, image segmentation, and edge enhancement. It is a first derivative mask.
Gx= Gy=
-1 0 1 -1 -2 -1
-2 0 2 0 0 0
-1 0 1 1 2 1
The Horizontal Sobel Kernel Gx excels at identifying vertical edges, whereas the Vertical Sobel Kernel
Gy highlights horizontal edges. Upon completing the convolutions, the Sobel filter computes the
gradient magnitude using the Pythagorean theorem:
or |G|=|Gx|+ |Gy|
This magnitude computation unveils insights into the rate of intensity variation and the presence of
edges throughout the image. Moreover, the orientation of these edges is determined counter clockwise
concerning the direction of maximum contrast, extending from black to white.
Ex-
10 9 9 4 0 x x x x x x x x x x x x x x x x x x x x
0 6 6 2 2 x -14 -18 -22 x x 6 2 -2 x x 15 18 22 x x 0 1 1 x
5 9 8 4 3 x 10 -15 -16 x x -4 1 -4 x x 11 15 16 x x 0 0 1 x
7 5 5 4 3 x -1 -12 -17 x x -5 -2 1 x x 5 12 17 x x 0 0 1 x
8 10 8 5 0 x x x x x x x x x x x x x x x x x x x x
Apply Gx Apply Gy Apply G Threshold= sum/9=15
4. Laplacian Filter- It is also a derivative operator which is used to find edges in an image. A
second order derivative mask. Positive Laplacian Operator is use to take out outward edges in an image.
0 1 0
1 -4 1
0 1 0
0 -1 0
-1 4 -1
0 -1 0
we can't apply both the positive and negative Laplacian operator on the same image. if we apply positive
Laplacian operator on the image then we subtract the resultant image from the original image to get the
sharpened image. Similarly if we apply negative Laplacian operator then we have to add the resultant
image onto original image to get the sharpened image.
Filter = [0 2 0 Filter = [1 4 1
2 -8 2 4 20 4
0 2 0], 1 4 1],
To detect edges in all direction
Example-
10 10 10 10 10 10 10
150 150 150 150 150 10 10 After
10 10 10 10 10 10 10 Filtering
10 10 10 10 10 10 10 With f1
10 10 150 150 150 150 150
10 10 10 10 10 10 10
10 10 10 10 10 10 10