Why does using normxcorr2 slow down my code seriously?
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Adam Danz
2020-4-8
编辑:Adam Danz
2020-4-8
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!