0% found this document useful (0 votes)
33 views5 pages

Ai M2 Ieee

Uploaded by

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

Ai M2 Ieee

Uploaded by

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

DIGITAL IMAGE PROCEESSING

Batch-16

T3-ASSIGNMENT

211FA04096 211FA04170 211FA04257 211FA04573


SEC-B SEC-B SEC-B SEC-B

Abstract— a) Contrast various types of noise [Link] Noise:


and their causes, which can corrupt an image? Cause: Although not practically present, uniform
noise is often used in numerical simulations to
Also describe their mathematical formulations. analyse systems.
Mathematical Formulation:
b) Design an algorithm to add the noise signal The PDF of uniform noise is given by:
(α [m,n] = cos (60πm/M ) cos(120πn/N) ) to 1
your image, where M and N corresponds to the P(x )=
b−a
dimensions of the image you have chosen. where:
x represents the noise value.
c) Design an algorithm for Indicate the a and b define the range of uniform distribution.
frequency domain approach to remove this 4. Impulse (Salt-and-Pepper) Noise:
noise through various filters. Analyze which Cause: Impulse noise results from quick transients,
such as faulty switching in cameras.
frequency domain filter is best suitable for Mathematical Formulation:
noise removal.
DESCRIPTION
[Link] Noise:
Cause: Gaussian noise arises due to factors such as
electronic circuit noise and sensor noise caused by
poor illumination or high temperature.
Mathematical Formulation:

Where: 5. Quantization Noise:


