How to counts matched object from main image with the template sub-Image
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a task where I should count numbers of suits(diamonds, clubs, ...) in a set of playing cards image. I have created a template sub-image for diamond from my original image for example, using imcrop in Matlab. I have also converted both Original or target Image in grayscale. I'm trying to find the match of the sub-image in the target image and counts the corresponding diamonds in the target image.
Does anyone have a suggestion?
I try to use normxcorr2 I got a plot where I can see the area with highest peak, but I don't have any ideas how to compute this.
Any suggestions of algorithms.
Thank you.
0 commentaires
Réponses (1)
Jakob
le 3 Août 2017
Modifié(e) : Jakob
le 3 Août 2017
Using normxcorr2 will give you the point of highest correlation between image and template.
% Perform registration
reg = normxcorr2(t,sI);
% find peaks and location and offset
[dy,dx] = find(reg== max(reg(:)));
Where t is the template and sI is the search image. You can then find the offset with:
yoffSet = dy-size(t,1);
xoffSet = dx-size(t,2);
P(yoffSet+1,yoffSet+1) is the point in the sI where the template starts.
0 commentaires
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!