Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Experiment No.03: LAB Manual Part A

You are on page 1of 13

LAB Manual

PART A
(PART A : TO BE REFFERED BY STUDENTS)

Experiment No.03
A.1 Aim:
Implementation of Point Processing image enhancement Operations in Spatial Domain.

A.2 Prerequisite:
1 Matlab programming syntax (Refer the Matlab manual).
2.Knowledge of point processing operations.
3. Availability of Soft copy of your Photograph for experiment.

A.3 Outcome:
After successful completion of this experiment students will be able to

1.Implement following point processing image enhancement operations.

a. Negation of an image
b. Thresholding of an image
c. Contrast Stretching of an image
d. Gray level Slicing
e. Bit Plane slicing.
2.Understand the effect of point processing operations on an Image.
3. Identify the real life application of point processing techniques implemented.

A.4 Theory:

a. Negation of an image
The negative of an image with gray levels in the range [ 0, L-1] is obtained by using the negative
transformation given by the expression
S= L – 1 – r …… Equation (1)

This is according to the transformation S = T ( r ) In above transformation ( 1 ) , the intensity of


the output image decreases as the intensity of the input increases. The type of processing is
particularly suited for enhancing white or gray detail embedded in dark regions of an image
especially when black areas are dominants in site.
Figure 1: The concept of image negation

b. Thresholding of an Image

Theory:
Thresholding is a simple process to separate the interested object from the background. It gives
the binary image. The formula for achieving thresholding is as follows

s = 0; if r <= t ……Equation (2)


s = L-1; if r > t

Figure 2: The concept of image thresholding


c. Contrast Stretching of an Image
Theory:
Low contrast images can result from poor illumination, lack of dynamic range in the imaging
sensor etc. The idea behind contrast stretching is to increase the dynamic range of the gray levels
in the image being processed. The transformation function for contrast stretching is given by
𝑎𝑥, 0 ≤ 𝑥 ≤ 𝑥1
𝑓(𝑥, 𝑦) = { 𝑏(𝑥 − 𝑥1) + 𝑦𝑥1 , 𝑥1 ≤ 𝑥 ≤ 𝑥2 } ….Equation (3)
𝑐(𝑥 − 𝑥2) + 𝑦𝑥1, 𝑥2 ≤ 𝑥 ≤ 𝐵

Where: f(x, y) is the Piecewise Linear Contrast Stretch in the image, a, b, and c are appropriate
constants, which are the slopes in the respective regions and B is the maximum intensity value.

Figure 3: The concept of Contrast stretching

The location of the points (r1 , s1) & (r2 , s2) control the shape of the transformation function.

d. Gray Level Slicing ( Intensity Level Slicing) :


Theory:
Highlighting a specific range of gray-levels in an image is often desired. Applications include
enhancing features such as masses of water, crop regions, or certain elevation area in satellite
imagery. Another application is enhancing flaws in x-ray. There are two main different
approaches:

highlight a range of intensities while diminishing all others to a constant low level.

highlight a range of intensities but preserve all others.

The fig. illustrates the intensity level slicing process. The left figures show a transformation
function that highlights a range [A,B] while diminishing all the others. The right figures
highlights a range [A,B] but preserves all the others.
Figure 4: The concept of Gray level slicing with and without background

The formulation for grey level slicing without background is

S = L-1 ; if A ≤ r ≤ B … Equation (4)

S = 0; Otherwise

The formulation for grey level slicing with background is

S = L-1 ; if A ≤ r ≤ B ….Equation (5)

S = r; Otherwise

e. Bit Plane Slicing:

Theory:
Bit plane slicing is new way of looking at an image. In bit plane slicing the image is considered
to be a stack of binary images. The images closes to the bottom are least significant and the
images on top are most significant. Instead of highlighting intensity ranges, highlighting the
contribution made to the total image appearance by specific bit might be desired. Imagine that
the image is composed of eight 1-bit planes, ranging from plane 0 for least significant bit to plane
7 for the most significant bit.
Figure 5. A model of the bit-planes

A.5 Procedure/Algorithm:
A.5.1 TASK 1:

Negation of an image

1. Read i/p image


2. Read maximum gray level pixel of i/p image
3. Replace input image by ( maximum – i/p ) = o/p
4. Display o/p image
5. Observe the output and complete PART B of lab manual.
6. Save and close the file and name it as EXP3_Task1_your Roll no.m
A.5.2 TASK 2:

