Professional Documents
Culture Documents
1734 - Digital Recognition Based On Using Template
1734 - Digital Recognition Based On Using Template
MATCHING
SUBMITTED BY:
Alma Ferdaus Sabiha
ID: 1803510201734
Department: CSE
Section: B
➢ Objective
1. Simplicity:
Template Matching is conceptually simple and easy
…… to understand.
2. Efficiency:
It can be computationally efficient for simple object
… recognition tasks.
3. Localization:
Template Matching provides precise localization of
…. objects.
➢ Application
1. Object Detection:
Locate specific objects within images or video frames.
Example: Finding a logo on a product package.
2. Character Recognition:
Identify characters in scanned documents.
Example: Reading handwritten digits on checks.
3. Medical Imaging:
Detecting anomalies in medical images.
Example: Identifying tumors in MRI scans.
➢ Framework
Start
Digit Acquisition
Pre-Processing
Template Matching
Sorting
Text Creation
Image Conversion
End
Input:
2
Gray Scale Image:
Output:
Input:
7
Gray Scale Image:
Output:
➢ Conclusion
NCC(merits):
Robust to variations in lighting and contrast.
Can handle simple transformations like rotation and scaling.
NCC(demerits):
NCC is sensitive to noise in the images.
Noisy images can lead to incorrect matches due to noisy correlations.
➢ Appendix
!pip install opencv.python
!pip install scikit-image
!pip install numpy
import cv2
import numpy as np
import matplotlib.pyplot as plt
from google.colab.patches import cv2_imshow
# Read the main image
img_rgb = cv2.imread('/content/6.jpeg')
# Convert it to grayscale
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
cv2_imshow(img_gray)
template_rgb = cv2.imread('/content/Template.jpeg')
# Convert it to grayscale
template_gray = cv2.cvtColor(template_rgb, cv2.COLOR_BGR2GRAY)
cv2_imshow(template_gray)
template= cv2.imread('/content/Template.jpeg', 2)
ret, bw_template = cv2.threshold(template, 170,255,cv2.THRESH_BINARY)
# converting to its binary form
template= cv2.threshold(template,170, 255,cv2.THRESH_BINARY)
cv2_imshow(bw_template)
cv2.waitKey(0)
cv2.destroyAllWindows()
import cv2
from google.colab.patches import cv2_imshow
def template_matching(image_path,template_path):
# Load the template and the image
image= cv2.imread('/content/6.jpeg', 0)
template= cv2.imread('/content/Template.jpeg', 0)
# Get the width and height of the template
w, h = image.shape[::-1]
# Perform template matching
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)