Prerequisites: Python OpenCV
Suppose we have two data images and a test image. Let’s find out which data image is more similar to the test image using python and OpenCV library in Python.
Let’s first load the image and find out the histogram of images.
Importing image data
image = cv2.imread('test.jpg')
Converting to gray image
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
histogram = cv2.calcHist([gray_image], , None, , [0, 256])
data1.jpg is more similar to test.jpg as compare to data2.jpg
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course