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
- Python | Measure similarity between two sentences using cosine similarity
- Arithmetic Operations on Images using OpenCV | Set-2 (Bitwise Operations on Binary Images)
- NLP | WuPalmer - WordNet Similarity
- Measuring the Document Similarity in Python
- Python | Similarity metrics of strings
- Python | Word Similarity using spaCy
- Python - Alternate elements Similarity
- Python | Percentage similarity of lists
- NLP | Leacock Chordorow (LCH) and Path similarity for Synset
- Python | Test list element similarity
- ML | V-Measure for Evaluating Clustering Performance
- Python - Measure time taken by program to execute
- Statistical Functions in Python | Set 2 ( Measure of Spread)
- Statistical Functions in Python | Set 1 (Averages and Measure of Central Location)
- pgmagick - Add text in images
- Working with Images in Python
- Reading images in Python
- Loading Images in Tkinter using PIL
- Apply changes to all the images in given folder - Using Python PIL
- Reading Images With Python - Tkinter
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.