0% found this document useful (0 votes)
55 views20 pages

Kashyap Ip

The document appears to be a lab file submitted by a student named Ramesh Vaidyanath Kashyap for their M.Tech program at the University of Petroleum and Energy Studies. It includes a list of 10 experiments performed in the Image Processing and Machine Vision lab related to topics like gray level operations, filtering, histogram equalization, edge detection, watershed transformation, arithmetic operations, and watermarking. Each experiment section includes the aim, theory, procedure and code used to perform the given image processing technique on sample images.

Uploaded by

Pranjal Paul
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)
55 views20 pages

Kashyap Ip

The document appears to be a lab file submitted by a student named Ramesh Vaidyanath Kashyap for their M.Tech program at the University of Petroleum and Energy Studies. It includes a list of 10 experiments performed in the Image Processing and Machine Vision lab related to topics like gray level operations, filtering, histogram equalization, edge detection, watershed transformation, arithmetic operations, and watermarking. Each experiment section includes the aim, theory, procedure and code used to perform the given image processing technique on sample images.

Uploaded by

Pranjal Paul
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/ 20

University of Petroleum and Energy Studies

Department of electrical & electronics Engineering

IMAGE PROCESSING AND MACHINE VISION LAB FILE

II SEMESTER M.Tech. (A&R)

STUDENT NAME: - Ramesh Vaidyanath Kashyap SUBMITTED TO

SAP ID: - 500066550 ADESH KUMAR SIR


INDEX

S.No. NAME OF EXPERIMENT DATE OF DATE OF GRADE FACULY


PERFORM SUBMISSION SIGN
1. To perform false countering operation 29-01-2019 05-02-2019
(Gray Level) on an image.
2 To perform Average Filter Operation on 05-02-2019 12-02-2019
an image.
3 To perform Histogram Equalization 12-02-2019 26-02-2019
Operation on an image.

4 To perform Different types of operator 26-02-2019 05-03-2019


for edge detection on an image.
5 To perform Watershed Transformation 05-03-2019 12-03-2019
operation on an image.
6 To perform Arithmetic operation on an 12-03-2019 19-03-2019
image.
7 To perform Watermarking 19-03-2019 26-03-2019
implementation in spatial domain on an
image using a different mark image.
8 To perform Watermarking extraction in 26-03-2019 02-04-2019
spatial domain on a marked image.

9 To perform wavelet-based 02-04-2019 09-04-2019


implementation Watermarking in
frequency domain on an image.

10 To perform Second-level decomposition 09-04-2019 16-04-2019


of the input image using a Haar wavelet.
EXPERIMENT: - 1

AIM: - To perform false countering operation (Gray Level) on an image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -
grayslice(I,N) converts a grayscale image to an indexed image by using multilevel thresholding
approach. The function automatically calculates the threshold values based on N.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

clc
clear all
close all
a=imread('flower1.jpg');
subplot(2,3,1),imshow(a),title('original image')
%using 128 gray levels
subplot(2,3,2),imshow(grayslice(a,128),gray(128)),
title('Image with 128 gray level')
%using 64 gray levels
subplot(2,3,3),imshow(grayslice(a,64),gray(64)),
title('Image with 64 gray level')
%using 32 gray levels
subplot(2,3,4),imshow(grayslice(a,32),gray(32)),
title('Image with 32 gray level')
%using 16 gray levels
subplot(2,3,5),imshow(grayslice(a,16),gray(16)),
title('Image with 16 gray level')
%using 8 gray levels
subplot(2,3,6),imshow(grayslice(a,8),gray(8)),
title('Image with 8 gray level')
RSULT: - performed different types of gray level on an image.
EXPERIMENT: - 2

AIM: - To perform Average Filter Operation on an image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -

The filter works as low-pass one. The basic idea behind filter is for any element of the signal (image) take
an average across its neighborhood.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