N(x, y) is the Gaussian noise at pixel location (x, y). Cause: Quantization noise arises from the
μ is the mean of the Gaussian distribution, quantization process when analog signals are
representing the average intensity of the noise. converted into digital format.
σ is the standard deviation of the Gaussian Mathematical Formulation:
distribution, controlling the spread or amplitude of Q= (Q/2) × U(−1,1)
the noise. Where:
N(0,1) is a random sample from a standard normal Q represents the quantization step size, which is the
distribution with mean 0 and standard deviation 1. difference between adjacent quantization levels.
[Link] Noise: U(−1,1) is a uniformly distributed random variable
Cause: Exponential noise is commonly present in ranging from -1 to 1.
cases of laser imaging.
Mathematical Formulation: ALOGRITHM(B)
The PDF of exponential noise is given by: 1. Read the original image:- The code reads an
−ax image file named `'[Link]'` and stores
P ( x )=a e it in the variable `original_image`.
where: 2. Get the dimensions of the original image:-
x represents the noise value. The dimensions of the original image are
a is a constant obtained using the `size` function. The
variable `M` represents the number of rows
(height) and `N` represents the number of
columns (width).
3. Generate the noise signal:- Two-dimensional
grids `m` and `n` are created using
`meshgrid` representing the spatial sOUTPUT(B)
dimensions of the image. A noise signal
`alpha` is generated based on the equation
`alpha = cos(60*pi*n/N) .*
cos(120*pi*m/M)`.
4. Normalize the noise signal:- The noise
signal `alpha` is normalized to the range [0,
1] by subtracting the minimum value and
dividing by the maximum value.
5. Scale and convert the noise signal to uint8:-
The normalized noise signal is scaled to the
range [0, 255] and converted to the `uint8`
data type to match the image data type.
6. 6. Add the noise signal to the original
image:- The noise signal `alpha_scaled` is
added to the original image `original_image`
element-wise to create a noisy image
`noisy_image`.
7. 7. Display the original image and the noise- ALGORITHM
added image:- The original image and the 1. Input:
noisy image are displayed side by side using - Read the noisy image (`[Link]`).
the `subplot` function with appropriate titles. - Convert the image to grayscale if it's in color.
2. Preprocessing:
CODE(B) - Convert the grayscale image to double precision
original_image = imread('[Link]’); for numerical processing.
[M, N, ~] = size(original_image); - Determine the dimensions (`M` x `N`) of the
[m, n] = meshgrid(1:N, 1:M); grayscale image.
alpha = cos(60*pi*n/N) .* cos(120*pi*m/M); 3. Generate Noise Signal:
alpha = alpha - min(alpha(:)); - Create a noise signal `alpha` using cosine
alpha = alpha / max(alpha(:)); functions of varying frequencies.
alpha_scaled = uint8(255 * alpha); - Add the noise signal to the original grayscale
noisy_image = original_image + alpha_scaled; image to generate the noisy image.
subplot(1, 2, 1); 4. Fourier Transform:
imshow(original_image); - Perform Fourier Transform on the noisy image.
title('Original Image'); - Shift the zero frequency component to the center
subplot(1, 2, 2); of the spectrum.
imshow(noisy_image); 5. Define Filters:- Define the parameters for different
title('Image with Added Noise'); filters:
- `sigma_low`: Standard deviation for low-pass
filter.
- `sigma_high`: Standard deviation for high-pass
filter.
- `sigma_bandpass_high`: Standard deviation for
the high-pass Gaussian filter.
- `sigma_bandpass_low`: Standard deviation for
the low-pass Gaussian filter.
- Create the following filters:
- Low-pass filter using Gaussian function.
- High-pass filter using Gaussian function with
zero-sum correction.
- Band-pass filter by subtracting low-pass from lowpass_filtered_F = F .*
high-pass filter. fftshift(fft2(lowpass_filter));
6. Apply Filters in Frequency Domain: highpass_filtered_F = F .*
- Multiply the Fourier-transformed noisy image fftshift(fft2(highpass_filter));
with each filter in the frequency domain to obtain bandpass_filtered_F = F .*
filtered images. fftshift(fft2(bandpass_filter));
7. Inverse Fourier Transform: lowpass_filtered_image =
- Perform Inverse Fourier Transform on each ifft2(ifftshift(lowpass_filtered_F));
filtered image to obtain spatial domain highpass_filtered_image =
representations. ifft2(ifftshift(highpass_filtered_F));
8. PSNR Calculation: bandpass_filtered_image =
- Calculate PSNR for each filtered image compared ifft2(ifftshift(bandpass_filtered_F));
to the original grayscale image using `psnr` function psnr_lowpass = psnr(uint8(image_gray),
from MATLAB's Image Processing Toolbox. uint8(abs(lowpass_filtered_image)));
9. Output PSNR Values: psnr_highpass = psnr(uint8(image_gray),
- Display PSNR values for each filtered image. uint8(abs(highpass_filtered_image)));
10. Display Results: psnr_bandpass = psnr(uint8(image_gray),
- Display the original grayscale image, noisy uint8(abs(bandpass_filtered_image)));
image, and the three filtered images (low-pass, high- fprintf('PSNR for Low-pass Filtered Image: %.2f\n',
pass, and band-pass) in separate subplots. psnr_lowpass);
fprintf('PSNR for High-pass Filtered Image: %.2f\n',
psnr_highpass);
fprintf('PSNR for Band-pass Filtered Image: %.2f\n',
SOURCE CODE psnr_bandpass);
% Display original and filtered images
image = imread('[Link]’); figure;
if size(image, 3) == 3 subplot(3, 2, 1), imshow(uint8(image_gray)),
image_gray = rgb2gray(image); title('Original Image');
else subplot(3, 2, 3), imshow(uint8(noisy_image)),
image_gray = image; title('Noisy Image');
end subplot(3, 2, 4),
image_gray_double = double(image_gray); imshow(uint8(abs(lowpass_filtered_image))),
[M, N] = size(image_gray_double); % Get title('Low-pass Filtered Image');
dimensions of the original image subplot(3, 2, 5),
alpha = cos(60*pi*(1:M)/M)' * cos(120*pi*(1:N)/N); imshow(uint8(abs(highpass_filtered_image))),
noisy_image = image_gray_double + alpha; % Add title('High-pass Filtered Image');
noise to the original image subplot(3,2,6),
F = fftshift(fft2(noisy_image)); % Shift zero imshow(uint8(abs(bandpass_filtered_image))),
frequency to center title('Band-pass Filtered Image');
% Define filters in the frequency domain
sigma_low = 10; OUTPUT
sigma_high = 50;
sigma_bandpass_high = 200;
sigma_bandpass_low = 50;
lowpass_filter = fspecial('gaussian', [M, N],
sigma_low);
highpass_filter = fspecial('gaussian', [M, N],
sigma_high);
highpass_filter = highpass_filter -
mean(highpass_filter(:)); % Ensure zero-sum for
high-pass effect
bandpass_filter = fspecial('gaussian', [M, N],
sigma_bandpass_high) - fspecial('gaussian', [M, N],
sigma_bandpass_low);
% Apply filters in the frequency domain

You might also like