-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template matching with an alpha channel #570
Conversation
294673d
to
02dd7c8
Compare
02dd7c8
to
2c15a74
Compare
This and #568 are both adding masked template matching. cc @daladim and @cospectrum |
My PR is compatible with OpenCV, which is a priority for me personally. |
@cospectrum by “compatible with” do you mean being able to produce equal results, or something else? |
Equal results, according to their formulas. #567 (comment) |
I did not see the open issue before implementing. Nice that the formulae for normalisations are posted there (and I realize that I also forgot to square the masked value for the correlation version). |
@cospectrum 's version is arguably better than mine :) (does not support images-with-alpha-channel, but has a correct computation, especially with regards to the normalization) I may try to create a separate MR to add tests for the |
I may as well add a helper function that extracts the template from an image with an alpha channel, to be more convenient when loading a PNG file |
Before @cospectrum merges his, I've added tests for the parallelized version at cospectrum#1 |
This MR could be closed now I've created |
This MR is adding the
match_template_with_alpha
(and itsmatch_template_parallel_with_alpha
counterpart).This make this crate support "masked" templates (or "non rectangular" templates or templates "with an alpha channel", name it as you'd like :D )
A few notes:
_inner
function).sum_squares
) in the case of an image with alpha. I'd be happy to have a review on this part (it's late and my brain is unable to get the meaning of the math behind this normalization, especially as the normalization term depending on the location of the image)Neat side effects:
match_template
andmatch_template_parallel
_parallel
functions are tested in CIgray_alpha_image!
macro