KEMBAR78
DIP Project | PDF | Discrete Fourier Transform | Convolution
0% found this document useful (0 votes)
4 views14 pages

DIP Project

Uploaded by

Aijt
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)
4 views14 pages

DIP Project

Uploaded by

Aijt
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
You are on page 1/ 14

1.

Perform 2D Linear Convolution, Circular Convolution between


two 2D matrices

clc;
clear;
x=input("Enter the 1st matrix for linear convolution");
h=input("Enter the 2nd matrix for linear convolution");
y=conv2(x,h);
disp(y);
x1=input("Enter the 1st matrix for circular convolution");
x2=input("Enter the 2nd matrix for circular convolution");
x1=fft(x1,-1);
x2=fft(x2,-1);
x3=x1.*x2;
z=fft(x3,1);
disp(z);

Output
2.Perform Discrete Fourier Transform(DFT), Discrete Cosine
Transform(DCT) of 4*4 image

clc;
clear;
x=input("Enter matrix to find DFT");
l=length(x);
n=4;
x1=fft(x,-1);
disp(x1);
y=input("Enter matrix to find DCT");
y1=dct(y,-1);
disp(y1);

Output
3.Perform Brightness Enhancement, Contrast Manipulation, Image
negative of an image.

clear;
clc;
x=imread("C:\Users\USER\Pictures\lenaimage1.jpg");
a=rgb2gray(x);
figure;
subplot(3,2,1)
imshow(x);
title('Original image');
subplot(3,2,2)
imshow(a);
title('Gray image');
b=double(a)+50;
b=uint8(b);
subplot(3,2,3)
imshow(b)
title('Brightness Enhancement');
c=double(a)*0.5;
c=uint8(c);
d=double(c)*2;
d=uint8(d);
subplot(3,2,4)
imshow(c);
title('Increase in contrast');
subplot(3,2,5)
imshow(d)
title('Decrease in contrast');
f=imcomplement(x);
subplot(3,2,6)
imshow(f);
title('Negative of an image');
Output
4.Perform Threshold Operation on an image

clear;
clc;
a=imread("C:\Users\USER\Pictures\lenaimage1.jpg");
a=rgb2gray(a);
[m n]=size(a);
t=input('Enter the threshold parameter');
for i=1:m
for j=1:n
if(a(i,j)<t)
b(i,j)=0;
else
b(i,j)=255;
end
end
end
imshow(b);
title('threshold image');
xlabel(sprintf('threshold value is %g',t));
Output
5.Perform Edge Detection using different edge detectors

clear;
clc;
a=imread("C:\Users\USER\Pictures\lenaimage1.jpg");
b=rgb2gray(a);
c=edge(b,'sobel');
d=edge(b,'prewitt');
e=edge(b,'log');
f=edge(b,'canny');
figure;
subplot(3,2,1)
imshow(a);
title('Original image');
subplot(3,2,2)
imshow(b);
title('Gray image');
subplot(3,2,3)
imshow(c)
title('Sobel');
subplot(3,2,4)
imshow(d);
title('Prewitt');
subplot(3,2,5)
imshow(e);
title('Log');
subplot(3,2,6)
imshow(f);
title('Canny');
Output
6.Perform Dilation and Erosion Operation

clc;
clear;
a=imread("C:\Users\USER\Pictures\morph.png");
SE=imcreatese('rect',6,6);
img=imdilate(a,SE);
img1=imerode(a,SE);
figure;
subplot(2,2,1)
imshow(a);
title('Original Image');
subplot(2,2,2)
imshow(img);
title('Dilated image');
subplot(2,2,3)
imshow(a);
title('Original Image');
subplot(2,2,4)
imshow(img1);
title('Eroded image');
Output
7.Perform Opening and Closing Operation

clc;
clear;
a=imread("C:\Users\USER\Pictures\sample.png");
SE=imcreatese('rect',15,15);
img=imopen(a,SE);
img1=imclose(a,SE);
figure
subplot(2,2,1)
imshow(a);
title('Original image');
subplot(2,2,2)
imshow(img);
title('Opened image');
subplot(2,2,3)
imshow(a);
title('Original image');
subplot(2,2,4)
imshow(img1);
title('Closed image');
Output
8.Read a Colour image and separate the image into red,blue and
green planes

clc;
clear;
a=imread("C:\Users\USER\Pictures\lenaimage1.jpg");
b=a;
subplot(2,2,1)
imshow(a);
title('Rgb image');
a(:,:,2)=0;
a(:,:,3)=0;
subplot(2,2,2)
imshow(a);
title('Red image');
a=b;
a(:,:,1)=0;
a(:,:,3)=0;
subplot(2,2,3)
imshow(a);
title('Green image');
a=b;
a(:,:,1)=0;
a(:,:,2)=0;
subplot(2,2,4)
imshow(a);
title('Blue image');
Output

You might also like