I have a PNG file that loads as an IndirectArray with an eltype of RGB{N0f8}:
![]()
I use the following code:
using FileIO
using ImageIO
function f()
img = load("mwe.png")
@show typeof(img)
return img[1]
end
Calling f() gives the following result:
typeof(img) = IndirectArrays.IndirectArray{ColorTypes.RGB{FixedPointNumbers.N0f8}, 2, UInt8, Matrix{UInt8}, OffsetArrays.OffsetVector{ColorTypes.RGB{FixedPointNumbers.N0f8}, Vector{ColorTypes.RGB{FixedPointNumbers.N0f8}}}}
CanonicalIndexError: getindex not defined for OffsetArrays.OffsetVector{ColorTypes.RGB{FixedPointNumbers.N0f8}, Vector{ColorTypes.RGB{FixedPointNumbers.N0f8}}}
Stacktrace:
[1] error_if_canonical_getindex(::IndexCartesian, A::OffsetArrays.OffsetVector{ColorTypes.RGB{FixedPointNumbers.N0f8}, Vector{ColorTypes.RGB{FixedPointNumbers.N0f8}}}, ::Int64)
@ Base .\abstractarray.jl:1357
[2] getindex
@ .\abstractarray.jl:1341 [inlined]
[3] _getindex
@ .\abstractarray.jl:1388 [inlined]
[4] getindex
@ .\abstractarray.jl:1342 [inlined]
[5] getindex(A::IndirectArrays.IndirectArray{ColorTypes.RGB{FixedPointNumbers.N0f8}, 2, UInt8, Matrix{UInt8}, OffsetArrays.OffsetVector{ColorTypes.RGB{FixedPointNumbers.N0f8}, Vector{ColorTypes.RGB{FixedPointNumbers.N0f8}}}}, i::Int64)
@ IndirectArrays ...\.julia\packages\IndirectArrays\BUQO3\src\IndirectArrays.jl:64
[6] f()
@ Main .\REPL[2]:4
[7] top-level scope
@ REPL[3]:1
A second call of the function gives the result I expected on the first call:
typeof(img) = IndirectArrays.IndirectArray{ColorTypes.RGB{FixedPointNumbers.N0f8}, 2, UInt8, Matrix{UInt8}, OffsetArrays.OffsetVector{ColorTypes.RGB{FixedPointNumbers.N0f8}, Vector{ColorTypes.RGB{FixedPointNumbers.N0f8}}}}
RGB{N0f8}(1.0, 1.0, 1.0)
Is there something I should be doing before the first getindex operation to ensure that it works?