<jupyter_start><jupyter_text>Histogram (statistics) A graphical display of numerical data in the form of upright bars, with the area of each bar representing frequency.---  Histogram of a Grayscale ImageNumber of pixels corresponding to a given intensitty. `hist	=	cv.calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate]])`* images:	Source arrays. They all should have the same depth, CV_8U, CV_16U or CV_32F , and the same size. Each of them can have an arbitrary number of channels.* channels:List of the dims channels used to compute the histogram. The first array channels are numerated from 0 to images[0].channels()-1 , the second array channels are counted from images[0].channels() to images[0].channels() + images[1].channels()-1, and so on.* mask:	Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size as images[i] . The non-zero mask elements mark the array elements counted in the histogram.* histSize:	Array of histogram sizes in each dimension.* ranges:	Array of the dims arrays of the histogram bin boundaries in each dimension.* hist	Output histogram, which is a dense or sparse dims -dimensional array.* dims	Histogram dimensionality that must be positive and not greater than CV_MAX_DIMS (equal to 32 in the current OpenCV version).<jupyter_code>%matplotlib inline
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

img = cv.imread('Lenna.png' ,cv.IMREAD_GRAYSCALE)
print("Total Pixels = ", img.shape[0]*img.shape[1])

hist = cv.calcHist([img], [0], None, [256], [0,256])
plt.plot(hist)
plt.xlim([0,256])
plt.show()

img +=70
hist = cv.calcHist([img], [0], None, [256], [0,256])
plt.plot(hist)
plt.xlim([0,256])
plt.show()<jupyter_output>Total Pixels =  262144<jupyter_text>Histogram of a color Image<jupyter_code>%matplotlib inline
import cv2 as cv
import matplotlib.pyplot as plt

img = cv.imread('Lenna.png', cv.IMREAD_COLOR)
channels = ['b', 'g', 'r'] # since cv reads img as BGR channel order
for i, col in enumerate(channels):
    histogram = cv.calcHist([img], [i], None, [256], [0,256])
    plt.plot(histogram, color = col)
    plt.xlim([0, 255])
plt.show()<jupyter_output><empty_output><jupyter_text>Histogram EqualizationMaking an uneven histogram, more or less flat, in order to make the image more vibrant. So its not too dark or too light.Compute the histogram of a set of data using numpy's histogram `numpy.histogram(a, bins=10, range=None, normed=None, weights=None, density=None)[source]`Return a contiguous flattened array `numpy.ravel(a, order='C')[source]`<jupyter_code>%matplotlib inline
import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10661218424962852, 'fraction_numerical': 0.024145616641901933, 'mean_word_length': 5.351415094339623, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '460205', 'license': 'MIT', 'n_tokens_mistral': 892, 'n_tokens_neox': 836, 'n_words': 336, 'path': 'PracticeCV/Histograms.ipynb', 'repo_name': 'Ganeshgng/CV-Processing', 'size': '2692'}