Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Computer Vision Workshop

You're reading from  The Computer Vision Workshop

Product type Book
Published in Jul 2020
Publisher Packt
ISBN-13 9781800201774
Pages 568 pages
Edition 1st Edition
Languages
Authors (3):
Hafsa Asad Hafsa Asad
Profile icon Hafsa Asad
Vishwesh Ravi Shrimali Vishwesh Ravi Shrimali
Profile icon Vishwesh Ravi Shrimali
Nikhil Singh Nikhil Singh
Profile icon Nikhil Singh
View More author details
Toc

3. Working with Histograms

Activity 3.01: Enhancing Images Using Histogram Equalization and CLAHE

Solution:

  1. 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.
  2. Import the OpenCV library and the pyplot module from the Matplotlib library:
    import cv2
    import matplotlib.pyplot as plt
  3. Read the image as grayscale:
    img= cv2.imread('fingervein.bmp', 0)
  4. 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:

    Figure 3.59: Original finger vein image

    The values on the X and Y axes show the width and height of the displayed image.

  5. Plot the histogram:
    plt.hist(img...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}