0% found this document useful (0 votes)
2 views128 pages

Image Processing Matlab Programs

The document provides a comprehensive overview of various image processing techniques using MATLAB, including RGB to grayscale conversion, image thresholding, Gaussian blur, edge detection, and morphological operations. Each technique is explained with definitions, detailed explanations, mathematical formulas, MATLAB code examples, and key features, advantages, disadvantages, and applications. The document serves as a practical guide for implementing these techniques in image processing tasks.

Uploaded by

DR
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views128 pages

Image Processing Matlab Programs

The document provides a comprehensive overview of various image processing techniques using MATLAB, including RGB to grayscale conversion, image thresholding, Gaussian blur, edge detection, and morphological operations. Each technique is explained with definitions, detailed explanations, mathematical formulas, MATLAB code examples, and key features, advantages, disadvantages, and applications. The document serves as a practical guide for implementing these techniques in image processing tasks.

Uploaded by

DR
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

IMAGE PROCESSING MATLAB PROGRAMS

1. RGB to Grayscale Conversion

Definition

RGB to Grayscale conversion is the process of transforming a color image


represented in the RGB color space (Red, Green, Blue channels) into a single-
channel intensity image that represents brightness information only. The resulting
grayscale image contains intensity values ranging from 0 (black) to 255 (white).

Detailed Explanation

A color image stores three separate intensity values for each pixel: red, green, and
blue. However, many image processing algorithms such as edge detection,
segmentation, filtering, and pattern recognition work better with a single intensity
channel.
To convert RGB to grayscale, a weighted sum of the RGB components is used. These
weights correspond to the human eye’s sensitivity to different colors. Humans
perceive green light most strongly, followed by red, and then blue.
Therefore, the green channel contributes the most to brightness perception.

Mathematical Formula

𝐺𝑟𝑎𝑦 = 0.299𝑅 + 0.587𝐺 + 0.114𝐵

Where

• R = Red channel intensity

• G = Green channel intensity

• B = Blue channel intensity

The result is a single grayscale intensity value.

MATLAB PROGRAM:

img = imread('[Link]'); % Read color image

gray_img = rgb2gray(img); % Convert to grayscale

figure;

subplot(1,2,1); imshow(img); title('Original RGB');

subplot(1,2,2); imshow(gray_img); title('Grayscale');

% The formula: 0.2989*R + 0.5870*G + 0.1140*B


INPUT IMAGE: PROCESSED OUTPUT IMAGE:

Algorithm / Steps

1. Read the RGB image.

2. Extract the three channels (R, G, B).

3. Multiply each channel by its weight.

4. Add the weighted values.

5. Store the result as a grayscale image.

Key Features

• Converts 3-channel image → 1-channel image

• Reduces computational complexity

• Maintains luminance information

• Useful as preprocessing step

Advantages

• Faster image processing

• Reduces memory usage

• Simplifies many computer vision algorithms

Disadvantages

• Complete loss of color information

• Some objects that differ only in color may appear identical


Applications

• Face detection systems

• OCR (Optical Character Recognition)

• Medical image preprocessing

• Object detection algorithms

2. Image Thresholding (Binary)

Definition

Image thresholding is a segmentation technique used to convert a grayscale image into a


binary image by selecting a threshold intensity value.

Pixels are classified as either foreground or background depending on whether their


intensity is greater or smaller than the threshold.

Detailed Explanation

In many images, objects have intensity values that are significantly different from the
background. Thresholding exploits this difference to separate objects.

If the pixel intensity exceeds the threshold value, the pixel is considered part of the
object; otherwise, it belongs to the background.

This results in a binary image consisting only of black and white pixels.

