# How do you find the histogram of an image in Python?

How to Show Histogram of Image using OpenCV Python | OpenCV Tutorialby Indian AI Production / On April 18, 2021 / In OpenCV ProjectInPython OpenCV Tutorial, Explained How to show t

## How to Show Histogram of Image using OpenCV Python | OpenCV Tutorialby Indian AI Production / On April 18, 2021 / In OpenCV Project

InPython OpenCV Tutorial, Explained How to show the Histogram of Image to analyse the image color format using OpenCV Python

Get the answers of below questions:

1. How do you find the histogram of an image?
2. How do you find the histogram of an image in Python?
3. Green channel extraction in image processing python
4. What is histogram in OpenCV?
5. How do you plot a histogram of a picture?
6. How do you calculate a histogram?
7. What are the properties of histogram?

## What is histogram ?

You can consider histogram as a graph or plot, which gives you an overall idea about the intensity distribution of an image. It is a plot with pixel values (ranging from 0 to 255, not always) in X-axis and corresponding number of pixels in the image on Y-axis.

Syntax: cv2.calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate]]) -> hist1. Histogram Calculation in OpenCV So now we use cv.calcHist() function to find the histogram. Let's familiarize with the function and its parameters : cv.calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate]]) images : it is the source image of type uint8 or float32. it should be given in square brackets, ie, "[img]". channels : it is also given in square brackets. It is the index of channel for which we calculate histogram. For example, if input is grayscale image, its value is [0]. For color image, you can pass [0], [1] or [2] to calculate histogram of blue, green or red channel respectively. mask : mask image. To find histogram of full image, it is given as "None". But if you want to find histogram of particular region of image, you have to create a mask image for that and give it as mask. (I will show an example later.) histSize : this represents our BIN count. Need to be given in square brackets. For full scale, we pass [256]. ranges : this is our RANGE. Normally, it is [0,256]. So let's start with a sample image. Simply load an image in grayscale mode and find its full histogram. REF: https://docs.opencv.org/master/d1/db7/tutorial_py_histogram_begins.html