Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

LAB REPORT NO # 09

OPEN ENDED LAB

DIGITAL IMAGE PROCESSING

MAY 1,2022
SUBMITTED BY: SYED RAGHIB
ROLL NO: 11931
SUBMITTED TO: MISS BEENISH
BE-ELECTRICAL ENGINEERING (MORNING)
LAB REPORT # 09

OBJECTIVE: -
In this lab we willUse technique study in lab to scaled up image in one axis and scale
down in another axis and rotate then add salt and pepper noise and Gaussian noise
with zero mean and unit variance by using filter remove the added noise. And also DFT
or histogram of final image

INTRODUCTION: -
In an image processing context, the histogram of an image normally refers to
a histogram of the pixel intensity values. This histogram is a graph showing the number
of pixels in an image at each different intensity value found in that image.
The imhist function creates a histogram plot by defining n equally spaced bins, each
representing a range of data values, and then calculating the number of pixels within
each range. You can use the information in a histogram to choose an appropriate
enhancement operation.
You can adjust image contrast and brightness by using the Adjust Contrast tool. You
can specify the range of the input and output values. Optionally, you can set the range
automatically based on a histogram of the image.
mage interpolation occurs when you resize or distort your image from one pixel grid to
another Zooming refers to increase the quantity of pixels, so that when you zoom
an image, you will see more detail. Interpolation works by using known data to estimate
values at unknown points.
A discrete transform is a transform whose input and output values are discrete samples,
making it convenient for computer manipulation. There are two principal reasons for
using this form of the transform. There is a fast algorithm for computing the DFT known
as the fast Fourier transform (FFT).
The discrete Fourier transform, or DFT, is the primary tool of digital signal processing.
The foundation of the product is the fast Fourier transform (FFT), a method for
computing the DFT with reduced execution time.

Q: Write a MATLAB script code to


 Read image from your desktop named pic1.png and display
Code: -
clc
clear all
A = imread('C:\Users\Syed Raghibs\OneDrive\Desktop\DIP
IMAGE\Cat.jpg');
imshow(A);
whosA

1
LAB REPORT # 09

Output: -

 Use technique study in lab to scaled up image in one axis and


scale down in another axis and rotate then add salt and pepper
noise and Gaussian noise with zero mean and unit variance by
using filter remove the added noise.
Code: -
clc
clear all
A = imread('C:\Users\Syed Raghib\OneDrive\Desktop\DIP
IMAGE\cat.jpg');
figure;
subplot(221);
imshow(A);

2
LAB REPORT # 09

title("Orginal image ");


B = imresize(A, [800 800]);
subplot(222);
imshow(B);
title("scale up ");
C = imresize(A, [200 200]);
subplot(223);
imshow(C);
title("scale down ");
D = imrotate(B,60);
figure;
subplot(121);
imshow(D);
title("rotate scale up ");
E = imrotate(C,20);
subplot(122);
imshow(E);
title("rotate scale down ");

F = imnoise(D,'salt& pepper', 0.03);


figure;
subplot(221);
imshow(F);
title("salt & pepper noise rotate scale up ");
red_channel = F(:, :, 1);
green_channel = F(:, :, 2);
blue_channel = F(:, :, 3);
Filter = fspecial('gaussian', [10 10], 4);
red = imfilter(red_channel, Filter);
green = imfilter(green_channel, Filter);
blue = imfilter(blue_channel, Filter);
p = cat(3,red, green, blue);
subplot(222);
imshow(p);
title('Noise Remove rotate scale up ');
G = imnoise(E,'salt& pepper', 0.03);
subplot(223);
imshow(G);
title("salt & pepper noise rotate scale down ");
red_channel = G(:, :, 1);
green_channel = G(:, :, 2);
blue_channel = G(:, :, 3);
Filter = fspecial('gaussian', [10 10], 4);
red = imfilter(red_channel, Filter);
green = imfilter(green_channel, Filter);
blue = imfilter(blue_channel, Filter);
o = cat(3,red, green, blue);
subplot(224);
imshow(o);
title(' Noise Remove rotate scale down ');
H = imnoise(D,'gaussian',0, 0.03);

3
LAB REPORT # 09

figure;
subplot(221);
imshow(H);
title("Gaussian noise rotate scale up ");
red_channel = H(:, :, 1);
green_channel = H(:, :, 2);
blue_channel = H(:, :, 3);
Filter = fspecial('gaussian', [10 10], 4);
red = imfilter(red_channel, Filter);
green = imfilter(green_channel, Filter);
blue = imfilter(blue_channel, Filter);
u = cat(3,red, green, blue);
subplot(222);
imshow(u);
title('Noise Remove rotate scale up ');
I = imnoise(E,'gaussian',0, 0.03);
subplot(223);
imshow(I);
title("Gaussian noise rotate scale down ");
red_channel = I(:, :, 1);
green_channel = I(:, :, 2);
blue_channel = I(:, :, 3);
Filter = fspecial('gaussian', [10 10], 4);
red = imfilter(red_channel, Filter);
green = imfilter(green_channel, Filter);
blue = imfilter(blue_channel, Filter);
y = cat(3,red, green, blue);
subplot(224);
imshow(y);
title('Noise Remove rotate scale down ');

 Display all results of images

4
LAB REPORT # 09

5
LAB REPORT # 09

6
LAB REPORT # 09

 Also show DFT and histogram of final image.


Histogram: -
figure;
subplot(211);
imshow(p);
title('salt & pepper Noise Remove rotate scale up');
subplot(212);
imhist(p)
figure;
subplot(211);
imshow(o);
title('salt & pepper Noise Remove rotate scale down');
subplot(212);
imhist(o)
figure;
subplot(211);
imshow(u);
title('Gaussian Noise Remove rotate scale up');
subplot(212);
imhist(u)
figure;
subplot(211);
imshow(y);
title('Gaussian Noise Remove rotate scale down');
subplot(212);
imhist(y);

7
LAB REPORT # 09

Output: -

8
LAB REPORT # 09

9
LAB REPORT # 09

DFT: -
clc
clear all
Img=imread('C:\Users\Syed raghib\OneDrive\Desktop\DIP IMAGE\cat.jpg');
[Img_M, Img_N,] = size(Img);
x=zeros(Img_M,Img_N);
x(40:184,40:184)= 1;
figure;
subplot(211)
imshow(x)
X = fft2(x);
X1 = fftshift(X);
subplot(212)
imshow(log(1+abs(X1)))

Output: -

10
LAB REPORT # 09

CONCLUSION:
In this lab we have learnt Imageto scaled up image in one axis and scale down in
another axis and rotate then add salt and pepper noise and Gaussian noise with zero
mean and unit variance by using filter remove the added noise. And also DFT or
histogram of final image.

11

You might also like