LAB#4
LAB#4
Objective:
The objective of this lab is to implement thresholding on images to convert them to binary,
perform different transformation operations on images, find out the histogram of an image and
perform histogram equalization.
Theory:
Thresholding is the operation through which an image can be converted into a binary image/black
& white i.e. having only two distinct levels. For thresholding, a threshold value is calculated for
the entire image and then using this calculated threshold, the image can be converted to binary.
This threshold value can be the mean or median etc. of the image. Similarly, a negative image can
also be generated using the binary image and applying the transformation s = (L – 1) – r where L
is the total number of gray levels while s is newly computed value and r is the current value of a
pixel.
Transformation operations help enhance the quality of the image by applying operations like log,
inverse log and power on the entire image. Different type of transformation yields different
results.
Histogram of an image shows the frequency of different intensities values present in the image.
This gives a clear idea of what intensities dominate the image. Histogram equalization is a
technique that uses this information to enhance the contrast.
Lab Tasks:
Lab Task 1:
Read an image and convert it into black & white (binary image). Calculate threshold value by
taking mean of whole image. Also, convert the same image into a negative image using the
transformation: s = (L-1) – r where L are the total grayscale levels of the image.
Lab Task 2:
Apply Power Law transformation for the following values of γ (0.9, 0.6, 1.3, and 1.8) for the
images given below and display the results. Also, apply log transformation (log10) on the images:
Lab Task 3:
Perform the following steps to do Hist. equalization to enhance the grayscale image.
• Calculate the histogram of the image and display it using the appropriate command.
(Don’t use the built in function of OpenCV or Numpy etc.)
• Calculate probability density function (PDF) from the histogram and display it using the
appropriate command PDF = H/(R*C). Where H is the Histogram and R and C is the number of
Rows and Columns of the image respectively.
• From the transformation function, replace the gray levels of the image to create contrast enhanced
(histogram equalized) image.
Conclusion:
This lab gives an understanding of different transformation operations and how they affect an
image. In addition, the lab also talks about thresholding and histogram equivalzation to improve
the image quality