@@ -1432,7 +1432,8 @@ end
14321432function mat2img (mat:: Union{AbstractMatrix{UInt16},AbstractArray{UInt16,3}} ; x= Float64[], y= Float64[], v= Float64[], hdr= Float64[], proj4:: String = " " , wkt:: String = " " , img8:: AbstractMatrix{UInt8} = Matrix {UInt8} (undef,0 ,0 ), kw... )
14331433 _mat2img_u16 (mat, vec (Float64 .(x)), vec (Float64 .(y)), vec (Float64 .(v)), vec (Float64 .(hdr)), proj4, wkt, img8, KW (kw))
14341434end
1435- function _mat2img_u16 (@nospecialize (mat), x:: Vector{Float64} , y:: Vector{Float64} , v:: Vector{Float64} , hdr:: Vector{Float64} , proj4:: String , wkt:: String , @nospecialize (img8), d:: Dict{Symbol,Any} )
1435+ function _mat2img_u16 (@nospecialize (mat), x:: Vector{Float64} , y:: Vector{Float64} , v:: Vector{Float64} ,
1436+ hdr:: Vector{Float64} , proj4:: String , wkt:: String , @nospecialize (img8), d:: Dict{Symbol,Any} )
14361437 # Take an array of UInt16 and scale it down to UInt8. Input can be 2D or 3D.
14371438 # If the kw variable 'stretch' is used, we stretch the intervals in 'stretch' to [0 255].
14381439 # Use this option to stretch the image histogram.
@@ -1453,8 +1454,12 @@ function _mat2img_u16(@nospecialize(mat), x::Vector{Float64}, y::Vector{Float64}
14531454 nz = 1
14541455 isa (mat, Array{UInt16,3 }) ? (ny, nx, nz) = size (mat) : (ny, nx) = size (mat)
14551456
1456- (vals == " auto" || vals == :auto || (isa (vals, Real) && vals == 1 )) &&
1457- (vals = [find_histo_limits (mat)... ]) # Out is a tuple, convert to vector
1457+ is_auto = (vals == " auto" || vals == :auto || (isa (vals, Real) && vals == 1 ))
1458+ if (is_auto)
1459+ vals = [find_histo_limits (mat)... ] # Out is a tuple, convert to vector
1460+ elseif (isa (vals, Tuple)) # Shit is that we must tell from [v1 v2] and (tresh1, tresh2)
1461+ vals = [find_histo_limits (mat, thresholds= (Float64 (vals[1 ]),Float64 (vals[2 ])))... ]
1462+ end
14581463 len:: Int = length (vals)
14591464
14601465 (len > 2 * nz) && error (" 'stretch' has more elements then allowed by image dimensions" )
0 commit comments