SVM – Using machine learning for image analysis | KISS digital

A project manager with a penchant for solving all of his problems using mathematical equations.

SVM – Using machine learning for image analysis

Machine learning is a field of artificial intelligence, which is increasingly often used in mobile app development. By taking advantage of advanced algorithms, it’s now possible to build innovative products, such as image analysis apps. How exactly?

Using machine learning for image analysis

Image analysis revolves around recognizing and classifying objects within images. Although it can be easily performed by humans, analyzing images by machines is a completely different story. Machines perceive images as sets of pixels, which makes it difficult to identify specific items within them. Thanks to dedicated software, though, they can turn into powerful image analysis tools.

This time, we will look into using machine learning to analyze images. Let’s start with a question we asked our team members: When analyzing an image, how to tell the difference between an apple and a banana? Those who had some experience with image analysis immediately started talking about artificial neural networks. The rest of the team members pointed out parameterization (separating certain traits of the objects). We decided to follow this lead and use SVM to identify and split those traits.

Those who had some experience with image analysis immediately started talking about artificial neural networks. The rest of the team members pointed out parameterization (separating certain traits of the objects). We decided to follow this lead and use SVM to identify and split those traits.

What is a Support Vector Machine and how it can be used in image analysis?

SVM (Support Vector Machine) is a learning model used for classification. Training such a model begins with providing distinctive features of the objects to find the optimal hyperplane, which will correctly classify the data. In our case, the model should distinguish between an apple and “no apple”. It’s important to find the maximum margin of separation to make it easier to tell the difference between the objects.

An example of the maximum margin:

An example of complex objects, which are more difficult to separate:

But what else, apart from apples and bananas, can we classify? Pretty much anything. Let’s analyze the real case we dealt with at KISS digital - iChallenge tennis app. Once it’s mounted on a tripod and properly configured, it serves as a virtual umpire and rules whether the ball was in or out.

An example of recognizing and classifying objects by a Support Vector Machine

Although iChallenge is a complex application uses more than an SVM to analyze images, this example helps to understand challenges that such a model has to face. In this case, it is important to identify a tennis ball on every video frame, in order to track and draw up its trajectory.

In a preliminary image analysis, all objects that resemble a tennis ball are marked. It can be actual tennis balls, but also yellow caps or other parts of clothing. If the model is well-trained, though, it should take into account an adequate shape (round), color (a mix of yellow and green) and its distribution (since the color is not uniform). If all criteria are met, a ball will be properly identified. It means that it will be included in the set of green points from the first graph, whereas all remaining objects should fall into the set of red points.

Those sets are created before the actual classification. It happens often that this task is first assigned to a QA Tester, who analyzes different images and marks the elements accordingly (“tennis ball” or “no ball”). The set of data has to be vast and diversified to include as many possible scenarios as possible.

Using such a training method allows the model to identify specific objects on various images in real time, and iChallenge is a great example of that. An SVM model can actually be trained to recognize and classify any type of objects, depending on our needs. Although building it from scratch is unprofitable, there are many tools and libraries available to develop image analysis apps. Would you like to create one too? Let’s make it happen.

Piotr

A project manager with a penchant for solving all of his problems using mathematical equations. His analytical mind constantly makes him draw formulas and charts on a whiteboard.