image-rs / imageproc

Image processing operations
MIT License
736 stars 144 forks source link

Match template with alpha #584

Closed daladim closed 3 months ago

daladim commented 4 months ago

Very quick-and-dirty proposal for match_template_with_alpha, a variant of match_template_with_mask that accepts a GrayImage (i.e. a template "blended" with its mask) rather than a separate mask.

That's useful because it is a turnkey function that one can call after image::opening a PNG template file. However, this requires copying the template, then calling slide_window_at on separate buffers. I'm not sure how much more efficient it would be to re-implement a slide_window_at specifically for this case... Do you think that would be overkill?

Depends on https://github.com/image-rs/imageproc/pull/568 being merged first

daladim commented 4 months ago

Discussed in https://github.com/image-rs/imageproc/pull/570

theotherphil commented 3 months ago

I don't think it's worth bundling up channel extraction and template matching into a single function in this module.

There are some trivial helpers functions in the map module for extracting channels - I'd welcome a PR that added functions there to pull out the relevant channels from GrayAlphaImages. Along the lines of https://github.com/image-rs/imageproc/blob/master/src/map.rs#L553