3. Working with Histograms
Activity 3.01: Enhancing Images Using Histogram Equalization and CLAHE
Solution:
- Open a new file in a Jupyter notebook in the folder you want to work on. Remember that your relevant finger veins image file must also be in the same folder so that when reading the image, you won't need to give a path along with the filename.
- Import the OpenCV library and the
pyplot
module from the Matplotlib library:import cv2 import matplotlib.pyplot as plt
- Read the image as grayscale:
img= cv2.imread('fingervein.bmp', 0)
- Display the image. Let's use Matplotlib to display the images in this example. You can also use OpenCV's
cv2.imshow()
if you want:imgplot = plt.imshow(img , cmap="gray") plt.title('Original image') plt.show()
The plot looks as follows:
The values on the X and Y axes show the width and height of the displayed image.
- Plot the histogram:
plt.hist(img...