Introduction
Object detection is one of the branches of computer vision which has a wide range of applications in industry such as face detection, surveillance, and defect detection in products under manufacturing to name a few.
The goal of object detection is to locate instances of semantic objects of a certain class (such as people, structures, or cars) in digital photos and videos. Object detection is a branch of computer vision and image processing. Face detection, pedestrian detection, picture retrieval, and other well-studied object detection fields are examples.
Finding a target image's sub image that matches a template image is the goal of the computer vision approach known as "template matching." This method is frequently utilized in object-detecting domains like manufacturing, robotics, medical imaging, surveillance, and vehicle tracking. In general, there are two types of template matching approaches: the first is based on the level histogram method, and the second is based on the feature extraction method. The former group is the topic of this discussion since it is easier to utilize the relevant level histogram methods, they have already undergone quantitative analysis to determine their accuracy and error estimates, and the preceding literature contains the study findings.
In this article, we will deep dive into the template Matching method for object detection and will learn the template matching functions that are used to match the target function to the template image.
Table of contents:
- Template matching method: Explained
- Template matching function
- Template matching with edge orientation
- Applications of Template matching in computer vision
- Conclusion
- Template matching method: Explained
Computer vision research is now focused on object detection. The two broad categories of currently used object detection techniques are the learning-based approach and the template-based approach. Object detection is frequently stated as a problem of binary classification in the learning-based approach, where object signatures (i.e., the features used to describe the objects) are produced through training using positive/negative examples. Finding the best matching template from an input image becomes the task of object detection in the template-based approach since objects are explicitly described by templates.
When the objects must be taken into account, the templates might be visualized as intensity/color images. Because the look of an object is typically dependent on the lighting situation and surface characteristics of the object, appearance templates are frequently particular and devoid of generalization. Given a set of binary templates representing the object, the task of determining whether an image contains the object ultimately becomes the matching score between each template and the image. As a result, binary templates representing the contours of the objects are frequently used in object detection because the shape information can be well captured by the templates.
Now, as we learned the explanation of Template matching for Object detection. Let’s look at the Template matching function that is used to perform this task.
- Template matching function
In this task of matching the template with the target image, the matching measure function is expressed as the difference between the RGB level histograms corresponding to the target item and the template object. The triplet RGB level values of each independent channel are plotted against the number of pixels for each tonal value to create the histograms for both the target and template images.
Let HI(i)(x) be the histogram of the target object, HI(i)(x) the histogram of the template object, where i=0 to 255 stands for the level values of each channel of the triplet RGB, and x = {R, G, B}.
Thus,
- Template matching with edge orientation
Let p(sp,op) and q(sq,oq) be two points on an image where sp=(xp,yp) and
sq=(xq,yq) are the spatial coordinates of p and q respectively; op and oq are
the edge orientations at p and q.Let ds(p, q) denote a spatial distance between
P and q, e.g. Euclidean distance; and do(p, q) be a measurement to measure the
difference in orientation between p and q.LetTand Ibe a binary template
and a test image respectively, D(T, I) denote the matching score or distance
(dissimilarity) between T and I.
Olson’s and Jain’s Methods
In, Olson et al. defined the matching score D(T, I) in the form of the Haus-dorff distance as-
D(T,I)=maxt∈Tmax{ds(t, t∗),do(t, t∗)} (1)
where t∗is the closest pixel of tin the image I with respect to the spatial and orientation distances, i.e. t∗=argminq∈Imax{ds(t, q), do(t, q)}. The orientation component do(·)is encoded as,
do(p, q)=|op−oq| (2)
- Applications of Template matching in computer vision
We saw a brief explanation of the template matching method for object detection tasks. Now let’s look at some of its applications
- Image annotation
- Vehicle counting
- Activity recognition
- Face detection and recognition
- Video co-segmentation
- Robotics
- Medical imagining
- Conclusion
In this article, we saw a detailed explanation of the template matching method for object detection in the computer vision field. We learned how the template matching function is used to detect objects in the target image along with applications of the template matching method for object detection in real-world scenarios
References: