In order to visualize histograms, we have made use of the plt.plot() function. If we want to visualize a histogram by using only OpenCV capabilities, there is no OpenCV function to draw histograms. In this case, we have to make use of OpenCV primitives (for example, cv2.polylines() and cv2.rectangle(), among others) to create some (basic) functionality for plotting histograms. In the histogram_custom_visualization.py script, we have created the plot_hist() function, which performs this functionality. This function creates a BGR color image, plotting the histogram in it. The code for this function is as follows:
def plot_hist(hist_items, color):
"""Plots the histogram of a image"""
# For visualization purposes we add some offset:
offset_down = 10
offset_up = 10
# This will be used for creating the...