2015 Digital Image Processing

advertisement
Digital
Image
Processing
Lecturer Mohd Abdul Rahim Khan
February 22
2015
CEN446
Fundamental
of image
To write and execute programs for image logical operations
AND operation between two images
OR operation between two images
Calculate intersection of two images
Water Marking using EX-OR operation
NOT operation (Negative image)
Experiment 1
clc
close all
clc
close all
myimageA=imread('download.jpg');
myimageA=rgb2gray(myimageA);
myimageB=imread('download2.jpg');
myimageB=rgb2gray(myimageB);
subplot(3,2,1)
imshow(myimageA),title('Image A ');
% Display the Original Image B
subplot(3,2,2)
imshow(myimageB),title('Image B');
% Take a complement of Image A and Display it
subplot(3,2,3)
cimageA= imcomplement(myimageA );
imshow(cimageA), title('Complement of Image A');
% Take a Ex-OR of Image A and Image B and Display it
subplot(3,2,4)
% Take OR of Image A and Image B and Display it
orimage= (myimageA | myimageB);
imshow(orimage), title('Image A OR Image B ');
% Take AND of Image A and Image B and Display it
subplot(3,2,5)
andimage= myimageA & myimageB;
imshow(andimage), title('Image A AND Image B ');
subplot(3,2,6)
xorimage= xor(myimageA,myimageB);
imshow(xorimage), title('Image A XOR Image B');
To provide copy protection of digital audio, image and video two techniques are
used: encryption and watermarking. Encryption techniques normally used to
protect data during transmission from sender to receiver. Once data received at
receiver, it is decrypted and data is same as original which is not protected.
Watermarking techniques can compliment encryption by embedding secret key
into original data. Watermarking can be applied to audio, image or video data.
Watermarking technique used for can be visible or non-visible. For visible
watermarking technique, watermark image is visible on original image in light
form. In non-visible watermarking technique, watermark image is hidden
inside original image. In digital watermarking, watermarking key bits are
scattered in the image and cannot be identified. There are so many techniques
being developed for secure and robust watermarking.
Watermarking using EX-OR operation is simplest technique. In following
program, Ex-OR operation is performed between original image data and
watermarking key. To extract watermarking image, EX-OR operation is
performed again between original image and watermarking image. In this
message, message GEC RAJKOT is watermarked in the digital image in
invisible form.
Experiment 2
clc;
close;
clear;
%Original Image
[namefile,pathname]=uigetfile({'*.bmp;*.tif;*.tiff;*.jpg;*.jpeg;*.gif','IMAGE
Files (*.bmp,*.tif,*.tiff,*.jpg,*.jpeg,*.gif)'},'Chose GrayScale Image');
img=imread(strcat(pathname,namefile));
if(size(img,3)==3)
img=rgb2gray(img);
end
subplot(2,2,1);
imshow(img);
title('Original Image');
[p q] = size(img);
key = imread('download3.jpg');
key=rgb2gray(key);
key = imresize(key,[p q]);
img=uint8(img);
key=uint8(key);
subplot(2,2,2);
imshow(key);
title('Water marking key');
w_img=bitxor(img,key);
subplot(2,2,3);
imshow(w_img);
title('Watermarked image');
extracted_key=bitxor(uint8(w_img),uint8(img));
subplot(2,2,4);
imshow(extracted_key);
title('Extracted Key');
Experiment 3
clc;
clear all;
close all;
Img = (imread('download.jpg'));
Jmg = (imread('images3.jpg'));
Img=rgb2gray(Img);
Jmg=rgb2gray(Jmg);
[p q] = size(Img);
Jmg = imresize(Jmg,[p q]);
imshow(uint8(Img));
figure
imshow(uint8(Jmg)) ;
l=length(Img);
for i=1:p
for j=1:q
if Img(i,j)==Jmg(i,j)
s(i,j)=Jmg(i,j);
elseif Img(i,j)~=Jmg(i,j)
k(i,j)=Img(i,j);
end
end
end
figure,imshow(uint8(k))
figure,imshow(uint8(s))
Experiment 4
% Shrinking
clc;
close all;
clear all;
A=imread('linda.jpg');
disp('Size of original image');
c=size(A);
for i=1:2:c(1)
for j=1:2:c(2)
B((i+1)/2,(j+1)/2)=A(i,j);
end
end
imshow(A);
title('Original image');
disp('Size of shrinked image');
d=size(B);
figure;
imshow(B);
title('Shrinked image');
Exercise 3
1. Write your own matlab function addbrightness() and use it to increase
brightness of given image.
2. Write Program to read any image, resize it to 256x256.
3. Write Program to read any image and convert into Negative image.
4. Calculate mean value of image.
5. Zooming the images
Download