What would be an efficient image type to apply a series of JuliaImages filters?

In JuliaImages we deliberately use N0f8 from FixedPointNumbers to replace UInt8 because otherwise, it’s often very confusing what is white in image processing (1 or 255?).

Converting Array{UInt8, 2} to Array{N0f8, 2} can be done efficiently via reinterpret(N0f8, img_uint8). And the reverse if rawview(img_n0f8)


Many operations like bitwise_and are actually a pointwise operations, and thus it’s better to write the scalar version, e.g.,:

bitwise_and(x::T, y::T) where T<:Number = 0xff * (x & y)

and use broadcasting

C = bitwise_and.(A, B)
# or in-place version
C .= bitwise_and.(A, B)

Didn’t check if the code runs, but I think you can get the idea here.

2 Likes