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

Histograms with OpenCV

OpenCV also gives you a command to generate histograms. To plot, you will need Matplotlib as well. The core strength of this method is that it allows you to find the histogram of your selected region of interest (ROI) in an image. This ROI is communicated to the command with the use of an appropriate mask. This mask is a binary image. It has white pixels on the ROI and black pixels elsewhere.

The command used to compute the histogram of a particular channel of an image is as follows:

cv2.calcHist([images], [channels], mask, [histSize], \
             [ranges])

Note

The inputs with square brackets must always be given as lists.

Let's take a look at the different parameters:

  • [images]: This is the list containing your input image(s). It may be 2D or 3D.
  • [channels]: This is the index of the plane of the image whose histogram you want to compute. For a grayscale or binary...
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