Fundamentals of Image Processing Lab Manual 2014 PDF
Fundamentals of Image Processing Lab Manual 2014 PDF
Image Processing
Laboratory Manual
CERTIFICATE
January-2014 to April-2014.
Solve exercise given at the end of each practical, write answers and execute it
Write and execute all programs either in MATLAB or SCILAB. You can cut and
paste results of image processing in soft copy of this lab manual. Write all the
programs in separate folder. Prepare your folder in your laptop/computer.
There are two SET of experiments. SET 1 having seven experiments. Students
must complete first SET of seven experiments before 15th March 2014 and get
signature of faculties in all six experiments. SET 2 having another 5
experiments. Students should complete SET2 before 30 th April 2014.
AIM: Write program to read and display digital image using MATLAB or
SCILAB
Introduction of SCILAB:
SciLab is a programming language for mathematical operations It provides
development environment for mathematical programming. It is very much
useful for matrix manipulation hence it is good choice for signal processing
and image processing applications. It is similar to MATLAB. MATLAB is
commercial software while SCILAB is open source software. It has one
thousand four hundred in-built functions and it is growing day by day.
Image and Video processing toolbox will be useful for this subject.
B = zeros(3,3)
0 0 0
B = 0 0 0
0 0 0
myImage=imread(‘/home/chv/test.bmp’)
The image filename can be given as a full file path or as a file path relative to
the SciLab current directory. The current directory can be changed from the
main SciLab interface window or by cd (change directory command). The
supported file formats include ‘bmp’, ‘gif’, ‘jpg’ and ‘png’.
Drawing of intensity profile along single line on given image (Scan one line
along the image and draw intensity values (1-D signal)) can be done by
function improfile()
Example:
improfile(myImage,[0,150],[200,150]);
If given image is chess-board pattern, profile graph would be squarewave.
:: WORKSHEET ::
[1] Give following commands in SCILAB, observe output and write
explanation of each command
t = 0:0.01:1
y=sin(2*%pi*10)
plot(y)
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
imgData=imread('black.bmp');
[Rows,Cols]=size(imgData);
imshow(imgData);
for i=1:Rows
for j=1:Cols
if(i>Rows/4 && i<3*Rows/4)
if(j>Cols/4 && j<3*Cols/4)
imgData(i,j)=0;
end
end
end
end
figure;
imshow(imgData);
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Introduction:
Image enhancement can be done in two domain: [1] Spatial Domain and
[2] Transform domain.
Threshold operation:
s=0 if r ≤ m
s = 255 if r > m
Where m = threshold
Run above program for different threshold values and find out optimum
threshold value for which you are getting better result.
Horizontal flipping:
% Experiment 2: Flip given image horizontally
% Read in an image
filename=input('Enter file name: ','s');
imagedata = imread(filename);
if(ndims(imagedata)==3)
imagedata=rgb2gray(imagedata);
end
%Determine the size of the image
[rows,cols] = size(imagedata);
%Declare a new matrix to store the newly created flipped image
FlippedImageData = zeros(rows,cols);
%Generate the flipped image
for r = 1:rows
for c = 1:cols
FlippedImageData(r,cols+1-c) = imagedata(r,c);
end
end
%Display the original image and flipped image
Negative Image:
Negative Image can be obtained by subtracting each pixel value from 255.
255
s = 255-r
r 255
[rows,cols]=size(img);
neg_img=zeros(rows,cols);
for r = 1:rows
for c = 1:cols
neg_img(r,c) = 255-img(r,c); %Calculate negative image
end
end
%Display original and negative images
subplot(2,1,1); imshow(img);
subplot(2,1,2); imshow(neg_img,[]);
s = x.r 0 ≤ r<a
s = y.r a ≤ r<b
s = z.r b ≤ r<255
Where x,y and z are different slopes
a b
RED line shows piecewise approximation
MATLAB Program for contrast stretching:
% Experiment No. 2 Contrast stretching using three slopes
% and two threshold values a & b
clc;
clear all;
[namefile,pathname]=uigetfile({'*.bmp;*.tif;*.tiff;*.jpg;*.jpe
g;*.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
[row, col]=size(img);
newimg=zeros(row,col);
a=input('Enter threshold value a: ');
b=input('Enter threshold value b: ');
for i=1:row
for j=1:col
if(img(i,j)<=a)
newimg(i,j)=img(i,j);
end
if (img(i,j)>a && img(i,j)<=b)
newimg(i,j)=2*img(i,j);
end
if(img(i,j)>b)
newimg(i,j)=img(i,j);
end
end
end
subplot(2,1,1); imshow(uint8(img));
subplot(2,1,2); imshow(uint8(newimg));
[1] In contrast stretching program take threshold values 50 and 100, Use
slope 3 for gray levels between 0 to 50, slope 2 for gray levels between 50 to
100 and slope 1 for rest gray levels. Modify and write program again.
Execute it for some image.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Where I(x,y) is resultant image due to addition of two images. x and y are
coordinates of image. Image addition is pixel to pixel. Value of pixel should
not cross maximum allowed value that is 255 for 8 bit grey scale image.
When it exceeds value 255, it should be clipped to 255.
To increase overall brightness of the image, we can add some constant value
depending on brightness required. In example program we will add value 50
to the image and compare brightness of original and modified image.
Multiplication operation can be used to mask the image for obtaining region
of interest. Black and white mask (binary image) containing 1s and 0s is
multiplied with image to get resultant image. To obtain binary image
function im2bw() can be used. Multiplication operation can also be used to
increase brightness of the image
Division operation results into floating point numbers. So data type required
is floating point numbers. It can be converted into integer data type while
storing the image. Division can be used to decrease the brightness of the
image. It can also used to detect change in image.
Result:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] Write Program to read any image, resize it to 256x256. Apply square
mask shown in following figure so that only middle part of the image is
visible.
128 256
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Lab Manual of Fundamentals of Image Processing Page 22
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Write your own matlab function addbrightness() and use it to increase
brightness of given image.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Program:
Experiment No. 4 Image Logical Operations
%Image Processing Lab, E.C. Department, GEC Rajkot
%Logical operations between two image circle and pentagon is shown
clc
close all
clc
close all
myimageA=imread('circle.jpg');
myimageA=rgb2gray(myimageA);
myimageB=imread('pentagon.jpg');
myimageB=rgb2gray(myimageB);
subplot(3,2,1)
imshow(myimageA),title('Image A ');
Image A 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.
Result:
:: WORKSHEET ::
[1] Prepare any two images of size 256x256 in paint. Save it in JPEG format
256 gray levels. Perform logical NOR, NAND operations between two images.
Write program and paste your results.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
E.C. Department, Government Engineering College, Rajkot Page 27
Result after execution of program:
Pseudo code:
Calculate histogram:
close all;
clear all;
[filename,pathname]=uigetfile({'*.bmp;*.jpg;*.gif','Choose
Poorly scanned Image'});
myimage=imread(filename);
if(size(myimage,3)==3)
myimage =rgb2gray(myimage);
end
imhist(myimage);
newimage= histeq(myimage);
figure;
subplot(2,2,1);imshow(myimage); title('Original image');
subplot(2,2,2);imshow(newimage); title('Histogram equalized
mage');
% Experiment No. 5
%Program for calculation and equalisation of the histogram
% Image Processing Lab, EC Department, GEC Rajkot
close all;
clear all;
[filename,pathname]=uigetfile({'*.bmp;*.jpg;*.gif','Choose
Poorly scanned Image'});
data=imread(filename);
if(size(data,3)==3)
data=rgb2gray(data);
end
sum=sum+myhist(i+1);
sum_of_hist(i+1)=sum;
end
area=rows*cols;
%Dm=input('Enter no. of gray levels in output image: ');
Dm=256;
for i=1:rows
for j=1:cols
n=double(data(i,j));
data(i,j)=sum_of_hist(n+1)*Dm/area;
end
end
%Calculation of histogram for equalised image
for i=1:rows
for j=1:cols
m=double(data(i,j));
myhist(m+1)=myhist(m+1)+1;
end
end
subplot(2,2,3);bar(myhist);title('Equalised Histogram');
1000
500
0
0 100 200 300
2000
1000
0
0 100 200 300
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
{
int n=data[i][j];
data[i][j]=sum_of_hist[n]*Dm/area;
}
}
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
{
int n=data[i][j];
hist[n]=hist[n]+1;
}
}
printf("Equalised histogram:\n");
print_histogram();
getch();
}
void image::print_histogram()
{
int i,j;
printf("\n\n");
printf(" Occurence of gray levels ---->\n");
printf(" ");
for(i=0;i<=25;i++)printf("_");
printf("\n");
for(i=0; i<16; i++)
{
R
Video
G
Viewer
B
Video Vi ewer
Histogram
Teddy.jpg G
2 User
B
Histogram1 M atrix Vector
Image From Fi le Concatenate Scope
Histogram2
Run simulation and see result. Change file and do experiment again.
(Copy and paste your original image, its histogram, equalized image and its
histogram)
1 0 x x
x' y ' 1 = 0 1 y y
0 0 1 1
S x 0 0 x
x' y ' 1 = 0 Sy 0 y
0 0 1 1
cos sin 0 x
x' y ' 1 = sin cos 0 y
0 0 1 1
x’ = x y’ = y × shy
1 sh y 0 x
Yshear= 0 1 0 y
0 0 1 1
Orignial Image
Shear in X direction
[1] In above program, modify matrix for geometric transformation and use
imtransform() function for modified matrix. Show the results and your
conclusions.
Program:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Conclusion:
Introduction:
Image restoration is the process of removing or minimizing known
degradations in the given image. No imaging system gives perfect quality of
recorded images due to various reasons.
Degradation of images can occur due to many reasons. Some of them are as
under:
Poor Image sensors
Defects of optical lenses in camera
Non-linearity of the electro-optical sensor;
Graininess of the film material which is utilised to store the image
Relative motion between an object and camera
Wrong focus of camera
Atmospheric turbulence in remote sensing or astronomy
Degradation due to temperature sensitive sensors like CCD
Poor light levels
Exercise:
[1] Draw conclusion from two figures in this experiment. Which filter is
better to remove salt and pepper noise ?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] Write mathematical expression for arithmetic mean filter, geometric
mean filter, harmonic mean filter and contra-harmonic mean filter
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[3] What is the basic idea behind adaptive filters?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Introduction:
Spatial Filtering is sometimes also known as neighborhood processing.
Neighborhood processing is an appropriate name because you define a
center point and perform an operation (or apply a filter) to only those pixels
in predetermined neighborhood of that center point. The result of the
operation is one value, which becomes the value at the center point's
location in the modified image. Each point in the image is processed with its
neighbors. The general idea is shown below as a "sliding filter" that moves
throughout the image to calculate the value at the center location.
clear;
clc;
x=input("Enter value of x: ")
y=input("Enter value of y: ")
n=length(x)
k=length(y)
for z=n+1:n+k-1
x(z)=0;
end
for u=k+1:n+k-1
y(u)=0;
end
for i=1:n+k-1
s(i)=0
for j=1:i
s(i)=(x(j)*y(i-j+1))+s(i)
end
end
subplot(3,1,1)
plot2d3(x)
Lab Manual of Fundamentals of Image Processing Page 44
subplot(3,1,2)
plot2d3(y)
subplot(3,1,3)
plot2d3(s)
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
clear;
clc;
x=input("Enter value of x in matrix form: ")
y=input("Enter value of y in matrix form: ")
[xrows,xcols]=size(x);
[yrows,ycols]=size(y);
result=zeros(xrows+yrows,xcols+ycols)
for r = 1:xrows-1
for c = 1:xcols-1
sum=0;
for a=0:yrows
for b=0:ycols
sum=sum+x(r+a,c+b)*y(a+1,b+1);
end
end
E.C. Department, Government Engineering College, Rajkot Page 45
result(r,c)=sum;
end
end
L1 = L1/sum(L1);
filt_image= conv2(double(myimage),double(L1));
subplot(3,2,2);
imshow(filt_image,[]);
title('Filtered image with mask L1');
L2 = L2/sum(L2);
filt_image= conv2(double(myimage),double(L2));
subplot(3,2,3);
imshow(filt_image,[]);
title('Filtered image with mask L2');
L3 = L3/sum(L3);
filt_image= conv2(double(myimage),double(L3));
subplot(3,2,4);
imshow(filt_image,[]);
title('Filtered image with mask L3');
filt_image= conv2(double(myimage),H1);
subplot(3,2,5);
imshow(filt_image,[]);
title('Filtered image with mask H1');
E.C. Department, Government Engineering College, Rajkot Page 47
filt_image= conv2(double(myimage),H2);
subplot(3,2,6);
imshow(filt_image,[]);
title('Filtered image with mask H1');
figure;
subplot(2,2,1);
imshow(myimage); title('Original Image');
% The command fspecial() is used to create mask
% The command imfilter() is used to apply the gaussian filter mask to the image
% Create a Gaussian low pass filter of size 3
gaussmask = fspecial('gaussian',3);
filtimg = imfilter(myimage,gaussmask);
subplot(2,2,2);
imshow(filtimg,[]),title('Output of Gaussian filter 3 X 3');
avgfilt = [ 1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1;
1 1 1 1 1 1 1];
avgfiltmask = avgfilt/sum(avgfilt);
convimage= conv2(double(myimage),double(avgfiltmask));
subplot(2,2,3);
imshow(convimage,[]);
title('Average filter with conv2()');
filt_image= conv2(double(myimage),H3);
subplot(3,2,6);
imshow(filt_image,[]);
title('Filtered image with mask H3');
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] What is need for padding? What is zero padding? Why it is required?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Introduction:
In spatial domain, we perform convolution of filter mask with image data. In
frequency domain we perform multiplication of Fourier transform of image
data with filter transfer function.
:: WORKSHEET ::
[1] Instead of following pre-processing step in above program use fftshift function to shift
FFT in the center. See changes in the result and write conclusion.
Conclusion:
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Lab Manual of Fundamentals of Image Processing Page 52
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Introduction:
Image segmentation is to subdivide an image into its component regions or
objects. Segmentation should stop when the objects of interest in an
application have been isolated. Basic purpose of segmentation is to partition
an image into meaningful regions for particular application The
segmentation is based on measurements taken from the image and might be
grey level, colour, texture, depth or motion.
Edge detection can be done by first order derivative and second order
derivative operators.
Sobel operator performs well for image with noise compared to Prewitt
operator because Sobel operator performs averaging along with edge
detection.
Because Sobel operator gives smoothing effect, spurious edges will not
be detected by it.
Second derivative operators are sensitive to the noise present in the image
so it is not directly used to detect edge but it can be used to extract
secondary information like …
Used to find whether point is on darker side or white side depending
on sign of the result
Zero crossing can be used to identify exact location of edge whenever
there is gradual transitions in the image
outimage=conv2(double(data),double(M));
figure;
imshow(outimage);
end
close all
%Write an image to a file
Lab Manual of Fundamentals of Image Processing Page 56
imwrite(mat2gray(outimage),'outimage.jpg','quality',99);
:: WORKSHEET ::
[1] Get mask for “Prewitt”, “Canny”, “Sobel” from the literature and write
MATLAB/SCILAB program for edge detection using 2D convolution
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
[2] Understand following C++ program written for edge detection. Different
member functions are written for image class. Image class and member
function are written in Image.h header file and used in main program in
file image.cpp
//file image.h
# include <iostream.h>
# include <conio.h>
# include <stdio.h>
# include <string.h>
# define rows 10
# define cols 10
class image
{
private:
int data[10][10];
public:
void write_image(char[]);
void read_image(char[]);
void edge_detect(char[]);
};
fread(data,sizeof(int),k,f1);
for(i=1; i<rows-1;i++)
{
for(j=1; j<cols-1; j++)
{
sum=0;
for(a=-1; a<2; a++)
{
for(b=-1;b<2;b++) sum=sum+data[i+a][j+b]*QM[a+1][b+1];
}
if(sum<0) sum=0;
if(sum>16) sum=15;
outimage[i][j]=sum;
}
}
cout<<"\nEdge detection using Quick mask:"<<endl;
for(i=0; i<rows;i++)
{
for(j=0; j<cols; j++) printf("%02d ", outimage[i][j]);
cout<<endl;
}
fclose(f1);
//file Image.cpp
# include "d:\image\image.h"
void help();
void main(int argc, char* argv[])
{
image I;
char file_name[30];
clrscr();
if(argv[1])
{
if(!argv[2])
{
printf("Enter file name: ");
scanf("%s",file_name);
}
else
{
strcpy(file_name,argv[2]);
}
if(!strcmp(argv[1],"write"))
{I.write_image(file_name);}
else if(!strcmp(argv[1],"read"))
{I.read_image(file_name);}
else if(!strcmp(argv[1],"edge"))
{ I.edge_detect(file_name); }
else if(!strcmp(argv[1],"hist"))
{ }
else
{help();}
}
else {help();}
}
void help()
{
printf("\n\t\t Image Processing Tutorial !");
printf("\t\t\tUsage :\n");
printf("\t\t\timage <operation> <filename>\n");
printf("\t\t\tFor example :\n ");
printf("\t\t\timage write data : To write image in \"data\" file\n");
printf("\n\t\t\tOther Operations:\n");
printf("\n\t\t read: read image\n");
printf("\n\t\t edge : Edge detection\n");
printf("\n\t\t hist : display histogram of image\n");
}
Original Image of size 1010: Edge detection after applying quick mask:
1111111111
00 00 00 00 00 00 00 00 00 00
1111111111
00 00 00 00 00 00 00 00 00 00
1111111111
00 00 00 00 00 00 00 00 00 00
1119999111
1119999111 00 00 00 15 16 16 15 00 00 00
1119999111 00 00 00 16 00 00 16 00 00 00
1119999111 00 00 00 16 00 00 16 00 00 00
1111111111
1111111111
1111111111
Exercise:
[1] Modify above program for edge detection using kirsch, prewitt & sobel mask
[2] Add member function LPF() to image class for spatial filtering of given image
Hint: Use following low pass convolution mask for low pass filtering
0 1 0
1/6 * 1 2 1
0 1 0
Introduction:
Morphology is a branch of biology that deals with form and structure
of animal and plant
In image processing, we use mathematical morphology to extract
image components which are useful in representation and description
of region shape such as … Boundaries, Skeletons, Convex hull,
Thinning, Pruning etc.
Two Fundamental morphological operations are: Erosion and dilation
Dilation adds pixels to the boundaries of objects in an image, while
erosion removes pixels on object boundaries.
Erosion operation: The value of the output pixel is the minimum value
of all the pixels in the input pixel’s neighborhood. In a binary image, if
any of the pixels is set to 0, the output pixel is set to 0.
Program:
% Program to demonstrate Erosion and Dilation
% Image Processing Lab, EC Department, GEC Rajkot
clear all;
clc;
while 1
K = menu('Erosion and dilation demo','Choose
Image','Choose 3x3 Mask','Choose 5x5 Mask','Choose
Structure Image','Erosion','Dilation','Opening',
'Closing','EXIT')
%B=[1 1 1;1 1 1;1 1 1;];
switch K
case 1,
[namefile,pathname]=uigetfile({'*.bmp;*.tif;*.tiff;*.jpg;
*.jpeg;*.gif','IMAGE Files (*.bmp,*.tif,*.tiff,*.jpg,
*.jpeg,*.gif)'},'Chose GrayScale Image');
A=imread(strcat(pathname,namefile));
%data=rgb2gray(data);
imshow(A);
case 2,
B=[1 1 1;1 1 1;1 1 1;];
case 3,
B=[1 1 1 1 1;1 1 1 1 1;1 1 1 1 1;1 1 1 1 1;1 1 1 1 1;];
case 4,
[namefile,pathname]=uigetfile({'*.bmp;*.tif;*.tiff;*.jpg;
*.jpeg;*.gif','IMAGE Files (*.bmp,*.tif,*.tiff,*.jpg,
*.jpeg,*.gif)'},'Chose GrayScale Image');
B=imread(strcat(pathname,namefile));
%data=rgb2gray(data);
figure;
imshow(B);
case 5,
C=imerode(A,B);
figure;
imshow(C);
case 6,
C=imdilate(A,B);
figure;
imshow(C)
case 7,
C=imdilate(A,B);
D=imerode(C,B);
figure;
imshow(D)
case 8,
C=imerode(A,B);
D=imdilate(C,B);
figure;
imshow(D)
case 9,
break;
otherwise,
E.C. Department, Government Engineering College, Rajkot Page 63
msgbox('Select proper mask');
end
end
close all
%Write an image to a file
imwrite(mat2gray(outimage),'outimage.jpg','quality',99);
WORKSHEET ::
[1] What is cryptography?
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
[2] What is sateganography?
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
[3] How watermarking differs from cryptography and sateganography?
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Execute above program given in this experiment on suitable image, cut and
paste resultant images on separate page and write your conclusion.
AIM:
To write and execute program for wavelet transform on given image and
perform inverse wavelet transform to reconstruct image.
Introduction:
Wavelet transform is relatively recent signal and image processing tool
which has many applications. Basis functions of Fourier transform is
sinusoids while basis functions of wavelet transform is wavelets.
Execute program given in this experiment on suitable image, cut and paste
resultant images on separate page and write your conclusion.