Skip to content

Commit

Permalink
fix UInt8 indexed image for im_from_matlab
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnychen94 committed Apr 20, 2022
1 parent 02c9214 commit 251fb2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/matlab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ _im_from_matlab(::Type{CT}, X::AbstractArray{T}) where {CT<:Gray,T<:Real} = colo
_im_from_matlab(::Type{CT}, X::AbstractArray{T,3}) where {CT<:Gray,T<:Real} = colorview(CT, X)

# index image support
im_from_matlab(index::AbstractArray, values::AbstractMatrix{T}) where T<:Real = im_from_matlab(RGB{T}, index, values)
im_from_matlab(index::AbstractArray, values::AbstractMatrix{T}) where T<:Real = im_from_matlab(RGB, index, values)
@static if VERSION >= v"1.3"
function im_from_matlab(::Type{CT}, index::AbstractArray, values::AbstractMatrix{T}) where {CT<:Colorant, T<:Real}
return IndirectArray(index, im_from_matlab(CT, values))
Expand Down
6 changes: 6 additions & 0 deletions test/matlab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@
lab_values = permutedims(channelview(Lab.(img.values)), (2, 1))
lab_img = im_from_matlab(Lab, index, lab_values)
@test sum(abs2, channelview(RGB.(lab_img) - img)) < 1e-10

values = UInt8.(values .* 255)
img = im_from_matlab(index, values)
@test size(img) == (2, 5)
@test eltype(img) == RGB{N0f8}
@test img[2, 3] == RGB(0.0, 0.0, 1.0)
end
end

Expand Down

0 comments on commit 251fb2d

Please sign in to comment.