Documente Academic
Documente Profesional
Documente Cultură
EE-792D
Credit: 2
Contact: 3P
4. HISTOGRAM EQUALIZATION
An image may be defined as a two-dimensional function, f ( x, y) , where x and y are spatial coordinates,
and the amplitude of f at any pair of coordinates ( x, y) is called the intensity or gray level of the image at that
point. When x, y and the amplitude values of f are all finite, discrete quantities, we call the image a digital image.
The field of digital image processing refers to processing digital images by means of a digital computer. Note that a
digital image is composed of a finite number of elements, each of which has a particular location and value. These
elements are referred to as pixels.
A digital image can be represented naturally as a matrix:
f (1,1)
f (2,1)
f
...
f ( M ,1)
f (1, 2)
f (2, 2)
...
...
...
...
f ( M , 2) ...
f (1, N )
f (2, N )
...
f (M , N )
We use letters M and N , respectively, to denote the number of rows and columns in a matrix.
Example 1.3:
I = imread('football.jpg'); %reading the colour image
Imshow(I); %showing the image
original image
Assignment 1.1:
Read the image football.jpg. Find size of the image. Resize it to 150x150.
s0
if r m
Read the image cameraman.tif.Run the above program for different threshold values and find out optimum
threshold value for which you are getting better result.
original image
negative image
Assignment 2.3: Read the image football.jpg and obtain the negative image.
Example 2.4: Contrast stretching using three slopes and two threshold values T1 and T2
%contrast stretching using three slopes and two threshold values
close all;
clear all;
clc;
z=imread('cameraman.tif');%read original image
T1=input('enter threshold value between 0 to 255:');%enter threshold
T2=input('enter threshold value between 0 to 255:');%enter threshold
[m,n]=size(z);%size of gray image
for i=1:m
for j=1:n
if z(i,j)<=T1
newimage(i,j)=z(i,j);
end
if z(i,j)>T1&&z(i,j)<=T2
newimage(i,j)=2*z(i,j);
end
if z(i,j)>T2
newimage(i,j)=z(i,j);
end
end
end
subplot(1,2,1), imshow(z),title('original image');%display gray image
subplot(1,2,2),imshow(newimage),title(contrast stretching');%contrast image
original image
contrast stretching
Where I ( x, y) is resultant image due to addition of two images. x, y are coordinates of image. Image addition is
pixel to pixel. Value of pixel should not cross maximum permissible value that is 255 for grey scale image. When it
exceeds value 255, it should be clipped to 255.
Exercise 3.1: Image addition and subtraction
clear all;close all;clc;
x=imread('cameraman.tif');%read original image
y=imread('rice.png');
addition_image=imadd(x,y);
subtraction_image=imsubtract(x,y);
subplot(2,2,1),imshow(x),title('original image I1');
subplot(2,2,2),imshow(y),title('original image I2');
subplot(2,2,3),imshow(addition_image),title('addition of image I1+I2');
subplot(2,2,4),imshow(subtraction_image),title('subtraction of image I1-I2');
sk T (rk )
j 1
k n
j
pr (r j )
n
j 1
1000
1000
500
500
0
0
100
original image
200
100
200
Assignment 4.1: Read the image cameraman.tif'. If the image is a color image change it to a gray image.
Obtain histogram of the gray image using and without using standard MATLAB functions. Obtain
histogram equalization using & without using standard MATLAB functions.
original image
Assignment 5.1: Read the image cameraman.tif. Filter image using laplacian filter using standard
MATLAB functions.
original image
6.1 THEORY:
Edges are calculated by using difference between corresponding pixel intensities of an image. All the
masks that are used for edge detection are also known as derivative masks. As image is also a signal so
changes in a signal can only be calculated using differentiation. So thats why these operators are also
called as derivative operators or derivative masks.
All the derivative masks should have the following properties:
Prewitt operator provides us two masks one for detecting edges in horizontal direction and another for
detecting edges in a vertical direction. When we apply this mask on the image it prominent vertical edges.
It simply works like as first order derivate and calculates the difference of pixel intensities in a edge
region. As the centre column is of zero so it does not include the original values of an image but rather it
calculates the difference of right and left pixel values around that edge. This increase the edge intensity
and it became enhanced comparatively to the original image.
by prewitt operator
close all;
clear all;
clc;
f1=imread('coins.png');%read original image
f2=im2double(f1); %converting the image value in to double
f3=edge(f2,'prewitt'); % prewitt operation
figure,imshow(f1),title('original image');%display original image
figure,imshow(f3),title(after edge detection image');%display edge image
Original Image
Assignment 6.1: Read the image football.jpg and fiend the edge with various operators (sobel, canny,
Roberts, laplacian etc.).