Computer vision [BCS613B]
MODULE – 04
1. Explain the Fundamentals of Color Image Processing
When white light passes through a prism, it splits into a continuous spectrum of colors from
violet to red.
Color image processing mainly uses color to help in identifying and understanding objects in
an image. It has two main types:
1. Pseudocolor Processing:
o Colors are added to grayscale images to make them easier to analyze.
o Example: Assigning red to high values and blue to low values.
2. Full-color Processing:
o Images are captured in color directly using digital cameras or scanners.
o This is now common due to cheaper and better color hardware.
Why Use Color in Image Processing?
• Color helps us identify objects better than black and white.
• Humans can see thousands of colors but only around 20 shades of gray.
Color Perception Basics
• We see color based on light reflected from objects.
• Light in the 400–700 nm range is visible to us.
• Achromatic light = no color, just brightness (black to white).
• Chromatic light = colored light.
Main Color Terms
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
• Brightness: How light or dark a color is.
• Hue: The actual color (red, green, etc.).
• Saturation: How pure the color is (more white = less saturated).
2. Explain pseudocolor image processing and its applications
1. intensity slicing.
• Definition: Intensity slicing is a pseudo-colour technique where the grayscale range is
divided into intervals using slicing planes, and each interval is assigned a distinct
colour.
• Process: If there are P slicing planes, the image is split into P+1 intensity intervals.
Each pixel’s intensity is mapped to a colour based on the interval it falls into.
• Purpose: It enhances visualization by making small intensity variations more
noticeable, which is helpful in analysing grayscale images.
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
• Difference: Intensity slicing uses fixed intervals for colour assignment, while
intensity-to-colour transformation may use continuous or contextual mappings based
on pixel values.
• Example: In weld X-ray images, assigning a unique colour to intensity level 255 helps
highlight defects clearly, reducing human error in inspections.
2. Intensity to Color Transformations
• It is a pseudocolor technique where each grayscale pixel value is transformed into a
color by applying separate functions to control the red, green, and blue components.
• Instead of using fixed intervals like intensity slicing, this method uses continuous
mathematical functions (such as sine waves) to map intensity values smoothly to
colors. This creates more flexible and visually rich outputs.
• Example: In X-ray security scans, intensity-to-color transformation helps highlight
specific materials (like explosives) by assigning distinct colors based on pixel
intensity, improving object detection.
3. Multispectral Band Combination:
Combines multiple grayscale images from different sensors (e.g., red, green, infrared) into a
single RGB image.
4. Color coding
• Color Coding assigns fixed colors to specific intensity values or ranges (like red for
high intensity, blue for low).
• It's a discrete mapping.
• It helps highlight important features for easier visual interpretation, such as defects
or specific patterns.
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
Applications of Pseudo colour image processing
1. Medical Imaging:
Enhances differences in tissues or organs (e.g., highlighting tumors).
2. X-ray Inspection:
Helps detect cracks or defects in welds or luggage by coloring specific intensity
values.
3. Satellite and Weather Imaging:
Used to highlight rainfall, vegetation, or land features from remote sensing images.
4. Industrial Testing:
Assists in detecting flaws in materials or products using coded X-ray or thermal
images.
3. Explain the role of color segmentation in object recognition.
1. Color Segmentation in RGB Space
• RGB uses Red, Green, and Blue channels.
• Each pixel has 3 values: (R, G, B).
• Color segmentation is done by comparing RGB values to predefined color ranges.
Limitations:
• RGB mixes color and brightness, so it’s hard to segment objects under different
lighting.
• Color boundaries are not clearly separated, making object isolation difficult.
Example:
• In RGB space, white = (255, 255, 255), black = (0, 0, 0).
• A green object may be segmented if:
R<100, G>150, B<100 (These thresholds define greenish regions.)
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
2. Color Segmentation in HSI Space
• HSI stands for Hue, Saturation, Intensity.
• It separates color from brightness, which helps in more accurate segmentation.
Advantages:
• Hue represents pure color (red, green, etc.).
• Saturation shows color purity.
• Intensity is brightness (gray level).
Equations:
To convert RGB to HSI:
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
4. How are color transformations used in image enhancement?
Color transformations refer to modifying or enhancing the color components of an image
within the same color model (like RGB, HSI, or CMYK) to improve appearance, correct
imbalances, or highlight features.
FORMULATION
COLOR COMPONENTS
Each color image has components based on the chosen color model:
• RGB → Red, Green, Blue
• CMY(K) → Cyan, Magenta, Yellow (+ Black)
• HSI → Hue, Saturation, Intensity
Each pixel in the color image is treated as a vector (voxel) of these component values
COLOR SLICING
Used to highlight or extract specific color regions in an image.
Two methods:
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
TONE AND COLOR CORRECTIONS
Tone correction modifies brightness and contrast; color correction adjusts the balance
between colors.
Tonal Corrections:
• Done interactively.
• RGB/CMY(K): apply same transformation to all components.
• HSI: apply only to Intensity (I).
• Common transformations:
o S-curve: Boosts contrast
o Power-law curves: Fix dark/light images
HISTOGRAM PROCESSING of Color Images
Histogram equalization aims to spread intensity values evenly.
Do not equalize RGB channels separately:
• Leads to false colors.
Better approach: Equalize only the intensity (I) in HSI space:
• Keeps hue and saturation intact
• Brightens image while maintaining color quality
Example:
• Original image had median intensity = 0.36.
• After equalization: median = 0.5
• Post-enhancement: Improve saturation to regain vibrancy
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
5. Define Color Models and Explain the Types with Examples
A color model is a mathematical way to represent colors. It helps us describe, process, and
display colors using numbers. A color model defines:
1. A coordinate system (like x, y, z axes), and
2. A range of colors (a subspace) within that system.
Each color in the model is a single point in that space.
Color models are used to simplify how we capture, store, manipulate, and display color
images in devices like cameras, printers, and monitors.
Types of Color Models
1. RGB Color Model
• The RGB model is based on the primary colors of light: Red, Green, and Blue.
• Each color is formed by adding different amounts of R, G, and B light.
• This model is represented in a 3D cube, where each axis corresponds to one color.
o For example:
▪ (1, 0, 0) = pure red
▪ (0, 1, 0) = pure green
▪ (0, 0, 1) = pure blue
▪ (1, 1, 1) = white
▪ (0, 0, 0) = black
• Used in: color monitors, digital cameras, TVs, and scanners.
• A typical RGB image is a 24-bit image, which means 8 bits for each color, allowing
over 16 million colors (2²⁴ = 16,777,216).
2. CMY and CMYK Color Models
• CMY stands for Cyan, Magenta, and Yellow, which are the secondary colors of light
and primary colors of pigments.
• The CMY model is used in printers, where colors are made by subtracting light from
white.
• The conversion from RGB to CMY is:
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
• Ideally, combining C, M, and Y should produce black. But in practice, the result is
muddy brown.
• So, a fourth component K (black) is added, forming the CMYK model, used in 4-color
printing.
The conversion from CMY to CMYK
K = min(C, M, Y)
If K = 1, then we have pure black, with no color contributions, from which it follows that
C = 0, M = 0, Y = 0
Otherwise, C =(C-K)/(1-K)
M=(M-K)/(1-K)
Y=(Y-K)/(1-K)
where all values are assumed to be in the range [0 ,1 ].
3. HSI Color Model
• HSI stands for Hue, Saturation, and Intensity.
• This model is designed to match how humans perceive and describe color.
• Hue (H) describes the actual color (e.g., red, blue, green).
• Saturation (S) measures color purity (0 = gray, 1 = pure color).
• Intensity (I) is the brightness level.
• HSI separates color information (H, S) from intensity (I), making it easier to apply
grayscale image processing to color images.
• Conversion equations:
o I = (R + G + B) / 3
o S = 1 − [3 / (R + G + B)] × min(R, G, B)
o H is calculated using trigonometric formulas from RGB values.
Examples of Applications
• RGB model is used in monitors where red, green, and blue dots combine to show
full-color images.
• CMYK is used in printers to create high-quality black and colored prints.
• HSI is helpful when you want to change the color tone of an object or extract regions
based on hue or brightness. For example, by changing the hue value in HSI space, we
can turn a red circle into a green one without affecting brightness.
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
6. Explain Color Image Smoothing and Sharpening
1. Color Image Smoothing
Color image smoothing is a technique used to reduce noise or minor variations in a color
image. It is done by replacing the value of a pixel with the average of its neighbors. This
helps create a smoother, less noisy image.
How it works:
In grayscale images, smoothing is done by applying a spatial averaging filter. The same idea
is extended to color images by treating each color plane (Red, Green, and Blue) separately or
using vector processing.
Each pixel in a color image has three components (R, G, B). To smooth the image:
• We slide a kernel (like a 5×5 averaging filter) over the image.
• At each location, we average the values of the neighborhood pixels for each color
channel.
• This reduces sharp edges and noise.
Let S denote the set of coordinates defining a neighborhood centered at (,) x y in an RGB
color image. The average of the RGB component vectors in this neighborhood is
Example
• An RGB image was smoothed by averaging each color channel using a 5×5 kernel.
The result was a visually smooth full-color image.
• Another method smoothed only the intensity component of the HSI model. This
method maintained the original color (hue and saturation), but made the image
appear smoother in brightness.
2. Color Image Sharpening
Color image sharpening is used to enhance edges and fine details in an image, making it
appear clearer and more defined.
How it works:
Sharpening is done using the Laplacian operator, which highlights regions with rapid
intensity changes (like edges). In color images:
• We calculate the Laplacian for each RGB component separately.
• These sharpened components are then combined to form the final sharpened image.
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
In the RGB color system, the Laplacian of vector c is
Example
• An RGB image was sharpened by applying the Laplacian filter to each color channel
(R, G, B).
• Another version was created by applying the Laplacian only to the intensity
component of the HSI image.
• The difference in results was shown visually: sharpening RGB affected both edges
and colors, while sharpening only intensity enhanced edges without changing color.
7. Discuss the challenges associated with noise in color images
Definition:
Noise in color images refers to unwanted random changes in pixel values that affect the
visual quality of the image. This noise can make the image appear grainy, distorted, or
unclear. Just like grayscale images, color images are also affected by different types of noise.
How Noise Affects Color Images:
• Color images have three separate channels: Red, Green, and Blue (RGB). Usually,
each channel may be affected equally by noise. But in many real-world situations,
some channels can have more noise than others.
• In some cases, electronics failure in one of the color channels can also cause higher
noise in just that channel.
Types of Noise in Color Images:
1. Additive Gaussian Noise:
o This type of noise adds small random values to pixel intensities.
o In the RGB image, the noise may appear as fine-grained dots.
o But when the noisy RGB image was converted to HSI (Hue, Saturation,
Intensity) format, the Hue and Saturation components became severely
degraded.
o This is because the HSI conversion uses nonlinear functions like cosine and
minimum, which amplify noise.
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
2. Salt-and-Pepper Noise:
o This noise appears as random black and white pixels.
o If this noise affects only one color channel (e.g., Green), it may spread to all
three HSI components when the image is converted from RGB to HSI.
o This happens because the HSI model depends on all three RGB channels, so
noise in one can affect all.
Effects of Noise During Color Model Conversion:
• Noise in one or more RGB channels can carry over and affect Hue, Saturation, and
Intensity when converting to HSI.
• The intensity component is usually less affected, because it is calculated as the
average of the three RGB values, which tends to smooth out the noise.
• But Hue and Saturation are more sensitive due to the mathematical complexity
involved.
Noise Reduction and Filtering:
• Noise in color images can be reduced using filters.
• A simple method is to apply an averaging filter (e.g., 5×5) to each RGB channel. This
can be done individually or in vector space (processing all three channels together).
• For some advanced filters, like median filters, working with color vectors is more
complicated. Unlike grayscale images, it is harder to define a "middle" value in color
vectors.
8. Explain the role of Color Edge Detection In image segmentation.
Color edge detection is used to find boundaries in color images during tasks like image
segmentation. Unlike grayscale images, where edge detection uses gradient operators like
Sobel, color images are vector-valued (RGB), so standard gradient methods don't apply
directly.
If we apply edge detection separately to the R, G, and B channels and then combine the
results, it can give incorrect edges. For example, even if the R, G, and B edges align in one
image and not in another, the combined gradient might still be the same—this leads to
errors.
To solve this, Di Zenzo (1986) proposed a method for computing gradients directly in color
vector space.
Partial Derivatives and Gradient Quantities (Di Zenzo Method)
In Di Zenzo’s method for color edge detection, we define gradient-related quantities using
the partial derivatives of R, G, and B channels with respect to x and y.
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
Let:
Edge direction:
Edge magnitude:
Where gxx, gyy, gxy are based on RGB partial derivatives.
These partial derivatives can be computed using Sobel operators.
9. Explain Full-Color Image Processing
Full-color image processing deals with handling and enhancing images that have multiple
color channels, typically Red (R), Green (G), and Blue (B). These techniques are important for
improving visual quality, object detection, segmentation, and other applications in color
images.
Approaches to Color Image Processing
Preetham Tejaswi, Acharya Institute of Technology
Computer vision [BCS613B]
There are two main approaches:
1. Per-Channel Processing (Independent Planes):
Each R, G, and B channel is processed independently using grayscale techniques. This
is simple but does not take into account the relationship between the color
components.
2. Vector-Based Processing:
Here, the pixel is treated as a vector in RGB space, and operations are done directly
on the vector. This method is more accurate but computationally expensive
Color Representation
A color image can be thought of as a collection of three grayscale images—one for each
color component (R, G, B). These are combined at each pixel to form a color vector.
Let an arbitrary vector in RGB color space be represented as:
Each pixel in a color image is a vector of RGB values. The values depend on the spatial
location (x, y) of the pixel. So, a color image can be expressed as:
This means that for every pixel coordinate (x,y) there is an RGB triplet that defines the color
at that point.
Neighborhood Processing in Color Images
Just like in grayscale image processing, spatial filtering (like blurring or sharpening) is
performed using a neighborhood of pixels. In color images, this becomes 3D neighborhood
processing:
• In grayscale, a 2D window moves over the image.
• In color, a 2D window is applied to each component (R, G, B) or the whole RGB
vector.
Importance of Vector Processing
• Vector-based processing considers correlation between R, G, B channels.
• It allows for more accurate color operations like edge detection, segmentation, and
enhancement. However, it is more complex and time-consuming than per-channel
methods.
Preetham Tejaswi, Acharya Institute of Technology