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 from my original image for diamond 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.
Have a look at method A) in Detect repetitive pixel patterns in an image and remove them using matlab (Disclaimer: I'm the author). Delete the rect
line and replace the variable template
with your (BW) template. Skip the last 3 commands and instead just count how many peaks there are:
idx = bwmorph(idx,'shrink',inf);
numberOfObjects = sum(idx)
You obviously will have to adjust some values greatly to get a good result - pattern detection isn't trivial.