Open JonBoyleCoding opened 5 years ago
Both of your suggestions sound good to me.
I finally found some time to work on this. I have a working version of the second point, taking a GenericImageView as an argument instead of grayscale (works with current tests, need more for different types), however there is an issue with using the ArrayData::DataType that is returned from sum_image_pixels as the compiler can't seem to index into it when Pixel type is a generic.
I made a workaround for the moment; however, it changes the API of sum_image_pixels in integral_image to turn the ArrayData::DataType back into the pixel it is from: https://github.com/JonBoyleCoding/imageproc/tree/template_matching_update
I was wondering if you had any thoughts on how this might be best approached.
I thought I would link to the actual files.
https://github.com/JonBoyleCoding/imageproc/blob/template_matching_update/src/template_matching.rs https://github.com/JonBoyleCoding/imageproc/blob/template_matching_update/src/integral_image.rs
If you would rather I did this via pull request, I can do that as well.
When looking at the template matching to add cross-correlation (#311) I came up with a few things that might be an idea for refactoring; however, I thought it would be worth making a discussion before actually doing the work if it's not going to be wanted.
Each of the template matching in https://docs.opencv.org/3.4/de/da9/tutorial_template_matching.html has exactly the same normalization term.
MatchTemplateMethod
is going to have a lot of duplications and the various checks for methods are going to be increased two-fold whereas it could just become one function parameter.Currently the method can only accept single-channel grayscale images. The conversion to grayscale isn't always the same and isn't necessary for template matching in general. I've messed around with converting the function to accept any number of channels and data types and it should be possible, although will definitely complicate the code.