0% found this document useful (0 votes)
24 views16 pages

DIP LAB Record III - CS

The document discusses several image processing techniques including 2D linear and circular convolution between matrices, computing the discrete Fourier transform and discrete cosine transform of an image, brightness and contrast manipulation of an image including producing the negative of an image, thresholding an image, edge detection using different edge detectors, morphological operations like dilation, erosion, opening and closing on an image, and separating the color planes of an image.

Uploaded by

Anand Print
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)
24 views16 pages

DIP LAB Record III - CS

The document discusses several image processing techniques including 2D linear and circular convolution between matrices, computing the discrete Fourier transform and discrete cosine transform of an image, brightness and contrast manipulation of an image including producing the negative of an image, thresholding an image, edge detection using different edge detectors, morphological operations like dilation, erosion, opening and closing on an image, and separating the color planes of an image.

Uploaded by

Anand Print
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/ 16

2D Linear Convolution, Circular Convolution Between Two 2D Matrices

Program :
clc;
clear;
close;
a=input(' X martix row : ');
b=input(' X matrix column : ');
c=input(' h matrix row : ');
d=input(' h matrix column : ');
disp(" Enter x seq : ");
for i=1:a
for j=1:b
x1(i,j)=input('')
end
end
disp(" Enter h seq : ");
for m=1:c
for n=1:d
h1(m,n)=input('')
end
end
// 2D Linear Convolution
y=conv2(x1,h1);
disp(' Image Matrix',x1);
disp(' Mask Matrix',h1);
disp(' 2D linear Convolution Result',y);
// Circular Convolution
sx=fft2(x1);
sh=fft2(h1);
sy=sx.*sh;
y2=ifft(sy);
disp(' circular Convolution Result',y2);
Output :
DFT & DCT of 4x4 Gray Scale Image

Program :

clc;
clear;
close;
disp("Enter f array values : ")
for i=1:4
for j=1:4
f(i,j)=input('')
end
end
x=fft2(f);
y=dct(f);
disp("DFT of 4x4 grayscal image")
disp(x);
disp("DCT of 4x4 grayscale image")
disp(y);
Output :
Brightness Enhancement, Contrast Manipulation, Image Negative of
an Image

Program :
clc;
clear;
close;
x1=imread("E:\III CS\dip img\sunflower.jpg");
x=x1;
x1=rgb2gray(x1);
xp=double(x1);
a=uint8(xp+50);
b=uint8(xp-50);
c=uint8(xp*0.5);
d=uint8(xp*2);
e=uint8(255-xp);
subplot(3,3,2),imshow(x),title("Orginal Image");
subplot(3,3,4.5),imshow(a),title("Enchance Brightness Image");
subplot(3,3,5.5),imshow(b),title("Supress Brightness Image");
subplot(3,3,7),imshow(c),title("Contrast Enlarge Image");
subplot(3,3,8),imshow(d),title("Contrast Supress Image");
subplot(3,3,9),imshow(e),title("Negative Image");
Output :
Threshold Operation on an Image

Program :

clc;
clear;
close;
a=imread("E:\III CS\dip img\aadi.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
subplot(1,2,1);
imshow(a);
title"Original Image"
subplot(1,2,2);
imshow(b);
title"Thresholded Image"
xlabel(sprintf("Threshold value is %g",t))
Output :
Edge Detection Using Different Edge Detectors

Program :

clc;
close;
clear;
im=imread('E:\III CS\dip img\aadi.jpg');
im=rgb2gray(im);
subplot(3,2,1.5),imshow(im),title" Original Image";
e1=edge(im,'sobel',0.35);
subplot(3,2,3),imshow(e1),title" sobel";
e2=edge(im,'canny');
subplot(3,2,4),imshow(e2),title" canny";
e3=edge(im,'prewitt');
subplot(3,2,5),imshow(e3),title" prewitt";
e4=edge(im,'log');
subplot(3,2,6),imshow(e4),title" log";
Output :
Dilation and Erosion operation
Program :

clc;
clear;
close;
a=imread("E:\III CS\dip img\aadi.jpg");
gry=rgb2gray(a);
bin=im2bw(gry,0.5);
se=imcreatese('rect',11,11);
er=imerode(bin,se);
dil=imdilate(bin,se);
subplot(3,2,1.5),imshow(a),title" Original Image";
subplot(3,2,3),imshow(gry),title" Gray Image";
subplot(3,2,4),imshow(bin),title" Binary Image";
subplot(3,2,5),imshow(er),title" Erosion of Binary Image";
subplot(3,2,6),imshow(dil),title" Dilation of Binary Image";
Output :
Opening And Closing Operation

Program :

clc;
clear;
close;
a=imread("E:\III CS\dip img\sunflower.jpg");
gry=rgb2gray(a);
bin=im2bw(gry,0.5);
mask=[111;111;111];
A_open=imopen(bin,mask);
A_close=imclose(bin,mask);
subplot(2,3,2),imshow(a),title" Original Image";
subplot(2,3,4),imshow(gry),title" Gray Image";
subplot(2,3,5),imshow(A_open),title" Open Image";
subplot(2,3,6),imshow(A_close),title" close Image";
Output :
Read a Colour Image And Separate the Image into Red, Blue, and Green
Planes

Program :

clc;
clear;
close;
a=imread("E:\III CS\dip img\foxy.jpg");
b=a;
subplot(2,3,2),imshow(a),title("Original Image");
a(:,:,2)=0;
a(:,:,3)=0;
subplot(2,3,4),imshow(a),title("Red Color Image");
a=b;
a(:,:,1)=0;
a(:,:,3)=0;
subplot(2,3,5),imshow(a),title("Green Color Image");
a=b;
a(:,:,1)=0;
a(:,:,2)=0;
subplot(2,3,6),imshow(a),title("Blue Color Image");
Output :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy