How to counts matched object from main image with the template sub-Image

2 ビュー (過去 30 日間)
Ndoum ekanga Steve willy
Ndoum ekanga Steve willy 2017 年 7 月 13 日
編集済み: Jakob 2017 年 8 月 3 日
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.

回答 (1 件)

Jakob
Jakob 2017 年 8 月 3 日
編集済み: Jakob 2017 年 8 月 3 日
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.

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by