a=imread('proimage.jpg');
% Addition of noise to the input image
b=imnoise(a,'salt & pepper');
c=imnoise(a,'gaussian');
d=imnoise(a,'speckle');
% Defining 3x3 and 5x5 kernel
h1=1/9*ones(3,3);
h2=1/25*ones(5,5);
% Attempt to recover the image
b1=convn(b,h1,'same');
b2=convn(b,h2,'same');
c1=convn(c,h1,'same');
c2=convn(c,h2,'same');
d1=convn(d,h1,'same');
d2=convn(d,h2,'same');
%Displaying the result
figure,subplot(2,2,1),imshow(a),title('Original Image'),
subplot(2,2,2),imshow(b),title('Salt & Pepper noise'),
subplot(2,2,3),imshow(uint8(b1)),title('3 x 3 Averaging filter'),
subplot(2,2,4),imshow(uint8(b2)),title('5 x 5 Averaging filter')
%...........................
figure,subplot(2,2,1),imshow(a),title('Original Image'),
subplot(2,2,2),imshow(c),title('Gaussian noise'),
subplot(2,2,3),imshow(uint8(c1)),title('3 x 3 Averaging filter'),
subplot(2,2,4),imshow(uint8(c2)),title('5 x 5 Averaging filter'),
%..................
figure,subplot(2,2,1),imshow(a),title('Original Image'),
subplot(2,2,2),imshow(d),title('Speckle noise'),
subplot(2,2,3),imshow(uint8(d1)),title('3 x 3 Averaging filter'),
subplot(2,2,4),imshow(uint8(d2)),title('5 x 5 Averaging filter'),
RESULT:- Performed Average Filter on an image.
EXPERIMENT: - 3

AIM: - To perform Histogram Equalization Operation on an image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -

Histogram equalization is a method in image processing of contrast adjustment using the image's
histogram. This method usually increases the global contrast of many images, especially when the usable
data of the image is represented by close contrast values. Through this adjustment, the intensities can be
better distributed on the histogram.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

clc
clear all
close all
a=imread('deer1.jpg');
%perform histogram equalization
b=histeq(a);
subplot(2,2,1),imshow(a),title('original image'),
subplot(2,2,2),imshow(b),title('After histogram equalization'),
subplot(2,2,3),imhist(a),title('original histogram')
subplot(2,2,4),imhist(b),title('After histogram equalization')

RESULT: - Performed Histogram Equalization on an image.


EXPERIMENT: - 4

AIM: - To perform Different types of operator for edge detection on an image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -

Edge detection is the name for a set of mathematical methods which aim at identifying points in a digital
image at which the image brightness changes sharply or, more formally, has discontinuities. The points
at which image brightness changes sharply are typically organized into a set of curved line segments
termed edges.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

clear all;
close all;
clc;
a=imread('Tomato2.jpg');
a=rgb2gray(a);
b=edge(a,'roberts');
c=edge(a,'sobel');
d=edge(a,'prewitt');
e=edge(a,'log');
f=edge(a,'canny');
imshow(a),title('Original Image')
figure,imshow(b),title('Roberts')
figure,imshow(c),title('Sobel')
figure,imshow(d),title('Prewitt')
figure,imshow(e),title('Log')
figure,imshow(f),title('Canny')
RESULT: - Performed different types of operator for edge detection on an image.
EXPERIMENT: - 5

AIM: - To perform Watershed Transformation operation on an image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -

A watershed is a transformation defined on a grayscale image. The name refers metaphorically to a


geological watershed, or drainage divide, which separates adjacent drainage basins. The watershed
transformation treats the image it operates upon like a topographic map, with the brightness of each
point representing its height, and finds the lines that run along the tops of ridges.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

a=imread('sunflower2.jpg');
a1=imnoise(a,'salt & pepper',0.1);
b=watershed(a,4);
b1=watershed(a1,4);
imshow(a),title('Original Image')
figure,imshow(a1),title('Noisy Image')
figure,imshow(b),title('Watershed of Original')
figure,imshow(b1),title('Watershed of Noisy Image')
RESULT: -Performed Watershed transformation operation on an image.
EXPERIMENT: - 6

AIM: - To perform Arithmetic operation on an image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

a= imread('1.jpg');
b= rgb2gray(a);
c= a + b ;
d= (a)- b;
e = a.*b;
f = a./b ;
figure,imshow(c), title('addition');
figure,imshow(d), title('subtraction');
figure,imshow(e), title('multiplication');
figure,imshow(f), title('division');

RESULT: - Performed Arithmetic operation on an image.


EXPERIMENT: - 7

AIM: - To perform Watermarking implementation in spatial domain on an image using a different


mark image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -

Watermarking and cryptography are closely related but watermarking is distinct from encryption. In the
digital watermarking system, information carrying the watermarked image is transmitted or stored, and
then decoded to be resolved by the receiver.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