Thresholding of an Image

1. Read input image


2. Enter thresholding value t
3. If image pixel is less than t replace it by zero.
4. If image pixel is > t replace it by 255
5. Display input image
6. Display threshold image
7. Display input image
8. Display threshold image
9. Observe the output and complete PART B of lab manual.
10. Save and close the file and name it as EXP3_Task2_your Roll no.m
A.5.3 TASK 3:

Contrast Stretching of an Image

1. Read input image


2. Enter values r1,r2,s1,s2
3. Calculate alpha,beta and gamma slopes.
4. if input pixel value is <= r1 then o/p = alpha x input
5. If input pixel is > r1and <=r2 then o/p = beta x (r-r1)+s1
6. otherwise o/p = gamma x (r-r2)+s2
7. Display i/p image
8. Display o/p image.
9. Observe the output and complete PART B of lab manual.
10. Save and close the file and name it as EXP3_Task3_your Roll no.m

A.5.4 TASK 4:

Gray Level Slicing ( Intensity Level Slicing)

1. Read input image


2. Enter values A, B.
3. Use the appropriate formula for without background and with background.
4. Find the output image for without background and with background.
5. Display i/p image
6. Display o/p images.
7. Observe the output and complete PART B of lab manual.
8. Save and close the file and name it as EXP3_Task4_your Roll no.m

A.5.5 TASK 5:

Bit Plane Slicing

1. Read input image.


2. For bit value from 1 to 8, find corresponding image planes.
3. Display i/p image
4. Display all 8 o/p image planes separately
5. Observe the output and complete PART B of lab manual.
6. Save and close the file and name it as EXP3_Task5_your Roll no.m

**********************
PART B
(PART B : TO BE COMPLETED BY STUDENTS)

(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded on the Blackboard or emailed to the concerned
lab in charge faculties at the end of the practical in case the there is no Black board access
available)

Roll No. Name:


Class : Batch :
Date of Experiment: Date of Submission
Grade :

B.1 Software Code written by student:


(Paste your Matlab code completed during the 2 hours of practical in the lab here)

TASk 1
clc;
clear all;
myImage=imread('C:\Users\mpstme.student\Documents\B019/img1.jpg');
Img=rgb2gray(myImage);
imshow(Img);
c=imresize(Img,[256,256],'nearest');
max=0;
for i=1:256
for j=1:256
if(max<c(i,j))
max=c(i,j)
end
end
end
disp(max);
for i=1:256
for j=1:256
c(i,j)=max-c(i,j);
end
end
imshow(c);

Task 2
clc;
clear all;
myImage=imread('C:\Users\mpstme.student\Documents\B019/img1.jpg');
Img=rgb2gray(myImage);
%imshow(Img);
og=imresize(Img,[256,256],'nearest');
c=imresize(Img,[256,256],'nearest');
d=imresize(Img,[256,256],'nearest');
e=imresize(Img,[256,256],'nearest');
t1=10;
t2=80;
t3=180;
%imshow(og);
for i=1:256
for j=1:256
if(c(i,j)<t1)
c(i,j)=0;
else
c(i,j)=255;
end
end
end
imshow(c);
for i=1:256
for j=1:256
if(d(i,j)<t2)
d(i,j)=0;
else
d(i,j)=255;
end
end
end
%imshow(d);
for i=1:256
for j=1:256
if(e(i,j)<t3)
e(i,j)=0;
else
e(i,j)=255;
end
end
end
%imshow(e);

TASK 3

B.2 Input and Output:


(Paste your program input and output in following format, If there is error then paste the specific
error in the output part. In case of error with due permission of the faculty extension can be given to
submit the error free code with output in due course of time. Students will be graded accordingly.)

Input Images: Your photographs

Output:
1)

2)
a-

b-
c-
3)

B.3 Observations and learning:


(Students are expected to comment on the output obtained with clear observations and learning for
each task/ sub part assigned)

B.4 Conclusion:
(Students must write the conclusion as per the attainment of individual outcome listed above and
learning/observation noted in section B.3)

B.5 Question of Curiosity


(To be answered by student based on the practical performed and learning/observations)

Solve following: a * f1 + (1- a) * f2 Where a = 0.5, f1 = your image and f2 = your neighbor
classmate’s image

************************

You might also like