Why does using normxcorr2 slow down my code seriously?

4 views (last 30 days)
I am working on template matching in fingeprints and after extracting minutiae points, I extract a template using a window size of 29 by 29 around a minutiae point for each minutiae, then i want to get the most unique of the template points in respect to the fingperint image. I am supposed to use cross correlation to match the each extracted template round the fingeprint image to find out the one that correlates the least as when compared to its correlation on its original location and from what i've read normxcorr2 seems to be the best for that, but when i implemented it, it takes so long to finish, if i actually let it finish it could take more than an hour because it takes over a minute for just one minutiae point and there are about 200 I have extracted. The approach i used is to extract a template of the same size around each pixel in the fingerprint image and cross correlate it with the minutiae template.
Please what can I do to solve this issue now? because it runs too slowly.
I can post the code if needed. Please help.
  11 Comments
Adam Danz
Adam Danz on 7 Apr 2020
Neither mat file contains the winsize variable.

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 8 Apr 2020
Edited: Adam Danz on 8 Apr 2020
The normxcorr2 function is the bottleneck of processing speed in your code consuming 49% of the total processing time however, you can make some improvements to make the process more efficient.
Using variable names from this line of code,
corrmat = normxcorr2(primtemplate, querytemplate);
it's often the case that querytemplate is a matrix of 0s and there's no purpose in sending a matrix of 0s through normxcorr2. You can reduce the number of calls to normxcorr2 by adding this condition after computing quertytemplate. It will skip to the next col loop before executing normxcorr2.
if all(querytemplate==0, 'all')
continue
end
I haven't deconstructed your code but at a glance, it looks like you may be repeating computations when a new primtemplate is chosen. Once two windows have been correlated, there's no reason to execute that computation again.
Lastly, the normxcorr2 function supports GPU arrays which can greatly speed up processing.
  7 Comments
Fego Etese
Fego Etese on 9 Apr 2020
I will go with the surf algorithm. Thanks for your help. I really appreciate it.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!