image-rs / imageproc

Image processing operations
MIT License
758 stars 149 forks source link

Expand `stetch_contrast()` to color images also using `u8` #670

Closed ripytide closed 3 months ago

ripytide commented 5 months ago

Ideally we'd want to use the Enlargeable trait currently private inside image to make this work for all types rather than just u8, but this is still an improvement that should be good enough for https://github.com/image-rs/image/issues/2238.

ripytide commented 5 months ago

It seems we need to bump the minimal rust version now since one of our dependencies, I think bitstream-io now requires v1.79

theotherphil commented 3 months ago

Thanks! What impact does this have on function run time for the greyscale case?

ripytide commented 3 months ago

Looks like no impact: Before PR:

test contrast::benches::bench_stretch_contrast                                        ... bench:         660.08 ns/iter (+/- 2.24)
test contrast::benches::bench_stretch_contrast_mut                                    ... bench:           0.25 ns/iter (+/- 0.00)

After PR:

test contrast::benches::bench_stretch_contrast                                        ... bench:         658.86 ns/iter (+/- 7.36)
test contrast::benches::bench_stretch_contrast_mut                                    ... bench:           0.25 ns/iter (+/- 0.00)
theotherphil commented 3 months ago

Thanks!

(Aside: it looks like the _mut variant of that benchmark is optimising out the function and so not actually running .)