clc
clear all
close all
a=imread('1.jpg');
figure, imshow(a),title('Base Image');
b=imresize(rgb2gray(imread('10.jpg')),[32 32]);
[m1 n1]=size(b);
figure,imshow(b),title('Mark Image');
[m n]=size(a);
i1=1;
j1=1;
p=1
c=a; iii=1;jjj=1;
for ff=1:8,
for i=1:32,
jjj=1;
for j=j1:j1+n1-1,
a(i,j)=bitand(a(i,j),254);% LSB of base image is set to zero.
temp=bitand(b(i,jjj),2^(ff-1));%MSB of the mark is extracted.
temp=temp/(2^(ff-1));
c(i,j)=bitor(a(i,j),temp);%MSB of mark is inerted into the %LSB of the base.
jjj=jjj+1;
end
end
j1=j1+32;
end
figure,imshow(uint8(c)),title('Marked Image');
imwrite(c,'1.jpg','jpg');

RESULT: - performed Watermarking implementation in spatial domain on an image using a different


mark image.
EXPERIMENT: - 8

AIM: - To perform Watermarking extraction in spatial domain on a marked image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -

Using the marked image in the base image, it is necessary to extract the watermark from the base
image.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

close all;
clear all;
clc
c1=imread('1.jpg');
figure,imshow(uint8(c1)),title('Marked Image');
i1=1;
j1=1;
d=zeros(32,32);
[m1 n1]=size(d);
jjj=1;
for ff=1:8,
for i=1:32
for j=j1:j1+n1-1,
temp=bitand(c1(i,j),1);
temp=temp*2^(ff-1);
d(i,jjj)=d(i,jjj)+temp;
jjj=jjj+1;
end
jjj=1;
end
j1=j1+32;
end
figure,imshow(uint8(d)),title('Extracted Mark');
RESULT: - performed Watermarking extraction in spatial domain on a marked image.
EXPERIMENT: - 9

AIM: - To perform wavelet-based implementation Watermarking in frequency domain on an image.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -

Implements the wavelet-based watermarking in following tasks: -

1. The wavelet transform of the input image is performed. Only one level of decomposition is
performed to get four sub-bands, namely, LL, LH, HL & HH respectively.
2. The key, which is the embedded, is taken. The key is multiplied with the weighting function and
it is then added to the sub-band information of the original image.
3. The inverse wavelet transform is then taken to get the watermarked image.
4. In order to retrieve key ,the forward wavelet transform of the watermarked image is taken and
it is subtracted from the wavelet coefficients of the original image to retrieve key image.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -

img = imread('flower1.jpg');
img = rgb2gray(img);
img=imresize(img,[300 300]);
img = double(img);
c = 0.001; %Initialise the weight of Watermarking
figure,imshow(uint8(img)),title('Original Image');
[p q] = size(img);
p1=p;
q1=q;
%Generate the key
n = rgb2gray(imread('1.jpg'));
key = imresize(double(n),[p q]);
figure,imshow(uint8(key)),title('Key');
[ca,ch,cv,cd] = dwt2(img,'db1');%Compute 2D wavelet transform
%Perform the watermarking
y = [ca ch;cv cd];
Y = y + c*key;
p=p/2;q=q/2;
for i=1:p
for j=1:q
nca(i,j) = Y(i,j);
ncv(i,j) = Y(i+p,j);
nch(i,j) = Y(i,j+q);
ncd(i,j) = Y (i+p,j+q);
end
end
%Display the Watermarked image
wimg = idwt2(nca,nch,ncv,ncd,'db1');
figure,imshow(uint8(wimg)),title('Watermarked Image');
%Extraction of key from Watermarked image
[rca,rch,rcv,rcd] = dwt2(wimg,'db1');%Compute 2D wavelet transform
n1=[rca,rch;rcv,rcd];
N1=n1-y;
figure,imshow(double(N1*4)),
title('Extract the key from watermarked image')

RESULT: - performed wavelet-based implementation Watermarking in frequency domain on an image.


EXPERIMENT: - 10

AIM: - To perform Second-level decomposition of the input image using a Haar wavelet.

APPARATUS REQUIRED: - computer system with installed MATLAB software, camera

THEORY: -

Using the marked image in the base image, it is necessary to extract the watermark from the base
image.

PROCEDURE: -

1. Capture the image using camera.


2. Open MATLAB in computer system.
3. Write MATLAB program and write location of image.
4. run MATLAB code.

CODE: -
clc
clear all
close all
img=imread('puppy.jpg');
a=imresize(img,[300 300]);
%First level decomposition
[p q r s]=dwt2(single(a),'db1');
b=[uint8(p), q; r,s];
%Second level decomposition
[p1 q1 r1 s1]=dwt2(p,'db1');
b1=[p1,q1; r1, s1];
b2=[uint8(b1), q; r s];
imshow(b2)
RESULT: - performed Second-level decomposition of the input image using a Haar wavelet.

You might also like