image-rs / imageproc

Image processing operations
MIT License
735 stars 145 forks source link

Remove unnecessary allocations #569

Closed cospectrum closed 4 months ago

cospectrum commented 4 months ago

The only public change: convex_hull.

theotherphil commented 4 months ago

Thanks for the PR. Does replacing a nested loop with Image::from_fn have any impact on the image filtering benchmarks?

cospectrum commented 4 months ago

Image::from_fn iterates in the same order (row-major, cache friendly), so it should be the same. Plus, you don't have to think about the row-major vs col-major every time.

cospectrum commented 4 months ago

Image::from_fn iterates in the same order (row-major, cache friendly), so it should be the same. Plus, you don't have to think about the row-major vs col-major every time.

Hmm, not really. A small regression. It seems that the compiler cannot optimize the mutable lambda

cospectrum commented 4 months ago

Or the iterators are to blame.

cospectrum commented 4 months ago

A couple of minutes. I'll refactor incrementally

cospectrum commented 4 months ago

@theotherphil, Now I think my bilateral_filter bench is better than the master (both allocs and speed).

theotherphil commented 4 months ago

Great, thanks!