How to counts matched object from main image with the template sub-Image
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Jakob
am 3 Aug. 2017
Bearbeitet: Jakob
am 3 Aug. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!