Mathematical Representation
1 𝑓(𝑥, 𝑦) > 𝑇
𝑔(𝑥, 𝑦) = {
0 𝑓(𝑥, 𝑦) ≤ 𝑇

Where

• 𝑓(𝑥, 𝑦)= original pixel intensity

• 𝑇= threshold value

• 𝑔(𝑥, 𝑦)= output binary image


MATLAB Code

gray = rgb2gray(imread('[Link]'));

T = 127; % Threshold value

bw = gray > T; % Create binary image

% Or use imbinarize for auto threshold:

bw_auto = imbinarize(gray);

figure;

subplot(1,2,1); imshow(gray); title('Grayscale');

subplot(1,2,2); imshow(bw); title('Binary (T=127)');

Input image :

Output processed image :


Algorithm / Steps

1. Convert image to grayscale if necessary.

2. Choose a threshold value T.

3. Compare each pixel intensity with T.

4. Assign pixel value:

o 1 (white) if intensity > T

o 0 (black) if intensity ≤ T

5. Generate binary image.

Key Features

• Simple image segmentation method

• Converts grayscale images to binary

• Works best when object and background intensities differ clearly

Advantages

• Extremely fast and computationally simple

• Easy to implement

• Effective for high contrast images

Disadvantages

• Sensitive to lighting variations

• Incorrect threshold causes poor segmentation

• Not suitable for complex images

Applications

• Document image binarization

• Industrial inspection systems

• Medical image segmentation

• License plate recognition


3. Gaussian Blur / Smoothing

Definition

Gaussian blur is a linear smoothing filter used to reduce image noise and detail using a
Gaussian distribution function.

Detailed Explanation

Images often contain high-frequency noise, which can interfere with image analysis tasks
such as edge detection.

Gaussian blur smooths the image by averaging pixel values with neighboring pixels using
weights defined by a Gaussian function.

Pixels closer to the center contribute more to the final value than those farther away.

Gaussian Function

1 𝑥 2 +𝑦 2

𝐺(𝑥, 𝑦) = 𝑒 2𝜎2
2𝜋𝜎 2

Where

• 𝜎= standard deviation controlling blur strength

Matlab program:

img = imread('[Link]');

sigma = 3; % Gaussian standard deviation

h = fspecial('gaussian', [15 15], sigma);

blurred = imfilter(img, h, 'replicate');

% Or simply:

blurred = imgaussfilt(img, sigma);

figure;

subplot(1,2,1); imshow(img); title('Original');

subplot(1,2,2); imshow(blurred); title(['Gaussian Blur sigma=' num2str(sigma)]);


Algorithm / Steps

1. Create Gaussian kernel matrix.

2. Place kernel on image pixel.

3. Multiply kernel values with corresponding pixels.

4. Sum the results.

5. Replace center pixel with calculated value.

Key Features

• Smooths image while preserving structure

• Reduces noise before edge detection

• Controlled by kernel size and sigma

Advantages

• Effective noise reduction

• Produces natural smoothing

• Prevents edge artifacts

Disadvantages

• Blurs edges and fine details

• Large kernel increases computation time

Applications

• Image preprocessing
• Computer vision pipelines

• Medical imaging noise reduction

• Photography post-processing

[Link] Detection (Canny)

Definition

Canny edge detection is a multi-stage algorithm used to detect edges in images with high
accuracy and low error rate.

Detailed Explanation

Edges correspond to rapid changes in image intensity, often indicating object boundaries.

The Canny algorithm is considered one of the most effective edge detection methods
because it reduces noise while detecting thin, well-localized edges.

Matlab program:

gray = rgb2gray(imread('[Link]'));

% edge(image, 'canny', [low high], sigma)

edges = edge(gray, 'canny', [0.1 0.3], 1.5);

figure;

subplot(1,2,1); imshow(gray); title('Grayscale');

subplot(1,2,2); imshow(edges); title('Canny Edges');

% Adjust thresholds to control sensitivity

Input image :
Processed output image:

Steps in Canny Algorithm

1. Gaussian smoothing
Remove noise using Gaussian filter.

2. Gradient calculation
Compute gradient magnitude and direction.

3. Non-maximum suppression
Keep only the strongest edges.

4. Double thresholding
Identify strong and weak edges.

5. Edge tracking by hysteresis


Connect weak edges that are linked to strong edges.

Key Features

• Accurate edge detection

• Thin edges

• Good noise suppression

Advantages

• High precision

• Low false edge detection

• Excellent localization

Disadvantages

• Computationally expensive
• Requires parameter tuning

Applications

• Autonomous vehicle vision

• Medical image analysis

• Robotics navigation

• Object detection systems

5. Morphological Dilation

Definition

Dilation is a morphological operation that expands the boundaries of objects in a binary


image by adding pixels to object edges.

Detailed Explanation

Morphological operations use a structuring element, which is a small matrix that scans the
image.

In dilation, if any pixel in the structuring element overlaps with the object, the output pixel
becomes part of the object.

This causes objects to grow in size.

Matlab program

gray = rgb2gray(imread('[Link]'));

bw = imbinarize(gray); % Binarize first

SE = strel('square', 5); % 5x5 square structuring element

dilated = imdilate(bw, SE);

figure;

subplot(1,2,1); imshow(bw); title('Original Binary');

subplot(1,2,2); imshow(dilated); title('After Dilation');

% SE shapes: 'disk', 'square', 'rectangle', 'line', etc.


Input image:

Output Image:

Algorithm / Steps

1. Select structuring element.

2. Slide it across the image.

3. If structuring element touches object pixels, expand the object.

4. Repeat for all pixels.

Key Features

• Enlarges objects

• Connects nearby regions

• Fills small holes

Advantages
• Repairs broken edges

• Improves object connectivity

• Useful in segmentation

Disadvantages

• May merge nearby objects

• Distorts original shape

Applications

• Medical image segmentation

• Character recognition

• Shape analysis

[Link] Erosion

Definition

Erosion is a morphological operation that shrinks objects in a binary image by


removing boundary pixels.

Detailed Explanation

The structuring element is moved across the image. If the structuring element does
not completely fit inside the object, the pixel is removed.
This results in smaller objects and removal of small noise.

Matlab Program

ray = rgb2gray(imread('[Link]'));
bw = imbinarize(gray);
SE = strel('square', 5);
eroded = imerode(bw, SE);
figure;
subplot(1,2,1); imshow(bw); title('Original Binary');
subplot(1,2,2); imshow(eroded); title('After Erosion');
% Erosion = shrinks bright regions, removes noise

Input image:
Output image:

Key Features
• Reduces object size
• Removes small noise
• Separates connected objects
Advantages
• Effective noise removal
• Useful for separating objects
Disadvantages
• Small objects may disappear
• Shape distortion possible
Applications
• Noise filtering
• Image segmentation
• Pattern recognition
7. Histogram Equalization

Definition

Histogram equalization is an image enhancement technique used to improve contrast by


redistributing intensity values across the full range.

Detailed Explanation

Low contrast images often have pixel intensities concentrated in a narrow range.

Histogram equalization spreads these intensities across the entire range, making details
more visible.

Mathematical Formula
𝑘

𝑠𝑘 = (𝐿 − 1) ∑ 𝑝𝑟 (𝑟𝑗 )
𝑗=0

Where

• L = number of intensity levels

• 𝑝𝑟 (𝑟𝑗 )= probability distribution

Matlab program:

ray = rgb2gray(imread('[Link]'));

eq = histeq(gray); % Apply equalization

figure;

subplot(2,2,1); imshow(gray); title('Original');

subplot(2,2,2); imshow(eq); title('Equalized');

subplot(2,2,3); imhist(gray); title('Original Histogram');

subplot(2,2,4); imhist(eq); title('Equalized Histogram');


Input image:

Output image

Algorithm / Steps

1. Compute image histogram.

2. Calculate cumulative distribution function (CDF).

3. Normalize the CDF.

4. Map original pixel values to new values.

Key Features

• Enhances contrast

• Expands dynamic range

• Automatic enhancement
Advantages

• Reveals hidden image details

• Works without manual tuning

Disadvantages

• May amplify noise

• Can over-enhance images

Applications

• Medical imaging

• Satellite imagery

• Surveillance systems

8. Sobel Edge Detection

Definition

The Sobel edge detection method is a gradient-based edge detection technique used to
identify edges in images by calculating the rate of intensity change in horizontal and vertical
directions.

Detailed Explanation

Edges in an image represent boundaries between objects where pixel intensity changes
rapidly. The Sobel operator detects these edges by computing the first derivative (gradient)
of the image intensity.

It uses two convolution kernels to measure intensity changes:

• One kernel detects horizontal edges

• Another detects vertical edges

The magnitude of the gradient indicates the strength of the edge, while the gradient
direction indicates the orientation of the edge.

Matlab program:

gray = rgb2gray(imread('[Link]'));

Gx = imfilter(double(gray), fspecial('sobel'));

Gy = imfilter(double(gray), fspecial('sobel')');

magnitude = sqrt(Gx.^2 + Gy.^2);


magnitude = uint8(255 * magnitude / max(magnitude(:)));

% Or simply:

edges = edge(gray, 'sobel');

figure;

subplot(1,2,1); imshow(gray); title('Original');

subplot(1,2,2); imshow(magnitude, []); title('Sobel Edges');

Input image:

Output image
Sobel Operator Kernels

Horizontal Gradient Kernel


−1 0 1
𝐺𝑥 = [−2 0 2]
−1 0 1

Vertical Gradient Kernel


−1 −2 −1
𝐺𝑦 = [ 0 0 0]
1 2 1

Gradient Magnitude Formula

𝐺 = √𝐺𝑥2 + 𝐺𝑦2

Or an approximate version:

𝐺 =∣ 𝐺𝑥 ∣ +∣ 𝐺𝑦 ∣

Algorithm / Steps

1. Convert image to grayscale.

2. Apply Sobel horizontal filter.

3. Apply Sobel vertical filter.

4. Calculate gradient magnitude.

5. Threshold the gradient to highlight edges.

Key Features

• Detects horizontal and vertical edges

• Uses gradient computation

• Provides edge direction information

• Simple convolution-based technique

Advantages

• Simple implementation

• Good detection of strong edges


• Provides directional edge information

Disadvantages

• Sensitive to noise

• Produces thick edges

• Less accurate compared to Canny

Applications

• Object boundary detection

• Image segmentation

• Industrial inspection

• Computer vision preprocessing

9. Image Rotation

Definition

Image rotation is a geometric transformation that rotates an image around a fixed point
(usually the image center) by a specified angle.

Detailed Explanation

Rotation changes the orientation of the image while maintaining its original structure. Every
pixel coordinate in the original image is mapped to a new coordinate using a rotation
transformation.

Since rotated coordinates may not fall exactly on integer pixel locations, interpolation
techniques are used to determine pixel values.

Mathematical Transformation

𝑥 ′ = 𝑥cos⁡ 𝜃 − 𝑦sin⁡ 𝜃
𝑦 ′ = 𝑥sin⁡ 𝜃 + 𝑦cos⁡ 𝜃

Where

• 𝑥, 𝑦= original coordinates

• 𝑥 ′ , 𝑦 ′ = rotated coordinates

• 𝜃= rotation angle
Matlab program

img = imread('[Link]');

angle = 45; % Rotation angle in degrees

rotated = imrotate(img, angle); % Rotates counter-clockwise

% With crop to maintain size:

rotated_crop = imrotate(img, angle, 'bilinear', 'crop');

figure;

subplot(1,2,1); imshow(img); title('Original');

subplot(1,2,2); imshow(rotated_crop); title(['Rotated ' num2str(angle) '°']);

Input image

Output image
Algorithm / Steps

1. Select rotation angle θ.

2. Determine image center.

3. Apply rotation transformation to each pixel.

4. Use interpolation to estimate pixel values.

5. Generate rotated image.

Key Features

• Maintains relative pixel relationships

• Rotates image clockwise or anticlockwise

• Requires interpolation for accurate results

Advantages

• Useful for orientation correction

• Maintains image geometry

Disadvantages

• Creates empty regions (black borders)

• Interpolation may reduce quality

Applications

• Image alignment

• Robotics vision systems

• Satellite image analysis

• Document orientation correction


10. Image Resizing / Scaling

Definition

Image resizing (or scaling) is the process of changing the dimensions of an image by
increasing or decreasing the number of pixels.

Detailed Explanation

Scaling modifies the spatial resolution of an image. When increasing size, new pixels must be
estimated using interpolation. When decreasing size, pixels are combined or removed.

Scaling Transformation

𝑥 ′ = 𝑆𝑥 × 𝑥
𝑦 ′ = 𝑆𝑦 × 𝑦

Where

• 𝑆𝑥 = horizontal scaling factor

• 𝑆𝑦 = vertical scaling factor

Matlab program

clc;

clear;

close all;

% Read image

img = imread('[Link]'); % Replace with your image

[h, w, c] = size(img);

% Resize image to smaller size

small = imresize(img, 0.4); % 40% scaling

% Create black canvas same size as original

canvas = zeros(h, w, c, 'uint8'); % Black image

% Get small image size

[hs, ws, ~] = size(small);


% Place small image at top-left corner of canvas

canvas(1:hs, 1:ws, :) = small;

% Display results

figure;

subplot(1,2,1);

imshow(img);

title('Original Image');

subplot(1,2,2);

imshow(canvas);

title('Processed Result');

Algorithm / Steps

1. Determine new image dimensions.

2. Calculate scaling factors.

3. Map new pixel coordinates to original coordinates.

4. Apply interpolation method.

5. Generate resized image.

Key Features

• Adjusts image resolution


• Maintains image proportions

• Supports enlargement and reduction

Advantages

• Allows images to fit different display sizes

• Reduces storage when downscaling

Disadvantages

• Enlarging images may cause blur

• Downscaling may lose details

Applications

• Web image optimization

• Deep learning preprocessing

• Image compression

• Multimedia applications
11. Adding Gaussian Noise

Definition

Gaussian noise is a type of noise that follows a normal distribution and randomly alters pixel
intensities across an image.

Detailed Explanation

In real-world imaging systems, noise often arises from electronic sensor interference,
thermal fluctuations, or low light conditions.

Gaussian noise affects every pixel slightly and is modeled mathematically using the Gaussian
probability distribution.

Probability Density Function


2
(𝑧−𝜇)
1 −
𝑝(𝑧) = 𝑒 2𝜎2
√2𝜋𝜎 2

Where

• 𝜇= mean intensity value

• 𝜎= standard deviation

Matlab program

% Add Gaussian Noise

img = imread('[Link]');

img_double = im2double(img); % Convert to [0,1] range

sigma = 0.1; % Noise standard deviation

noise = sigma * randn(size(img_double));

noisy = img_double + noise;

noisy = max(0, min(1, noisy)); % Clip to valid range

% Or use imnoise:

noisy2 = imnoise(img, 'gaussian', 0, 0.01);

figure;

subplot(1,2,1); imshow(img); title('Clean Image');

subplot(1,2,2); imshow(noisy); title('Gaussian Noise Added');


output image:

Algorithm / Steps

1. Generate random Gaussian noise.

2. Add noise to original pixel values.

3. Clip values to valid intensity range.

4. Produce noisy image.

Key Features

• Continuous noise distribution

• Affects entire image

• Realistic noise model

Advantages

• Simulates real camera noise

• Useful for testing image processing algorithms

Disadvantages

• Reduces image clarity

• Makes edge detection harder

Applications

• Image restoration research

• Filter performance testing

• Simulation of imaging sensors


12. Salt-and-Pepper Noise & Median Filter

Definition

Salt-and-pepper noise is a type of impulse noise where random pixels appear as white (salt)
or black (pepper) in an image.

Detailed Explanation

This noise occurs due to transmission errors, faulty memory locations, or sensor
malfunction. It randomly replaces pixel intensities with extreme values (0 or 255).

A median filter is commonly used to remove this noise.

The filter replaces each pixel value with the median value of neighboring pixels, effectively
removing isolated noise.

Median Filter Formula

𝑂𝑢𝑡𝑝𝑢𝑡(𝑥, 𝑦) = 𝑚𝑒𝑑𝑖𝑎𝑛{𝑓(𝑖, 𝑗)}

Where the median is taken from the neighborhood window.

Matlab program

img = imread('[Link]');

% Add salt-and-pepper noise (5% density)

noisy = imnoise(img, 'salt & pepper', 0.05);

% Apply 5x5 median filter

denoised = medfilt2(rgb2gray(noisy), [5 5]);

% For color images, apply per-channel:

for c = 1:3

filtered(:,:,c) = medfilt2(noisy(:,:,c), [5 5]);

end

figure;

subplot(1,2,1); imshow(noisy); title('Salt & Pepper Noise');

subplot(1,2,2); imshow(denoised); title('Median Filtered');


Input image:

Outputimage:

Algorithm / Steps

1. Choose neighborhood window (e.g., 3×3).

2. Collect pixel values within window.

3. Sort pixel values.

4. Replace center pixel with median value.

5. Repeat for all pixels.

Key Features

• Removes impulse noise effectively

• Preserves edges better than average filters

Advantages
• Excellent for salt-and-pepper noise removal

• Maintains image edges

Disadvantages

• Computationally slower than mean filter

• Less effective for Gaussian noise

Applications

• Medical image preprocessing

• Image restoration

• Digital photography noise removal

13. Image Flipping (Horizontal/Vertical)

Definition

Image flipping is a geometric transformation that mirrors an image along a specified axis,
producing a reflected version.

Detailed Explanation

Two main types of flipping exist:

Horizontal Flip

The image is mirrored along the vertical axis. The left side becomes the right side.

Vertical Flip

The image is mirrored along the horizontal axis. The top becomes the bottom.

Mathematical Representation

Horizontal Flip

(𝑥, 𝑦) → (𝑤𝑖𝑑𝑡ℎ − 𝑥 − 1, 𝑦)

Vertical Flip

(𝑥, 𝑦) → (𝑥, ℎ𝑒𝑖𝑔ℎ𝑡 − 𝑦 − 1)


Matlab program

img = imread('[Link]');

% Horizontal flip (left-right mirror)

flipped_h = fliplr(img);

% Vertical flip (upside-down)

flipped_v = flipud(img);

% Both flips

flipped_both = rot90(img, 2); % Same as flip both

figure;

subplot(1,3,1); imshow(img); title('Original');

subplot(1,3,2); imshow(flipped_h); title('Horizontal Flip');

subplot(1,3,3); imshow(flipped_v); title('Vertical Flip');

Output:

Algorithm / Steps

1. Read image dimensions.

2. Swap pixel positions according to flip direction.

3. Assign new pixel positions.

4. Display flipped image.


Key Features

• Simple transformation

• Maintains pixel intensity values

• Creates mirror image

Advantages

• Very fast operation

• Useful for data augmentation

Disadvantages

• May distort orientation-dependent objects

• Not meaningful in some applications

Applications

• Deep learning dataset augmentation

• Computer graphics

• Image editing tools

14. Image Sharpening (Unsharp Masking)

Definition

Image sharpening enhances edges and fine details by emphasizing high-frequency


components in an image.

Detailed Explanation

Unsharp masking is a common sharpening method where a blurred version of the image is
subtracted from the original image to highlight edges.

The difference between the original and blurred image is called the mask.

Sharpening Formula

𝑆ℎ𝑎𝑟𝑝𝑒𝑛𝑒𝑑 = 𝑂𝑟𝑖𝑔𝑖𝑛𝑎𝑙 + 𝑘(𝑂𝑟𝑖𝑔𝑖𝑛𝑎𝑙 − 𝐵𝑙𝑢𝑟𝑟𝑒𝑑)

Where

• 𝑘= sharpening factor
Matlab program

clc;

clear;

close all;

img = imread('[Link]');

sharpened = imsharpen(img, 'Radius', 2, 'Amount', 1.5);

figure;

subplot(1,2,1); imshow(img); title('Original Image');

subplot(1,2,2); imshow(sharpened); title('Sharpened Image');

Output:

Algorithm / Steps

1. Apply Gaussian blur to the image.

2. Subtract blurred image from original.

3. Multiply difference by sharpening factor.

4. Add result to original image.

Key Features

• Enhances edges

• Improves image contrast

• Highlights fine details

Advantages
• Improves visual clarity

• Enhances texture and details

Disadvantages

• May amplify noise

• Over-sharpening causes artifacts

Applications

• Digital photography enhancement

• Medical imaging

• Satellite image processing

• Printing and publishing


15. Color Channel Manipulation

Definition

Color channel manipulation refers to the process of separating, modifying, or analyzing


individual color channels (Red, Green, and Blue) in an RGB image to enhance or extract
specific information.

Detailed Explanation

A color image in the RGB color model consists of three separate matrices representing the
red, green, and blue intensity components. By manipulating these channels independently,
different visual effects or analytical results can be obtained.

For example:

• Enhancing the red channel highlights objects with strong red components.

• Removing one channel creates a color-filtered image.

Channel manipulation is commonly used in color-based segmentation, object detection,


and image enhancement.

Mathematical Representation

An RGB image can be represented as:

𝐼(𝑥, 𝑦) = [𝑅(𝑥, 𝑦), 𝐺(𝑥, 𝑦), 𝐵(𝑥, 𝑦)]

Where

• 𝑅(𝑥, 𝑦)= Red channel intensity

• 𝐺(𝑥, 𝑦)= Green channel intensity

• 𝐵(𝑥, 𝑦)= Blue channel intensity

Each channel can be processed independently.

Matlab program

% Color Channel Manipulation

img = imread('[Link]');

% Extract individual channels

R = img(:,:,1); % Red channel

G = img(:,:,2); % Green channel


B = img(:,:,3); % Blue channel

% Swap R and B channels for artistic effect

swapped = img;

swapped(:,:,1) = B; % Put Blue in Red slot

swapped(:,:,3) = R; % Put Red in Blue slot

figure;

subplot(2,2,1); imshow(img); title('Original');

subplot(2,2,2); imshow(cat(3,R,R,R)); title('Red Channel');

subplot(2,2,3); imshow(cat(3,G,G,G)); title('Green Channel');

subplot(2,2,4); imshow(swapped); title('R-B Swapped');

Output:

Algorithm / Steps

1. Load the RGB image.

2. Extract R, G, and B channels.

3. Modify or analyze each channel separately.

4. Combine channels if necessary.

5. Display the processed image.

Key Features

• Allows analysis of individual color components


• Enables color filtering and enhancement

• Useful for object detection

Advantages

• Provides detailed color information

• Improves color-based segmentation

• Simple to implement

Disadvantages

• Sensitive to lighting variations

• May distort original color balance

Applications

• Traffic sign detection

• Plant disease detection

• Medical image analysis

• Color object tracking


16. RGB to HSV Color Space Conversion

Definition

RGB to HSV conversion transforms an image from the Red-Green-Blue (RGB) color space to
the Hue-Saturation-Value (HSV) color space, which separates color information from
brightness.

Detailed Explanation

In the RGB model, color and brightness are mixed together, making color analysis difficult.
The HSV model separates these components:

• Hue (H) → actual color type

• Saturation (S) → purity or intensity of the color

• Value (V) → brightness level

This separation makes HSV more suitable for color segmentation and object detection
tasks.

Mathematical Representation

Hue calculation:
𝐺−𝐵
60∘ × if 𝑚𝑎𝑥 = 𝑅
Δ
𝐵−𝑅
𝐻 = 60∘ × (2 + ) if 𝑚𝑎𝑥 = 𝐺
Δ

𝑅−𝐺
{ 60 × (4 + ) if 𝑚𝑎𝑥 = 𝐵
Δ

Where

Δ = 𝑚𝑎𝑥(𝑅, 𝐺, 𝐵) − 𝑚𝑖𝑛(𝑅, 𝐺, 𝐵)

Matlab program

% RGB to HSV Conversion

img = imread('[Link]');

hsv = rgb2hsv(img); % Convert to HSV [0,1] range

H = hsv(:,:,1); % Hue channel

S = hsv(:,:,2); % Saturation channel

V = hsv(:,:,3); % Value channel


figure;

subplot(2,2,1); imshow(img); title('Original RGB');

subplot(2,2,2); imshow(H); title('Hue');

subplot(2,2,3); imshow(S); title('Saturation');

subplot(2,2,4); imshow(V); title('Value');

Output:

Algorithm / Steps

1. Normalize RGB values.

2. Find maximum and minimum values among R, G, B.

3. Compute hue based on dominant color.

4. Calculate saturation and value.

5. Store the HSV image.

Key Features

• Separates color from brightness

• Provides intuitive color representation

• Useful for segmentation tasks

Advantages

• More robust to lighting variations

• Better for color detection algorithms


Disadvantages

• Conversion process adds computational overhead

• Not always suitable for grayscale processing

Applications

• Object tracking in computer vision

• Skin detection systems

• Color-based segmentation

• Robotics vision systems


17. Otsu's Automatic Thresholding

Definition

Otsu’s thresholding is an automatic image segmentation technique that computes the


optimal threshold value by minimizing intra-class variance between foreground and
background pixels.

Detailed Explanation

Unlike manual thresholding, Otsu’s method determines the best threshold based on the
image histogram.

It assumes that the image contains two classes of pixels (bimodal histogram):

• Foreground

• Background

The algorithm selects the threshold that maximizes the between-class variance.

Mathematical Formula

Between-class variance:

𝜎𝑏2 = 𝑤1 𝑤2 (𝜇1 − 𝜇2 )2

Where

• 𝑤1 , 𝑤2= probabilities of two classes

• 𝜇1 , 𝜇2 = class means

The threshold that maximizes this variance is chosen.

Matlab Program:

% Otsu's Automatic Thresholding

gray = rgb2gray(imread('[Link]'));

% Find optimal threshold automatically

T = graythresh(gray); % Returns value in [0,1]

bw = imbinarize(gray, T); % Apply threshold

fprintf('Optimal threshold: %.3f\n', T);

% Or in one step:
bw2 = imbinarize(gray, 'global'); % Uses Otsu internally

figure;

subplot(1,2,1); imshow(gray); title('Grayscale');

subplot(1,2,2); imshow(bw); title(['Otsu Threshold T=' num2str(T,'%.3f')]);

Output:

Algorithm / Steps

1. Compute histogram of image.

2. Calculate probability distribution.

3. Compute class probabilities and means.

4. Calculate between-class variance.

5. Select threshold maximizing variance.

Key Features

• Automatic threshold selection

• Works well for bimodal images

• Histogram-based segmentation

Advantages

• No manual parameter selection

• Effective for many segmentation tasks

Disadvantages

• Sensitive to noise
• Performs poorly when histogram is not bimodal

Applications

• Document image binarization

• Medical image segmentation

• Industrial inspection
18. Laplacian Edge Detection

Definition

Laplacian edge detection is a method that identifies edges by calculating the second
derivative of image intensity.

Detailed Explanation

Edges correspond to locations where the image intensity changes rapidly. The Laplacian
operator highlights these changes by measuring the rate of change of the gradient.

Unlike Sobel, the Laplacian detects edges in all directions simultaneously.

However, because it is sensitive to noise, it is usually applied after Gaussian smoothing.

Mathematical Formula

∂2 𝑓 ∂2 𝑓
∇2 𝑓 = +
∂𝑥 2 ∂𝑦 2

Common Laplacian Kernel


0 −1 0
[−1 4 −1]
0 −1 0

Matlab Program:

% Laplacian Edge Detection

gray = rgb2gray(imread('[Link]'));

% Apply Laplacian filter

h = fspecial('laplacian', 0.2);

laplacian = imfilter(double(gray), h);

edges = uint8(abs(laplacian));

% Laplacian of Gaussian (LoG) - more robust to noise:

h_log = fspecial('log', [9 9], 1.5);

log_edges = imfilter(double(gray), h_log);

figure;

subplot(1,2,1); imshow(gray); title('Original');


subplot(1,2,2); imshow(edges, []); title('Laplacian Edges');

Output:

Algorithm / Steps

1. Convert image to grayscale.

2. Apply smoothing filter to reduce noise.

3. Convolve image with Laplacian kernel.

4. Detect zero crossings for edges.

Key Features

• Detects edges in all directions

• Uses second-order derivatives

• Highlights fine details

Advantages

• Simple implementation

• Detects thin edges

Disadvantages

• Highly sensitive to noise

• Requires smoothing preprocessing

Applications

• Medical imaging
• Feature extraction

• Image sharpening

19. Perspective Transform (Homography)

Definition

Perspective transformation (homography) is a geometric operation that maps points from


one plane to another using projective transformation.

Detailed Explanation

When images are captured from different viewing angles, objects may appear distorted due
to perspective effects.

Perspective transformation corrects this distortion by mapping the original coordinates to


new coordinates using transformation matrices.

It is widely used in image stitching and augmented reality systems.

Mathematical Formula
𝑎𝑥 + 𝑏𝑦 + 𝑐
𝑥′ =
𝑔𝑥 + ℎ𝑦 + 1
𝑑𝑥 + 𝑒𝑦 + 𝑓
𝑦′ =
𝑔𝑥 + ℎ𝑦 + 1

Where
a, b, c, d, e, f, g, h are transformation parameters.

Matlab Program:

% Perspective Transform

img = imread('[Link]');

[h, w, ~] = size(img);

% Define source and destination points

srcPts = [1 1; w 1; w h; 1 h];

dstPts = [30 10; w-20 1; w-40 h-20; 10 h-30];

% Compute homography

tform = fitgeotrans(srcPts, dstPts, 'projective');

% Apply transform

warped = imwarp(img, tform, 'OutputView', imref2d([h w]));


figure;

subplot(1,2,1); imshow(img); title('Original');

subplot(1,2,2); imshow(warped); title('Perspective Warped');

Output:

Algorithm / Steps

1. Identify four corresponding points in two images.

2. Compute homography matrix.

3. Apply transformation matrix to all pixels.

4. Generate corrected image.

Key Features

• Corrects perspective distortion

• Maintains straight lines

• Used in geometric mapping

Advantages

• Enables image alignment

• Useful for panoramic image creation

Disadvantages

• Requires accurate point detection

• Computationally complex

Applications
• Image stitching

• Augmented reality

• Robotics navigation

• Satellite image correction

20. Gamma Correction

Definition

Gamma correction is a nonlinear image processing technique used to adjust brightness and
contrast according to human visual perception.

Detailed Explanation

Display devices do not respond linearly to intensity values. Gamma correction compensates
for this nonlinearity to ensure images appear correctly on screens.

Low gamma values brighten images, while high gamma values darken them.

Matlab Program:

% Gamma Correction

img = imread('[Link]');

img_double = im2double(img); % Normalize to [0,1]

gamma = 0.5; % < 1 brightens, > 1 darkens

corrected = img_double .^ (1/gamma);

corrected = im2uint8(corrected);

% Or: brighten the image

corrected2 = img_double .^ (1/2.2); % Standard monitor gamma

figure;

subplot(1,2,1); imshow(img); title('Original');

subplot(1,2,2); imshow(corrected); title(['Gamma = ' num2str(gamma)]);

Output:
Algorithm / Steps

1. Normalize pixel intensities.

2. Apply gamma transformation.

3. Rescale output intensities.

4. Generate corrected image.

Key Features

• Nonlinear intensity adjustment

• Enhances dark or bright regions

Advantages

• Improves image visibility

• Corrects display device response

Disadvantages

• Incorrect gamma causes distortion

• May reduce contrast in some regions

Applications

• Digital photography

• Display calibration

• Video processing
21. Morphological Opening

Definition

Morphological opening is a morphological operation that removes small objects or noise


from an image while preserving the main shape of larger objects.

Detailed Explanation

Opening is performed by erosion followed by dilation using the same structuring element.

Erosion removes small objects, and dilation restores the size of the remaining objects.

Matlab Program:

% Morphological Opening

gray = rgb2gray(imread('[Link]'));

bw = imbinarize(gray);

SE = strel('disk', 5); % Disk-shaped structuring element

opened = imopen(bw, SE);

% Opening = erosion then dilation

% Removes: small objects, thin protrusions, spurs

eroded = imerode(bw, SE);

opened_manual = imdilate(eroded, SE);

figure;

subplot(1,2,1); imshow(bw); title('Original Binary');

subplot(1,2,2); imshow(opened); title('After Opening');

Input image:
Output:

Algorithm / Steps

1. Apply erosion to the image.

2. Apply dilation to the eroded image.

3. Remove small artifacts.

Key Features

• Removes small noise

• Smooths object boundaries

Advantages

• Preserves large objects

• Effective noise removal

Disadvantages

• Small details may be lost

• Depends on structuring element size

Applications

• Noise filtering

• Image segmentation

• Shape analysis
22. Morphological Closing

Definition

Morphological closing is an operation used to fill small holes and connect nearby
objects in an image.

Detailed Explanation

Closing is performed by dilation followed by erosion. Dilation expands object


boundaries, and erosion restores object size while filling gaps.

Matlab Program:

% Morphological Closing

gray = rgb2gray(imread('[Link]'));

bw = imbinarize(gray);

SE = strel('disk', 8); % Disk-shaped structuring element

closed = imclose(bw, SE);

% Closing = dilation then erosion

% Fills: small holes, gaps, thin dark regions

% Manual closing:

dilated = imdilate(bw, SE);

closed_manual = imerode(dilated, SE);

figure;

subplot(1,2,1); imshow(bw); title('Original Binary');

subplot(1,2,2); imshow(closed); title('After Closing');

Input image:
Output image :

Algorithm / Steps

1. Apply dilation to the image.

2. Apply erosion to the dilated image.

3. Fill small gaps and holes.

Key Features

• Connects nearby objects

• Fills small holes in regions

Advantages

• Improves object continuity

• Useful in segmentation tasks

Disadvantages

• May merge nearby objects

• May alter object shape

Applications

• Medical image processing

• Pattern recognition

• Object detection
23. Color Image Histogram Equalization

Definition

Color Image Histogram Equalization is an image enhancement technique used to


improve the contrast of a color image by redistributing the pixel intensity values so that the
histogram becomes more uniform. It enhances the visibility of details in dark or low-
contrast regions of an image.
Detailed explanation

Histogram

A histogram is a graphical representation of the distribution of pixel intensity values in


an image.

Concept of Color Histogram Equalization

Method 1: RGB Channel Equalization

Method 2: HSV-Based Equalization (Better Method)

Mathematical Background

Probability Density Function (PDF)


𝑛𝑘
𝑝(𝑟𝑘 ) =
𝑛
Where

• 𝑟𝑘 = intensity level

• 𝑛𝑘 = number of pixels with intensity 𝑟𝑘

• 𝑛= total number of pixels

Algorithm / Steps

➢ Read the input color image.


➢ Separate the image into R, G, B channels.
➢ Apply histogram equalization to each channel.
➢ Combine the channels to form the equalized image.
➢ (Optional) Convert RGB to HSV and equalize the V channel.
➢ Convert back to RGB.
➢ Display the original and equalized images.
PROGRAM:

% Color Histogram Equalization


img = imread('[Link]');
% Method 1: Per-channel RGB equalization eq_r = histeq(img(:,:,1));
eq_g = histeq(img(:,:,2));
eq_b = histeq(img(:,:,3));
equalized = cat(3, eq_r, eq_g, eq_b);
% Method 2: Equalize V channel in HSV (better) hsv = rgb2hsv(img);
hsv(:,:,3) = histeq(hsv(:,:,3));
equalized_hsv = hsv2rgb(hsv);
figure;
subplot(1,2,1);
imshow(img);
title('Original');
subplot(1,2,2);
imshow(equalized);
title('Color Equalized')

INPUT IMAGE OUTPUT IMAGE

Applications
➢ Image enhancement in digital image processing
➢ Medical imaging (improves visibility in X-ray, MRI)
➢ Satellite and remote sensing images
➢ Surveillance and security systems

Advantages
➢ Improves image contrast
➢ Enhances details in dark or low-contrast images
➢ Simple and easy to implement
➢ Works automatically without manual adjustment
Disadvantages
➢ May produce over-enhancement in some regions
➢ Can change original colors in color images
➢ Amplifies noise in low-quality images
➢ Not suitable for all types of images
[Link] (Adaptive Histogram Equalization):

Definition

CLAHE is an image enhancement technique that improves local contrast by applying


histogram equalization to small regions (tiles) of an image while limiting noise amplification
using a clip limit.

Detailed Explanation

CLAHE is an improved form of Histogram Equalization. Instead of processing the


entire image, it divides the image into small tiles and enhances contrast in each tile separately.
A clip limit is used to prevent excessive amplification of noise. After equalization,
bilinear interpolation is applied to blend neighbouring tiles smoothly and avoid boundary
artifacts. It is widely used in medical imaging, satellite images, and low-light image
enhancement.

Mathematical Expression:
Let the image intensity be:
𝐼(𝑥, 𝑦)

Histogram:
ℎ(𝑟𝑘 ) = 𝑛𝑘

Probability distribution:
𝑛𝑘
𝑝(𝑟𝑘 ) =
𝑁

Cumulative distribution function:


𝑘

𝐶𝐷𝐹(𝑟𝑘 ) = ∑ 𝑝( 𝑟𝑗 )
𝑗=0

Transformation function:
𝑠𝑘 = (𝐿 − 1) × 𝐶𝐷𝐹(𝑟𝑘 )

where 𝐿is the number of gray levels.


Clip limit condition:
ℎ(𝑟𝑘 ) ≤ 𝑇
where T is the clip limit.

Algorithm

➢ Read the input image and convert to grayscale.


➢ Divide the image into small tiles (e.g., 8×8).
➢ Compute histogram for each tile.
➢ Apply clip limit to restrict histogram peaks.
➢ Perform histogram equalization on each tile.
➢ Use bilinear interpolation to combine tiles.
➢ Display the enhanced image.

PROGRAM:
clc;
clear;
close all;
% Read image
img = imread('[Link]'); % Replace with your image
[h, w, c] = size(img);
% Resize image to smaller size
small = imresize(img, 0.4); % 40% scaling
% Create black canvas same size as original
canvas = zeros(h, w, c, 'uint8'); % Black image
% Get small image size
[hs, ws, ~] = size(small);
% Place small image at top-left corner of canvas
canvas(1:hs, 1:ws, :) = small;
% Display results
figure;
subplot(1,2,1);
imshow(img);
title('Original Image');
subplot(1,2,2);
imshow(canvas);
title('Processed Result');

INPUT IMAGE OUTPUT IMAGE

Applications

➢ Medical imaging (X-ray, MRI)


➢ Satellite image processing
➢ Surveillance systems
➢ Face recognition
➢ Low-light image enhancement
Advantages
➢ Enhances local contrast
➢ Reduces noise amplification
➢ Improves visibility in low contrast images
➢ Suitable for medical image processing

Disadvantages

➢ Higher computational cost


➢ Requires parameter tuning (tile size, clip limit)
➢ May create artifacts if parameters are not chosen properly.

[Link] Corner Detection


Definition

Harris Corner Detection is a technique used in image processing to detect corner points
where image intensity changes in multiple directions.

Detailed Explanation

Harris corner detector identifies important feature points (corners) in an image. It


analyzes the intensity variation around each pixel using gradients in the x and y
directions.
A structure tensor matrix is formed to measure intensity changes. By calculating the
corner response value (R), pixels are classified as corners, edges, or flat regions.
Pixels with high positive response values are detected as corners.

Mathematical Expression
Image gradients:
∂𝐼 ∂𝐼
𝐼𝑥 = , 𝐼𝑦 =
∂𝑥 ∂𝑦

Structure tensor:
𝐼𝑥2 𝐼𝑥 𝐼𝑦
𝑀=[ ]
𝐼𝑥 𝐼𝑦 𝐼𝑦2

Harris response:
𝑅 = 𝑑𝑒𝑡(𝑀) − 𝑘(𝑡𝑟𝑎𝑐𝑒(𝑀))2

where 𝑘 ≈ 0.04
Interpretation:
R > 0 → Corner
R < 0 → Edge
R ≈ 0 → Flat region

Algorithm
➢ Read the input image.
➢ Convert image to grayscale.
➢ Compute image gradients (Ix, Iy).
➢ Form the structure tensor matrix.
➢ Calculate Harris response (R).
➢ Select pixels with high R values as corners.
➢ Display detected corners.

PROGRAM:
% Harris Corner Detection
img = imread('[Link]');
gray = rgb2gray(img);
% Detect Harris corners corners = detectHarrisFeatures(gray, ... 'MinQuality', 0.01, ...
'FilterSize', 5);
% Visualize corners figure;
imshow(img);
hold on;
plot([Link](50));
% Show 50 strongest corners
title('Harris Corner Detection');
hold off;

INPUT IMAGE: OUTPUT IMAGE:

Applications
➢ Feature matching
➢ Object recognition
➢ Image stitching
➢ Motion tracking
➢ 3D reconstruction

Advantages
➢ Accurate corner detection
➢ Rotation invariant
➢ Useful for feature extraction

Disadvantages
➢ Not scale invariant
➢ Sensitive to parameter selection
➢ Higher computational cost.

26. Brightness and Contrast Adjustment


Definition
Brightness and contrast adjustment is an image processing technique used to enhance
the visibility of an image. Brightness controls how light or dark an image appears, while
contrast controls the difference between the bright and dark regions.

Detailed Definition
Brightness and contrast adjustment modifies the pixel intensity values of an image
using a linear transformation. Brightness shifts all pixel values to make the image lighter or
darker, while contrast scales the intensity difference between pixels. This technique improves
image clarity and is commonly used as a preprocessing step in image processing and computer
vision applications.

Mathematical Expression
𝑔(𝑥, 𝑦) = 𝛼𝑓(𝑥, 𝑦) + 𝛽

Where:
• f(x,y) – Original pixel intensity
• g(x,y) – Output pixel intensity
• α – Contrast factor
• β – Brightness offset
Conditions:
• α > 1 → Increase contrast
• 0 < α < 1 → Decrease contrast
• β > 0 → Increase brightness
• β < 0 → Decrease brightness

Algorithm

➢ Read the input image.


➢ Convert the image to double format.
➢ Select contrast value α.
➢ Select brightness value β.
➢ Apply transformation 𝑔(𝑥, 𝑦) = 𝛼𝑓(𝑥, 𝑦) + 𝛽.
➢ Clip pixel values to the valid range.
➢ Convert back to image format and display results.

PROGRAM:
% Brightness and Contrast Adjustment
img = imread('[Link]');
img_double = im2double(img);
alpha = 1.5; % Contrast multiplier (>1 = more contrast)
beta = -0.1; % Brightness offset (>0 = brighter)
adjusted = alpha * img_double + beta;
adjusted = max(0, min(1, adjusted)); % Clip to valid range
adjusted = im2uint8(adjusted);
figure;
subplot(1,2,1); imshow(img); title('Original');
subplot(1,2,2); imshow(adjusted);
title(['alpha=' num2str(alpha) ' beta=' num2str(beta)])

INPUT IMAGE OUTPUT IMAGE

Applications
➢ Medical image enhancement
➢ Digital photography
➢ Satellite image analysis
➢ Computer vision preprocessing
➢ Security and surveillance systems

Advantages
➢ Simple and easy to implement
➢ Improves image visibility
➢ Computationally efficient
➢ Useful preprocessing technique

Disadvantages
➢ Excess adjustment may cause pixel saturation
➢ Some image details may be lost
➢ Linear adjustment may not work well for all images
27. Log Transformation
Definition
Log transformation is an image enhancement technique used to expand dark
pixel values and compress bright pixel values. It helps improve the visibility of details
in darker regions of an image.

Detailed Definition

Log transformation is a point processing operation in image processing where


each pixel intensity value is replaced using a logarithmic function. This transformation
increases the intensity of low-value pixels while reducing the effect of high-value
pixels. As a result, details in darker regions become more visible without excessively
brightening already bright areas.
This method is particularly useful in images with a large dynamic range, where both
very dark and very bright regions exist. The logarithmic transformation behaves
similarly to the human visual system, which perceives brightness in a logarithmic
manner.

Mathematical Expression
𝑠 = 𝑐log⁡(1 + 𝑟)

Where:
r = Input pixel intensity
s = Output pixel intensity
c = Scaling constant
log = Logarithmic function
The constant c controls the scaling of the output image.

Algorithm
➢ Read the input image.
➢ Convert the image to double format.
➢ Choose the scaling constant c.
➢ Apply the logarithmic transformation 𝑠 = 𝑐log⁡(1 + 𝑟).
➢ Normalize the result to keep pixel values in the valid range.
➢ Display the original and processed images.

PROGRAM:

% Log Transformation
img = imread('[Link]');
img_double = im2double(img); c = 1; % Scaling constant
log_img = c * log(1 + img_double); % Apply log transform
log_img = log_img / max(log_img(:)); % Normalize to [0,1]
% This brightens dark regions more than bright ones
% Useful for: HDR images, Fourier spectrum display
figure; subplot(1,2,1);
imshow(img); title('Original');
subplot(1,2,2); imshow(log_img);
title('Log Transformed')

INPUT IMAGE OUTPUT IMAGE:

Applications
➢ Enhancement of dark regions in images
➢ High Dynamic Range (HDR) image processing
➢ Display of Fourier transform spectrum
➢ Medical image enhancement
➢ Satellite and remote sensing images

Advantages
➢ Enhances details in dark areas of the image
➢ Reduces intensity of very bright regions
➢ Improves visibility in high dynamic range images
➢ Simple and easy to implement

Disadvantages
➢ Bright regions may lose some details
➢ Not suitable for all types of images
➢ Requires normalization after transformation
➢ Excessive scaling may distort image intensity values
28. Pseudocolor / False Color Mapping
Definition

Pseudocolor or false color mapping is an image processing technique in which


grayscale intensity values are converted into colors using a predefined colormap to make image
details easier to visualize.

Detailed Definition

Pseudocolor mapping assigns different colors to different grayscale intensity levels


using a color lookup table (colormap). Instead of displaying the image only in shades of gray,
each intensity value is mapped to a specific color. This improves the visual interpretation of
the image by highlighting small intensity variations that may not be clearly visible in grayscale
images.

The technique does not change the original data but enhances visualization. Common
colormaps include Jet, Hot, HSV, Parula, Cool, Spring, Summer, Autumn, and Winter. For
example, in the Jet colormap, low intensity values appear blue while high intensity values
appear red.

Mathematical Expression

If I(x,y) is the grayscale intensity value, the pseudocolor mapping can be expressed as:

𝐶(𝑥, 𝑦) = 𝑀(𝐼(𝑥, 𝑦))

Where:
I(x,y) = Input grayscale pixel value
M = Colormap function (lookup table)
C(x,y) = Output colored pixel value

Algorithm
➢ Read the input image.
➢ Convert the image to grayscale if necessary.
➢ Select a suitable colormap (Jet, Hot, HSV, etc.).
➢ Map grayscale intensity values to corresponding colors using the colormap.
➢ Display the colored image along with a color scale (colorbar).

PROGRAM:
% Pseudocolor / False Color Mapping
gray = rgb2gray(imread('[Link]'));
% Apply colormap to grayscale image
figure;
subplot(1,3,1);
imshow(gray);
title('Grayscale');
subplot(1,3,2);
imagesc(gray);
colormap(jet);
colorbar;
title('Jet Colormap');
subplot(1,3,3);
imagesc(gray);
colormap(hot);
colorbar;
title('Hot Colormap');
% Other colormaps: parula, hsv, cool, spring, summer, autumn, winter

INPUT IMAGE: OUTPUT IMAGE:

Applications:

➢ Medical imaging (MRI, CT scan visualization)


➢ Thermal imaging systems
➢ Satellite and remote sensing images
➢ Weather and climate visualization
➢ Elevation and topographic maps

Advantages

➢ Enhances visualization of intensity variations


➢ Makes image interpretation easier
➢ Useful for scientific and medical analysis
➢ Helps highlight hidden patterns in grayscale images
Disadvantages

➢ Does not change or improve the actual image data


➢ Color interpretation may vary depending on the chosen colormap
➢ May sometimes mislead visual interpretation if colors are not chosen properly

29. Connected Component Labeling (CCL)


Definition

Connected Component Labeling is an image processing technique used to detect and


label groups of connected pixels in a binary image. Each connected region is assigned a unique
label to identify separate objects.

Detailed Explanation

Connected Component Labeling (CCL) is used to identify distinct regions or objects in


a binary image. In this method, pixels with the same intensity value that are connected to each
other form a component. Each component is assigned a unique label so that different objects
in the image can be distinguished.

Connectivity can be defined in two ways:

• 4-Connectivity: A pixel is connected to its top, bottom, left, and right neighbours.
• 8-Connectivity: A pixel is connected to all eight surrounding pixels, including
diagonal neighbours.

After labeling the components, properties such as area, centroid, and bounding box can be
calculated. This information is useful for object detection, counting, and analysis.

Mathematical Expression

Let B(x,y) be a binary image.


𝐿(𝑥, 𝑦) = 𝑘

Where:
• B(x,y) = Binary pixel value (0 or 1)
• L(x,y) = Label assigned to the pixel
• k = Unique label for each connected component
All connected pixels with value 1 are assigned the same label.

Algorithm

➢ Read the input image.


➢ Convert the image into a grayscale image if required.
➢ Convert the grayscale image into a binary image using thresholding.
➢ Scan the binary image pixel by pixel.
➢ Check the connectivity (4 or 8 neighbors).
➢ Assign a unique label to each connected component.
➢ Store component properties such as area, centroid, and bounding box.
➢ Display labeled components using different colors.

PROGRAM:
% Connected Component
gray = rgb2gray(imread('[Link]'));
bw = imbinarize(gray);
% Label connected components
[labeled, num_components] = bwlabel(bw, 8); % 8-connectivity
fprintf('Found %d components\n', num_components); % Get properties
stats = regionprops(labeled, 'Area', 'Centroid', 'BoundingBox');
% Visualize with colors
colored = label2rgb(labeled, 'jet', 'k');
figure;
subplot(1,2,1);
imshow(bw);
title('Binary Image');
subplot(1,2,2);
imshow(colored);
title(['CCL: ' num2str(num_components) ' components']);

INPUT IMAGE: OUTPUT IMAGE:

Applications
➢ Object counting in images
➢ Character recognition (OCR)
➢ Medical image analysis
➢ Vehicle number plate detection
➢ Shape and object detection in computer vision

Advantages
➢ Helps identify and separate objects in an image
➢ Useful for object counting and feature extraction
➢ Simple and effective technique for binary images
➢ Widely used in computer vision applications

Disadvantages
➢ Works mainly on binary images
➢ Sensitive to noise in the image
➢ Requires preprocessing like thresholding
➢ Complex scenes with overlapping objects may reduce accuracy

30. Contour Detection


Definition
Contour detection is an image processing technique used to identify and extract the
boundaries of objects in an image. A contour represents the outline or edge that separates an
object from the background.

Detailed Definition

Contour detection is used to find continuous curves that represent the boundaries of
objects in a binary or thresholded image. These curves are formed by connecting pixels that
lie on the edges of an object. Contours help describe the shape and structure of objects in an
image.
In image processing, contour detection is usually performed after converting the image into a
binary image. Algorithms then trace the connected boundary pixels to form a contour.
Functions like bwboundaries() in MATLAB or findContours() in OpenCV are commonly
used to detect these boundaries.
Contours provide useful information such as area, perimeter, centroid, and shape
properties, which can be used for object detection, recognition, and shape analysis.

Mathematical Expression
Let B(x,y) represent a binary image.

A contour C can be represented as a set of boundary pixels:

𝐶 = {(𝑥, 𝑦) ∣ 𝐵(𝑥, 𝑦) = 1 and at least one neighbor 𝐵(𝑖, 𝑗) = 0}

Where:
• B(x,y) = Binary pixel value
• C = Set of contour boundary pixels

Algorithm

➢ Read the input image.


➢ Convert the image to grayscale.
➢ Convert the grayscale image into a binary image using thresholding.
➢ Detect boundary pixels of connected regions.
➢ Trace the boundary to form continuous contours.
➢ Store contour coordinates.
➢ Display the contours on the original image.

PROGRAM:
% Contour Detection
img = imread('[Link]');
gray = rgb2gray(img);
bw = imbinarize(gray); % Find boundaries of all objects boundaries =
bwboundaries(bw);
Draw contours on original image figure;
imshow(img);
hold on;
for k = 1:length(boundaries) b = boundaries{k};
plot(b(:,2), b(:,1), 'g-', 'LineWidth', 2);
end title(['Contours: ' num2str(length(boundaries)) ' found']);
hold off;

INPUT IMAGE: OUTPUT IMAGE:

Applications
➢ Object detection and recognition
➢ Shape analysis in computer vision
➢ Medical image analysis
➢ Handwriting and character recognition
➢ Vehicle and number plate detection

Advantages
➢ Helps identify object boundaries clearly
➢ Useful for shape analysis and feature extraction
➢ Works well for object detection tasks
➢ Provides useful geometric information like area and perimeter

Disadvantages
➢ Sensitive to image noise
➢ Requires preprocessing like thresholding
➢ May fail if object boundaries are unclear
➢ Complex scenes may produce too many contours

31. GRADIENT DIRECTION


Definition

Gradient direction or orientation is an image processing concept that represents the


direction of the maximum intensity change at each pixel in an image.

Detailed Definition

Gradient direction describes the orientation of edges in an image. It indicates the


direction in which the pixel intensity changes most rapidly. In edge detection, gradients are
computed in both horizontal (Gx) and vertical (Gy) directions using operators such as Sobel
or Prewitt filters.
The gradient direction is calculated from these two components and represents the angle of the
edge at each pixel. This information helps determine the orientation of object boundaries in
the image. Gradient direction is widely used in edge detection algorithms, feature extraction,
and object recognition techniques.

Mathematical Expression

The gradient direction is calculated using:


𝐺𝑦
𝜃 = tan⁡−1 ( )
𝐺𝑥

Where:
• Gx = Gradient in horizontal direction
• Gy = Gradient in vertical direction
• θ = Gradient direction (angle)

Gradient magnitude can also be calculated as:


𝑀 = √𝐺𝑥2 + 𝐺𝑦2

Where M represents the strength of the edge.

Algorithm
➢ Read the input image.
➢ Convert the image to grayscale.
➢ Apply gradient filters (such as Sobel) to compute Gx and Gy.
➢ Calculate gradient magnitude.
➢ Compute gradient direction using
𝜃 = tan⁡−1 (𝐺𝑦/𝐺𝑥).
➢ Normalize direction values if required.
➢ Display or visualize the gradient direction.

PROGRAM:
% Gradient Direction Computation
gray = rgb2gray(imread('[Link]'));
% Compute gradients Gx = imfilter(double(gray), fspecial('sobel'));
Gy = imfilter(double(gray), fspecial('sobel')');
% Gradient magnitude and direction magnitude = sqrt(Gx.^2 + Gy.^2);
direction = atan2d(Gy, Gx); % Direction in degrees [-180, 180]
% Visualize direction as hue (color)
H = (direction + 180) / 360;
% Normalize to [0,1] S = ones(size(H));
V = magnitude / max(magnitude(:));
hsv_vis = cat(3, H, S, V);
dir_vis = hsv2rgb(hsv_vis);
figure;
subplot(1,2,1);
imshow(gray);
title('Grayscale');
subplot(1,2,2);
imshow(dir_vis);
title('Gradient Direction (HSV)');

INPUT IMAGE: OUTPUT IMAGE:


Applications

➢ Edge detection (Canny algorithm)


➢ Object detection using HOG features
➢ Image segmentation
➢ Motion analysis and optical flow
➢ Computer vision and pattern recognition

Advantages
➢ Provides information about edge orientation
➢ Useful for feature extraction in computer vision
➢ Helps improve edge detection accuracy
➢ Useful in object recognition systems

Disadvantages
➢ Sensitive to image noise
➢ Requires gradient computation which increases processing time
➢ Accuracy depends on the quality of the input image
➢ May produce incorrect directions in noisy images

32. Fourier Transform (Frequency Domain)


Definition
Fourier Transform is an image processing technique used to convert an image from the
spatial domain to the frequency domain. It represents the image in terms of its frequency
components.

Detailed Definition

The 2D Discrete Fourier Transform (DFT) analyzes the frequency content of an


image by decomposing it into sinusoidal components. In the frequency domain, an image is
represented by low-frequency and high-frequency components.
Low frequencies correspond to smooth areas and general shapes, while high frequencies
represent edges, fine details, and noise. The Fourier Transform helps in understanding how
image information is distributed across different frequencies.
The output of the transform usually consists of a magnitude spectrum and a phase spectrum.
The magnitude spectrum shows the strength of frequency components, while the phase
spectrum represents positional information of image structures.

Mathematical Expression

The 2D Discrete Fourier Transform of an image is given by:


𝑀−1
𝑁−1 𝑢𝑥 𝑣𝑦
−𝑗2𝜋(
𝐹(𝑢, 𝑣) = ∑ ∑ 𝑓(𝑥, 𝑦) 𝑒 𝑀+𝑁 )
𝑦=0
𝑥=0

Where:
• f(x,y) = Input image in spatial domain
• F(u,v) = Frequency domain representation
• M, N = Image dimensions
• u, v = Frequency coordinates

Algorithm

➢ Read the input image.


➢ Convert the image to grayscale.
➢ Convert pixel values to double precision.
➢ Apply 2D Fourier Transform (DFT) using FFT.
➢ Shift the zero-frequency component to the center.
➢ Compute the magnitude and phase spectrum.
➢ Display the frequency domain representation.

PROGRAM:
% 2D Fourier Transform
gray = rgb2gray(imread('[Link]'));
% Compute DFT and shift DC to center
F = fft2(double(gray));
Fshift = fftshift(F);
% Compute magnitude spectrum (log scale for visibility)
magnitude = 20 * log(abs(Fshift) + 1);
% Phase spectrum
phase = angle(Fshift);
figure;
subplot(1,3,1);
imshow(gray);
title('Spatial Domain');
subplot(1,3,2);
imshow(magnitude, []);
title('Magnitude Spectrum');
subplot(1,3,3);
imshow(phase, []);
title('Phase Spectrum');

INPUT IMAGE: OUTPUT IMAGE:

Applications

➢ Image filtering (low-pass and high-pass filtering)


➢ Image compression techniques
➢ Texture analysis
➢ Noise removal in images
➢ Image enhancement and restoration

Advantages

➢ Provides detailed frequency information of images


➢ Useful for filtering and image enhancement
➢ Helps analyze image texture and patterns
➢ Widely used in signal and image processing

Disadvantages

➢ Computationally complex for large images


➢ Frequency representation is difficult to interpret visually
➢ Sensitive to noise in some applications
➢ Requires inverse transform to reconstruct the image

33. Frequency Domain Low-Pass Filter


Definition

A Low-Pass Filter (LPF) in the frequency domain is used to allow low-frequency


components of an image to pass while blocking high-frequency components, resulting in a
smoother or blurred image.

Detailed Definition
In image processing, frequency domain filtering is performed after converting the
image into the frequency domain using the Fourier Transform. A low-pass filter removes
high-frequency components such as edges, fine details, and noise, while preserving low-
frequency components that represent the general structure of the image.
This filtering is done by multiplying the Fourier transform of the image with a filter mask that
keeps low frequencies near the center and suppresses high frequencies farther from the center.
The filtered image is then converted back to the spatial domain using the Inverse Fourier
Transform.
Low-pass filtering is commonly used for image smoothing and noise reduction.

Mathematical Expression
The filtered image in the frequency domain is given by:
𝐺(𝑢, 𝑣) = 𝐻(𝑢, 𝑣) ⋅ 𝐹(𝑢, 𝑣)

Where:
• F(u,v) = Fourier transform of the input image
• H(u,v) = Low-pass filter function
• G(u,v) = Filtered frequency output

The final image is obtained by applying the Inverse Fourier Transform.
Algorithm

➢ Read the input image.


➢ Convert the image to grayscale.
➢ Apply 2D Fourier Transform to convert the image into the frequency domain.
➢ Shift the frequency spectrum to place the low-frequency components at the center.
➢ Create a low-pass filter mask with a cutoff frequency.
➢ Multiply the mask with the Fourier transform of the image.
➢ Apply Inverse Fourier Transform to obtain the filtered image.
➢ Display the original and filtered images.

PROGRAM:
% Low-Pass Filter in Frequency Domain
gray = rgb2gray(imread('[Link]'));
F = fft2(double(gray));
Fshift = fftshift(F);
% Create circular low-pass mask
[rows, cols] = size(gray);
[X, Y] = meshgrid(1:cols, 1:rows);
D0 = 30;
% Cutoff frequency (pixels) D = sqrt((X - cols/2).^2 + (Y - rows/2).^2);
mask = double(D <= D0); % 1 inside circle, 0 outside
% Apply mask and inverse DFT
filtered = Fshift .* mask;
img_back = ifft2(ifftshift(filtered));
img_back = uint8(real(img_back));
figure;
subplot(1,2,1);
imshow(gray);
title('Original');
subplot(1,2,2);
imshow(img_back);
title(['Low-Pass Filter D0=' num2str(D0)]);

INPUT IMAGE: OUTPUT IMAGE:


Applications

➢ Image smoothing and blurring


➢ Noise reduction in images
➢ Preprocessing for image analysis
➢ Medical image processing
➢ Satellite image enhancement

Advantages

➢ Effective for removing high-frequency noise


➢ Produces smooth images
➢ Provides control over frequency components
➢ Useful in many image enhancement techniques

Disadvantages

➢ Causes loss of fine details and edges


➢ May produce blurred images
➢ Requires Fourier transform computation
➢ Cutoff frequency selection affects image quality

34. Frequency Domain High-Pass Filter


Definition

Removes low-frequency components (smooth areas) and preserves high-frequency


details (edges).

Mathematical Expression

𝐺(𝑢, 𝑣) = 𝐻(𝑢, 𝑣) ⋅ 𝐹(𝑢, 𝑣)

• 𝐹(𝑢, 𝑣): Fourier Transform of image

• 𝐻(𝑢, 𝑣): High-pass filter mask

• Ideal HPF:
0, 𝐷(𝑢, 𝑣) ≤ 𝐷0
𝐻(𝑢, 𝑣) = {
1, 𝐷(𝑢, 𝑣) > 𝐷0

Algorithm

1. Convert image to grayscale

2. Apply FFT

3. Shift zero frequency to center

4. Apply HPF mask

5. Inverse FFT

6. Normalize output

Program :
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Edge detection

• Image sharpening

Advantages

• Enhances fine details

• Removes background variations


Disadvantages

• Amplifies noise

• Ringing artifacts (ideal filter)

35. Bilateral Filter


Definition

Edge-preserving smoothing filter combining spatial + intensity similarity.

Mathematical Expression
∣∣𝑥−𝑥𝑖 ∣∣ 2 ∣𝐼(𝑥)−𝐼(𝑥𝑖 )∣ 2

1 −
2𝜎 2 −
2𝜎𝑟2
𝐼 (𝑥) = ∑ 𝐼( 𝑥𝑖 )𝑒 𝑠 𝑒
𝑊𝑝
𝑥𝑖

Algorithm

1. For each pixel

2. Compute spatial weight

3. Compute intensity weight

4. Multiply and normalize

5. Replace pixel value

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Noise reduction

• Cartoon effect

Advantages

• Preserves edges

• Smooths noise

Disadvantages

• Computationally expensive

• Parameter sensitive

36. K-Means Color Segmentation


Definition

Clusters pixels into K groups based on color similarity.

Mathematical Expression
𝑘

𝐽 = ∑ ∑ ∣∣ 𝑥 − 𝜇𝑖 ∣∣2
𝑥∈𝐶𝑖
𝑖=1
Algorithm

1. Choose K clusters

2. Initialize centroids

3. Assign pixels to nearest centroid

4. Update centroids

5. Repeat until convergence

Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications
• Object segmentation

• Image compression

Advantages

• Simple

• Fast

Disadvantages

• Needs K value

• Sensitive to initialization

37. Morphological Gradient


Definition

Difference between dilation and erosion.

Expression

𝐺𝑟𝑎𝑑𝑖𝑒𝑛𝑡 = (𝐴 ⊕ 𝐵) − (𝐴 ⊖ 𝐵)

Algorithm

1. Apply dilation

2. Apply erosion

3. Subtract results

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Edge detection

Advantages

• Simple

• Highlights boundaries

Disadvantages

• Sensitive to structuring element

38. Top-Hat Transform


Definition

Extracts small elements from image.

Expression

• White:

𝑇𝑜𝑝𝐻𝑎𝑡 = 𝑓 − (𝑓 ∘ 𝑏)

• Black:
𝐵𝑜𝑡𝑡𝑜𝑚𝐻𝑎𝑡 = (𝑓 ∙ 𝑏) − 𝑓

Algorithm

1. Perform opening/closing

2. Subtract from original

Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• Uneven illumination correction

Advantages

• Enhances small features

Disadvantages
• Depends on structuring element

39. Image Blending / Alpha Compositing:


Definition

Combines two images using transparency.

Expression

𝐼 = 𝛼𝐴 + (1 − 𝛼)𝐵

Algorithm

1. Resize images

2. Choose alpha

3. Compute weighted sum

Program:

INPUT IMAGE: OUTPUT IMAGE:


Applications

• Photo editing

• AR

Advantages

• Simple

• Smooth transitions

Disadvantages

• Ghosting if misaligned

40. Prewitt Edge Detection


Definition

Gradient-based edge detection.

Expression

𝐺 = √𝐺𝑥2 + 𝐺𝑦2

Algorithm

1. Apply horizontal mask

2. Apply vertical mask

3. Compute magnitude

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Edge detection

Advantages

• Simple to implement

Disadvantages

• Sensitive to noise

41. Hough Line Transform


Definition

Detects lines using parameter space.

Expression

𝜌 = 𝑥cos⁡ 𝜃 + 𝑦sin⁡ 𝜃

Algorithm

1. Edge detection

2. Transform to (ρ,θ) space

3. Find peaks
Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• Lane detection

Advantages

• Detects broken lines

Disadvantages
• Computationally heavy

42. Hough Circle Transform:


Definition

Detects circles.

Expression

(𝑥 − 𝑎)2 + (𝑦 − 𝑏)2 = 𝑟 2

Algorithm

1. Edge detection

2. Vote in 3D accumulator

3. Detect peaks

Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• Coin detection

Advantages

• Robust
Disadvantages

• High complexity

43. Affine Transformation (Shearing)


Definition

Slants image along axis.

Expression

𝑥 ′ = 𝑥 + 𝑘𝑦, 𝑦 ′ = 𝑦

Algorithm

1. Define shear matrix

2. Apply to all pixels

Program:

INPUT IMAGE: OUTPUT IMAGE:


Applications

• Image correction

Advantages

• Preserves lines

Disadvantages

• Distorts shape

44. Template Matching


Definition

Finds region matching template.

Expression

𝑅(𝑥, 𝑦) = ∑𝑇(𝑥 ′ , 𝑦 ′ )𝐼(𝑥 + 𝑥 ′ , 𝑦 + 𝑦 ′ )

Algorithm

1. Slide template

2. Compute similarity

3. Find max

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Face detection

Advantages

• Easy

Disadvantages

• Sensitive to scale

45. Background Subtraction


Definition

Separates foreground from background.

Expression

∣ 𝐼𝑡 − 𝐵 ∣> 𝑇

Algorithm

1. Store background

2. Subtract current frame

3. Threshold

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Surveillance

Advantages

• Fast

Disadvantages

• Lighting sensitive

46. Mean Shift Filtering


Definition

Non-parametric clustering.

Expression
∑𝑥𝑖 𝐾(𝑥𝑖 − 𝑥)
𝑚(𝑥) =
∑𝐾(𝑥𝑖 − 𝑥)

Algorithm

1. Choose window

2. Compute mean

3. Shift window

4. Repeat
Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• Segmentation

Advantages

• No K required

Disadvantages

• Slow
47. Watershed Segmentation
Definition

Treats image as topographic surface.

Algorithm

1. Compute gradient

2. Mark seeds

3. Flood regions

Program:

INPUT IMAGE: OUTPUT IMAGE:


Applications

• Medical imaging

Advantages

• Accurate boundaries

Disadvantages

• Over-segmentation

48. Seam Carving


Definition

Content-aware resizing.

Expression

𝐸 =∣ ∇𝐼 ∣

Algorithm

1. Compute energy map

2. Find minimum seam

3. Remove seam

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Image resizing

Advantages

• Preserves important regions

Disadvantages

• Distorts objects

49. Image Inpainting


Definition

Fills missing regions.

Algorithm

1. Identify damaged area

2. Use neighbors to fill

3. Iterate
Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• Object removal

Advantages

• Restores images

Disadvantages
• Blurry results

50. Gaussian Image Pyramid


Definition

A Gaussian pyramid is a multi-resolution representation where each level is a smoothed and


downsampled version of the previous image.

Mathematical Expression
2
2

𝐺𝑖+1 (𝑥, 𝑦) = ∑ ∑ 𝑤(𝑚, 𝑛) 𝐺𝑖 (2𝑥 + 𝑚, 2𝑦 + 𝑛)


𝑛=−2
𝑚=−2

• 𝑤(𝑚, 𝑛): Gaussian kernel

Algorithm

1. Take original image 𝐺0

2. Convolve with Gaussian kernel

3. Downsample (reduce size by 2)

4. Repeat for multiple levels

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Image compression

• Feature detection (SIFT)

• Multi-scale analysis

Advantages

• Reduces noise

• Efficient multi-scale representation

Disadvantages

• Loss of details

• Not reversible

51. Laplacian Pyramid


Definition

A pyramid representing difference between Gaussian levels, capturing edge details.

Mathematical Expression

𝐿𝑖 = 𝐺𝑖 − 𝐸𝑥𝑝𝑎𝑛𝑑(𝐺𝑖+1 )

Algorithm

1. Build Gaussian pyramid


2. Expand next level

3. Subtract from current level

4. Store result

Program:

INPUT IMAGE: OUTPUT IMAGE:


Applications

• Image blending

• Compression

Advantages

• Preserves details

• Efficient reconstruction

Disadvantages

• Computationally complex

52. Anisotropic Diffusion (Perona-Malik)


Definition

Edge-preserving smoothing using diffusion process.

Mathematical Expression
∂𝐼
= ∇ ⋅ (𝑐(𝑥, 𝑦, 𝑡)∇𝐼)
∂𝑡

Algorithm

1. Compute gradients

2. Compute diffusion coefficient

3. Update pixel values iteratively


Program:

INPUT IMAGE: OUTPUT IMAGE:


Applications

• Noise reduction

• Medical imaging

Advantages

• Preserves edges

• Reduces noise

Disadvantages

• Parameter sensitive

• Slow convergence

53. Bit-Plane Slicing


Definition

Separates image into binary layers based on bit significance.

Mathematical Expression
7

𝐼(𝑥, 𝑦) = ∑ 𝑏𝑘 (𝑥, 𝑦) ⋅ 2𝑘
𝑘=0

Algorithm

1. Convert image to binary

2. Extract each bit plane

3. Analyze or reconstruct
Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• Image compression

• Watermarking

Advantages
• Simple

• Reveals hidden features

Disadvantages

• Lower planes contain noise

54. Retinex Color Enhancement


Definition

Enhances image by separating reflectance and illumination.

Mathematical Expression

𝑅(𝑥, 𝑦) = log⁡ 𝐼(𝑥, 𝑦) − log⁡[𝐹(𝑥, 𝑦) ∗ 𝐼(𝑥, 𝑦)]

Algorithm

1. Apply Gaussian blur

2. Take log of image

3. Subtract blurred version

4. Normalize

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Low-light enhancement

• Image correction

Advantages

• Improves contrast

• Handles illumination

Disadvantages

• Halo artifacts

• Computational cost

55. Custom Kernel Convolution (Emboss)


Definition

Applies a kernel to highlight edges in a 3D embossed style.

Kernel
−2 −1 0
[−1 1 1]
0 1 2

Algorithm
1. Define kernel

2. Convolve with image

3. Add offset (optional)

Program:

INPUT IMAGE: OUTPUT IMAGE:


Applications

• Image effects

• Feature enhancement

Advantages

• Simple

• Highlights edges

Disadvantages

• Not useful for analysis

56. Image Thinning / Skeletonization


Definition

Reduces objects to thin skeletons preserving structure.

Mathematical Concept

Iterative removal of boundary pixels:


𝑛

𝑆 = ⋂ 𝑋𝑘
𝑘=0

Algorithm

1. Convert to binary

2. Identify boundary pixels

3. Remove pixels without breaking connectivity

4. Repeat
Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• OCR

• Shape analysis

Advantages

• Reduces data

• Preserves topology

Disadvantages

• Sensitive to noise
57. Integral Image (Summed Area Table)
Definition

Stores cumulative pixel sums for fast region sum computation.

Mathematical Expression

𝐼(𝑥, 𝑦) = 𝑓(𝑥, 𝑦) + 𝐼(𝑥 − 1, 𝑦) + 𝐼(𝑥, 𝑦 − 1) − 𝐼(𝑥 − 1, 𝑦 − 1)

Algorithm

1. Initialize first row/column

2. Compute cumulative sums

3. Use for fast region queries

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Face detection (Viola-Jones)

Advantages

• Very fast computation

• Constant-time region sum

Disadvantages

• Extra memory

58. Radon Transform (Sinogram)


Definition

Transforms image into projection space along different angles.

Mathematical Expression

𝑅(𝜌, 𝜃) = ∫ 𝑓(𝑥, 𝑦) 𝛿(𝑥cos⁡ 𝜃 + 𝑦sin⁡ 𝜃 − 𝜌) 𝑑𝑥𝑑𝑦

Algorithm

1. Rotate image

2. Project intensity along lines


3. Store projections

Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• CT scan reconstruction

Advantages
• Useful in tomography

Disadvantages

• Computationally intensive

59. Color Quantization


Definition

Reduces number of colors in image.

Mathematical Idea

Minimize error:

𝐸 = ∑ ∣∣ 𝐼 − 𝑄(𝐼) ∣∣2

Algorithm

1. Choose K colors

2. Assign pixels

3. Update palette

Program:
Applications

• Image compression

Advantages

• Reduces storage

Disadvantages

• Loss of color detail

60. Distance Transform


Definition

Computes distance of each pixel to nearest object pixel.

Mathematical Expression

𝐷(𝑥, 𝑦) = min⁡ 𝑑((𝑥, 𝑦), (𝑖, 𝑗))


(𝑖,𝑗)∈𝑜𝑏𝑗𝑒𝑐𝑡

Algorithm

1. Convert to binary

2. Initialize distances

3. Update using neighbors


Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• Shape analysis

Advantages

• Useful for segmentation


Disadvantages

• Sensitive to noise

61. Image Quality Metrics (PSNR / SSIM)


PSNR

𝑀𝐴𝑋 2
𝑃𝑆𝑁𝑅 = 10log⁡10 ( )
𝑀𝑆𝐸

SSIM

(2𝜇𝑥 𝜇𝑦 + 𝐶1 )(2𝜎𝑥𝑦 + 𝐶2 )
𝑆𝑆𝐼𝑀 =
(𝜇𝑥2 + 𝜇𝑦2 + 𝐶1 )(𝜎𝑥2 + 𝜎𝑦2 + 𝐶2 )
program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Image comparison

Advantages

• Quantitative evaluation

Disadvantages

• PSNR not perceptual

62. Local Binary Patterns (LBP)


Definition

Texture descriptor comparing neighborhood pixels.

Expression
𝑃−1

𝐿𝐵𝑃 = ∑ 𝑠( 𝑔𝑝 − 𝑔𝑐 )2𝑝
𝑝=0

Algorithm
1. Compare neighbors with center

2. Assign binary values

3. Convert to decimal

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Face recognition

Advantages

• Simple

• Fast

Disadvantages

• Sensitive to noise

63. Non-Local Means Denoising


Definition

Removes noise using similarity of patches.

Mathematical Expression

𝑁𝐿(𝑥) = ∑𝑤(𝑥, 𝑦)𝐼(𝑦)

Algorithm
1. Compare patches

2. Compute weights

3. Weighted averaging

Program:
INPUT IMAGE: OUTPUT IMAGE:

Applications

• Medical images

Advantages

• High-quality denoising

Disadvantages

• Very slow

64. Image Stitching / Panorama


Definition

Combines multiple images into a single panorama.

Mathematical Concept

Homography:

𝑥 ′ = 𝐻𝑥

Algorithm

1. Detect features (SIFT/SURF)

2. Match features

3. Estimate homography

4. Warp images
5. Blend images

Program:

INPUT IMAGE: OUTPUT IMAGE:

Applications

• Panorama photography

• Satellite imaging
Advantages

• Wide field of view

Disadvantages

• Requires overlap

• Sensitive to mismatches

You might also like