imresize does interpolation (https://github.com/JuliaImages/ImageTransformations.jl/blob/a83895e0b1386aee833c8337d2b8029842c61b1b/src/resizing.jl#L316)
so, it naturally outputs floating point numbers.
Maybe the best option is to use normed fixed-point numbers (instead of floating-point numbers).
For example the type N0f8
is a 8-bit number which represents numbers between 0 and 1. [1]
The equivalent code is
using ImageTransformations, Colors, ImageCore
N = 10
img = rand( RGB{N0f8}, N, N)
img = imresize(img, ratio=(0.7,0.7))
or, if you want to keep the channels as a third dimension:
img = rand( N0f8, N, N, 3)
img = imresize(img, ratio=(0.7,0.7,1.0))
However, due to the memory arrangement of multidimensional arrays, it is better to have the channel in the first dimension and it is best to use RGB{N0f8}
. You can use channelview(img)
[2] if you want to access only particular channels.
Links: [1] GitHub - JuliaMath/FixedPointNumbers.jl: fixed point types for julia
[2] Views · ImageCore