introduce

As humans, we’re usually pretty good at spotting differences in images. For example, a common game — two images look different. Now let’s play the game. First let’s take a look at the image above and see if we can find anything different in it for 30 seconds. Answer: Isn’t it simple that the colors of fruit, ice cream and drinks change dramatically, as do the curtains and the sun? If you have additional answers, please give them in the comments! This kind of problem seems easy for humans, but it is not easy for computers. This is because computers can only eventually acquire such abilities by learning from the models we train them to use. There are many good models for classifying bulk images, such as open source tools such as TensorFlow and Keras. With the help of such open source tool libraries, computer vision research has developed rapidly. Now we can also use such toolkits to create very complex models and solve more complex problems, such as Kaggle: Animal-10, which contains dozens of images of different types of Animals as well as non-animal images. All you have to do is create a model to predict what type of animal the picture is.

MSE and SSIM

However, the above tasks are relatively simple, such as the common handwritten number recognition MNIST, etc., generally can also achieve high accuracy. Here, I want to make it a little harder by creating an image classifier that can tell how similar two images are. And it does not rely on any complex tool libraries, such as TensorFlow, Keras, etc. Traditional machine learning methods are adopted in this paper. Two methods are selected here to find whether an image is similar to another image. The two methods are mean square error (MSE) and structural similarity index (SSIM) respectively.



MSE




SSIM






1 ~ 1

implementation

Now use code to implement the above idea: load the necessary libraries:








Write the MSE formula








































Three different dogs



Three different cats






Original source code











The author information

Iftekher Mamun, Machine learning This article is translated by Ali Yunqi Community Organization. Image Classification using SSIM Simple Image Classifier with OpenCV For more details, please refer to the original text.