@@ -59,7 +59,7 @@ im_from_matlab(X::AbstractArray) = throw(ArgumentError("Unrecognized MATLAB imag
59
59
60
60
# Step 2: storage type conversion
61
61
function im_from_matlab (:: Type{CT} , X:: AbstractArray{T} ) where {CT,T}
62
- if T<: Union{Normed, AbstractFloat}
62
+ if T <: Union{Normed,AbstractFloat}
63
63
return _im_from_matlab (CT, X)
64
64
else
65
65
msg = " Unrecognized element type $T , manual conversion to float point number or fixed point number is needed."
@@ -68,11 +68,11 @@ function im_from_matlab(::Type{CT}, X::AbstractArray{T}) where {CT,T}
68
68
throw (ArgumentError (msg))
69
69
end
70
70
end
71
- im_from_matlab (:: Type{CT} , X:: AbstractArray{UInt8} ) where CT = _im_from_matlab (CT, reinterpret (N0f8, X))
72
- im_from_matlab (:: Type{CT} , X:: AbstractArray{UInt16} ) where CT = _im_from_matlab (CT, reinterpret (N0f16, X))
73
- function im_from_matlab (:: Type{CT} , X:: AbstractArray{Int16} ) where CT
71
+ im_from_matlab (:: Type{CT} , X:: AbstractArray{UInt8} ) where {CT} = _im_from_matlab (CT, reinterpret (N0f8, X))
72
+ im_from_matlab (:: Type{CT} , X:: AbstractArray{UInt16} ) where {CT} = _im_from_matlab (CT, reinterpret (N0f16, X))
73
+ function im_from_matlab (:: Type{CT} , X:: AbstractArray{Int16} ) where {CT}
74
74
# MALTAB compat
75
- _im2double (x) = (Float64 (x)+ Float64 (32768 ))/ Float64 (65535 )
75
+ _im2double (x) = (Float64 (x) + Float64 (32768 )) / Float64 (65535 )
76
76
return _im_from_matlab (CT, mappedarray (_im2double, X))
77
77
end
78
78
@@ -88,22 +88,26 @@ function _matlab_type_hint(@nospecialize X)
88
88
end
89
89
90
90
# Step 3: colorspace conversion
91
- _im_from_matlab (:: Type{CT} , X:: AbstractArray{CT} ) where CT<: Colorant = X
91
+ _im_from_matlab (:: Type{CT} , X:: AbstractArray{CT} ) where { CT<: Colorant } = X
92
92
@static if VERSION >= v " 1.3"
93
93
# use StructArray to inform that this is a struct of array layout
94
- function _im_from_matlab (:: Type{CT} , X:: AbstractArray{T,3} ) where {CT<: Colorant , T<: Real }
94
+ function _im_from_matlab (:: Type{CT} , X:: AbstractArray{T,3} ) where {CT<: Colorant ,T<: Real }
95
95
_CT = isconcretetype (CT) ? CT : base_colorant_type (CT){T}
96
96
# FIXME (johnnychen94): not type inferrable here
97
97
return StructArray {_CT} (X; dims= 3 )
98
98
end
99
99
else
100
- function _im_from_matlab (:: Type{CT} , X:: AbstractArray{T,3} ) where {CT<: Colorant , T<: Real }
100
+ function _im_from_matlab (:: Type{CT} , X:: AbstractArray{T,3} ) where {CT<: Colorant ,T<: Real }
101
101
_CT = isconcretetype (CT) ? CT : base_colorant_type (CT){T}
102
102
# FIXME (johnnychen94): not type inferrable here
103
103
return colorview (_CT, PermutedDimsArray (X, (3 , 1 , 2 )))
104
104
end
105
105
end
106
- _im_from_matlab (:: Type{CT} , X:: AbstractArray{T} ) where {CT<: Gray , T<: Real } = colorview (CT, X)
106
+ function _im_from_matlab (:: Type{CT} , X:: AbstractArray{T} ) where {CT<: Colorant ,T<: Real }
107
+ throw (ArgumentError (" For $(ndims (X)) dimensional numerical array, manual conversion from MATLAB layout is required." ))
108
+ end
109
+ _im_from_matlab (:: Type{CT} , X:: AbstractArray{T} ) where {CT<: Gray ,T<: Real } = colorview (CT, X)
110
+ _im_from_matlab (:: Type{CT} , X:: AbstractArray{T,3} ) where {CT<: Gray ,T<: Real } = colorview (CT, X)
107
111
108
112
109
113
"""
0 commit comments