From f12d328cf76d5eda9efbb18a3baddf022db0bf53 Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Tue, 22 Jan 2019 22:42:04 +0100 Subject: [PATCH 1/2] clamp image for backends not supporting image Does not work for GR or PyPlot which are supposed to support images natively --- src/series.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/series.jl b/src/series.jl index 33861bd6..fbf5ee10 100644 --- a/src/series.jl +++ b/src/series.jl @@ -335,7 +335,7 @@ end yflip --> true cbar --> false fillcolor --> ColorGradient([:black, :white]) - SliceIt, 1:m, 1:n, Surface(convert(Matrix{Float64}, mat)) + SliceIt, 1:m, 1:n, Surface(clamp!(convert(Matrix{Float64}, mat), 0., 1.)) end end From 5e2598936687de9b0fd54aef5e7813388bfd2190 Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Wed, 23 Jan 2019 21:04:09 +0100 Subject: [PATCH 2/2] copy and clamp for greyscale images if outside (0,1) --- src/series.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/series.jl b/src/series.jl index fbf5ee10..ab2dd3a0 100644 --- a/src/series.jl +++ b/src/series.jl @@ -323,12 +323,14 @@ end # # images - grays +clamp_greys(mat::AMat{T}) where T<:Gray = Gray.(clamp!([m.val for m in mat], 0, 1)) @recipe function f(mat::AMat{T}) where T<:Gray n, m = size(mat) if is_seriestype_supported(:image) seriestype := :image yflip --> true + any(x-> x.val<0 || x.val >1, mat) && (mat = clamp_greys(mat)) SliceIt, 1:m, 1:n, Surface(mat) else seriestype := :heatmap