Okay to reduce the confusion I went ahead an installed TestImages
. Here’s what’s happening (I think):
julia> using Images, TestImages
julia> image = testimage("cameraman.tif");
julia> typeof(image)
Array{Gray{Normed{UInt8,8}},2}
So image
is an array of Gray{Normed{UInt8,8}}
elements:
julia> image[1,1]
Gray{N0f8}(0.612)
If you multiply those by an Int
, as you do, you end up with:
julia> image[1,1]*255
Gray{Float32}(156.0f0)
that doesn’t work for indexing, you need an integer. You converted this back to UInt8
:
julia> UInt8(image[1,1]*255)
0x9c
but then you’re directly adding a 1
, which as we said is just a literal that gets parsed as an Int64
, and adding that to your UInt8
just gives you a regular Int
:
julia> UInt8(image[1,1]*255)+1
157
So this is essentially the same as doing:
julia> Int(image[1,1]*255)+1
157