Tax Payers Fake ID Card Detection | A Machine Learning Project Part 2
Check out Part 1, before reading this.
7. Find the Similarity Index of the Image
The function (structural_similarity) helps to compare the two images which are the arguments (original_gray and fake_gray)
score, diff: They represent variables score is the percentage of how similar the fake image is to the original image
diff — is the difference between them
full=True: This means you want to access the full image.
(diff * 255).astype(“uint8”) — diff * 255 is to normalize the difference.
.astype(“unit8) — This helps to convert the value of the difference data type to an unassigned integer with the decimal value from 0–255 (which is 8 bit)
8. Find the threshold of the image
Threshold helps to separate the object we are interested in from the one we are not.
cv2.threshold() — It helps to get the threshold function of the computer vision which applies to the threshold of the image, and is stored in form of an array.
cv2.THRESH_BINARY_INV: Converts the difference value to binary
cv2.THRESH_OTSU: It automatically gives a value for the threshold.
It’s one of the forms of thresholding
cv2.findContours(): This method helps to find contours or objects in images
thresh.copy(): This is the processed image,i.e the code before the second line.
cv2.RETR_EXTERNAL: It is used to grab or retrieve external contours of objects.
imutils.grab_contours: It helps to grab contours or objects and appropriate the necessary values.
All these functions are complex mathematical functions written as codes.
9. Finding contour and grabbing those contours using imutils
a. Draw rectangles in any difference identified as contours
cv2.boundingRect(c): It loops through the values in the contour(which are like lists) that’s every object or alteration in the image. It then creates a rectangle to any differences it sees between the two images
b. Identify the contour in both the original and fake image
It’s obvious here, that contours didn’t help to visualize the images properly when you run the code.
10. Find the threshold using the difference function.
The threshold gave the best and highest difference between both images and should be advised to be used unlike the contour
Summary
Our SSIM (Structural Similarity Index Mark) is ~31.2%. It made it evident that the user ID is fake.
This project has helped us find similarities and differences between Taxpayers ID Cards to detect fake and fraud.
We found out thresholds and contours based on the threshold for the images converted into grayscale with the help of the open-cv package.
This helped in analysis and recognition.
We were also able to visualize the differences between the two images asides from the SSIM.
This project can be used in different organizations such as schools, event centres, finance institutions, entry and exit situations, electoral ID PVC and so many others.
I hope the project was explanatory, come here for more projects.
Till we see, bye 🎉🎉