Kashyap Ip
Kashyap Ip
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: -
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
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: -
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
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: -
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')
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: -
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
THEORY: -
PROCEDURE: -
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
PROCEDURE: -
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');
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: -
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');
THEORY: -
Using the marked image in the base image, it is necessary to extract the watermark from the base
image.
PROCEDURE: -
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
THEORY: -
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: -
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')
AIM: - To perform Second-level decomposition of the input image using a Haar wavelet.
THEORY: -
Using the marked image in the base image, it is necessary to extract the watermark from the base
image.
PROCEDURE: -
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.