JuliaImages / DitherPunk.jl

Dithering algorithms in Julia.
MIT License
68 stars 3 forks source link

Separate inner loop of error diffusion #49

Closed adrhill closed 2 years ago

adrhill commented 2 years ago

As mentioned here by @johnnychen94:

I noticed this only recently; for the innermost for loop, a performance practice is to separate the loops into two parts: 1) border and 2) inner area. The benefits are 1) we can remove unnecessary bounds check for the inner area, and thus 2) we can enable @simd for such simple operations.

See https://github.com/JuliaImages/Images.jl/blob/9796acc8bf1d56d9574c555656fdba362f84a988/src/algorithms.jl#L505-L537 and JuliaImages/ImageBase.jl#22 (comment)