Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

Experiment 6B 10-244

Title: To implement Thresholding.

Estimated time to complete this experiment: 2 hours

Objective: In this experiment, student should be able to understand the formula to perform thresholding of
a black and white image.

PEO to be achieved:

Expected Outcome of Experiment:


Obtaining a black and white image based on threshold specified by user.

Books/ Journals/ Websites referred:


 http://www.mathworks.in/help/matlab/

Pre Lab/ Prior Concepts: Basic MATLAB knowledge of the standard formula to obtain Digital
Negative
______________________________________________________________________________________

Historical Profile:
Sezgin and Sankur (2004) categorize thresholding methods into the following six groups based on the
information the algorithm manipulates

New Concepts to be learned: How to set the pixel values to their minimum or maximum grey level.

Software & Hardware Required: MATLAB software


Experiment 6B 10-244
Flow Chart:

Start

Read the image in an object


Take the size of image in r

Set the pixels to max or min value based


on the user specified threshold

Plot the image

Stop

Stepwise Procedure:
1. Open Matlab software
2. Goto New  Script
3. Write the program code given below.
4. Save the code with an “.m” extension.
5. Run the code to get the output.

Program Code:

r=imread('cameraman.tif');
[x y]=size(r);

r1=input('Enter r1 : ');

for i=1:x
for j=1:y
if(r1<=r(i,j) && r(i,j)<=255)
rcs(i,j)=255;
else
rcs(i,j)=0;
end
end
Experiment 6B 10-244
end

subplot(1,2,1);
imshow(r);

subplot(1,2,2);
imshow(rcs);

Output:

Enter r1 : 100

Conclusion: Therefore we obtained a black and white image of the original image.

Real Life Application:


A clear stand out between the darker and brighter parts of the image.

_________________________________________________________________________
_______

Viva Questions:

1. Define Thresholding
 Contrast is the difference in luminance and/or color that makes an object (or its
representation in an image or display) distinguishable. In visual perception of the real world,
contrast is determined by the difference in the color and brightness of the object and other
objects within the same field of view.

2. What is highest grey level in an 3 bit image


 23 – 1 = 7
Experiment 6B 10-244
3. What is the transformation formula for thresholding?
s = l-1 r1 <= r <=l-1
s=0 otherwise

_________________________________________________________________________
_______

You might also like