Using Open-CV and Structural Similarity to Detect Tampered Cards

Using Open-CV and Structural Similarity to Detect Tampered Cards

Table of contents

No heading

No headings in the article.

I am delighted to have conquered the spirit of procrastination and self-doubt to write my first article on a machine learning project. Image tampering is a major concern as it can potentially lead to a series of crimes, starting with identity theft. To counter this problem, many organisations are leveraging machine learning and trained models to detect tampered card images. In this post, we delve into a machine learning project that utilises structural similarity and OpenCV to identify tampered cards. We will begin by providing an introduction of the technologies employed and the steps involved in the project.

OpenCV (Open Source Computer Vision) is a popular machine learning library that provides a wide range of algorithms for object detection, image processing, feature extraction and many more. This project takes advantage of the feature extraction and matching function in OpenCV, which entails algorithms like SURF and SIFT.

Structural similarity (SSIM) measures the likeness between two images by considering the contrast, luminance and structure of the images. In the context of image tampering detection, structural similarity values of the original and tampered images are compared.

In this project, the initial step involved acquiring the data, which in this case, was a sample of the original and tampered images. OpenCV aided in converting the two images into grayscale. It is worth noting that the identification of coloured images is more challenging because they have three colour channels, whereas grayscale images have only one. SSIM utilises x and y coordinates to identify the discrepancies between the images, and a lower similarity score is indicative of less similarity.

Next, the threshold function from OpenCV was utilised to apply adaptive thresholding to the stored image, resulting in an array. This process facilitated the extraction of salient features of the original image, to identify the areas that exhibit differences when compared to the tampered image.

The application of SSIM facilitated the detection of similarities and differences between the two provided images. In the project, a similarity score of 31% was obtained for the tampered image, confirming the presence of tampering. The project's scope encompasses implementing this approach in organisations to bolster security systems by automatically identifying tampered cards.

In a production setting, Support Vector Machine (SVM) model can be trained on a dataset of original and tampered cards. The model’s performance should be evaluated to ensure an image classification accuracy of at least 95% before deployment. Additionally, a Flask application was developed to demonstrate the performance of the model in production.

This project effectively showcased the application OpenCV and structural similarity (SSIM) in detecting tampered cards. A Flask application was developed to demonstrate the performance of the model in production mode. You can find all the code and notebook related to this project in the following Github repository https://github.com/Kamire-J/card_tempering_detection