image-rs / imageproc

Image processing operations
MIT License
759 stars 150 forks source link

Refactoring Template Matching Discussion #312

Open JonBoyleCoding opened 5 years ago

JonBoyleCoding commented 5 years ago

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.

theotherphil commented 5 years ago

Both of your suggestions sound good to me.

JonBoyleCoding commented 4 years ago

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.

JonBoyleCoding commented 4 years ago

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.