Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Computer Vision Workshop

You're reading from   The Computer Vision Workshop Develop the skills you need to use computer vision algorithms in your own artificial intelligence projects

Arrow left icon
Product type Paperback
Published in Jul 2020
Publisher Packt
ISBN-13 9781800201774
Length 568 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Nikhil Singh Nikhil Singh
Author Profile Icon Nikhil Singh
Nikhil Singh
Hafsa Asad Hafsa Asad
Author Profile Icon Hafsa Asad
Hafsa Asad
Vishwesh Ravi Shrimali Vishwesh Ravi Shrimali
Author Profile Icon Vishwesh Ravi Shrimali
Vishwesh Ravi Shrimali
Arrow right icon
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 €18.99/month. Cancel anytime