Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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 $19.99/month. Cancel anytime
Banner background image