I have an image with two grayscale color channels I would like to visualize in the same plot.
How can I combine them?
I think I would need to add an alpha or something that scales with the gray value …
Or instead of ch1_grad = cgrad([:black, pal[1]])
for the gradient, I would use something like:
ch1_grad = cgrad([:clear, pal[1]])
or
ch1_grad = cgrad([:empty, pal[1]])
if it existed.
using Plots, Images
# Set up color palette
pal = palette(:batlow,2)
# The blue selected is too dark; let's lighten it and use it.
pal_light = pal .+ 0.5*ones(RGB{Float32},2,1)
pal = [pal_light[1],pal[2]]
# Make a gradient from black for each channel.
ch1_grad = cgrad([:black, pal[1]])
ch2_grad = cgrad([:black, pal[2]])
# Test images with gradients.
ch1 = Gray.(rand(1000,1000).*range(0.0,stop=1.0,length=1000))
ch2 = Gray.(rand(1000,1000).*range(1.0,stop=0.0,length=1000))
fig_test = plot(
legend = false,
colorbar = false)
heatmap!(fig_test,
reverse(Float64.(ch1),dims=1),
color = ch1_grad,
colorbar = false,
axis = nothing,
xaxis = false,
yaxis = false,
aspect_ratio = :equal)
heatmap!(fig_test,
reverse(Float64.(ch2),dims=1),
color = ch2_grad,
colorbar = false,
axis = nothing,
xaxis = false,
yaxis = false,
aspect_ratio = :equal)