I’m doing some working with images using the Images package, and when larger images are displayed they are scaled smaller than the actual size. How do I change this?
img = Gray.(rand(1200,1200))
I’m doing some working with images using the Images package, and when larger images are displayed they are scaled smaller than the actual size. How do I change this?
img = Gray.(rand(1200,1200))
The following code using Plots’ gr()
backend displays images that are proportionally scaled in subplots.
using Images, Plots; gr(titlefontsize=16)
plt = Array{Plots.Plot{Plots.GRBackend}}(undef,3)
img1 = Gray.(rand(600,600))
img2 = Gray.(rand(150,300))
img3 = Gray.(rand(300,1200))
plt[1] = plot(img1, title="600x600");
plt[2] = plot(img2, title="150x300");
plt[3] = plot(img3, title="300x1200");
h1, w1 = size(img1); h2, w2 = size(img2); h3, w3 = size(img3)
h = [h1,h2,h3]; w = [w1,w2,w3]
hs, ws = sum(h), sum(w)
hn = h/hs; wn = w/ws # to use with grid heights and/or widths
Plots.plot(plt..., layout = grid(1, 3, widths=wn), axis=nothing) # images scaled in subplots
Plots.plot!(size=(ws,maximum(h)))
For plotting individual images with correct relative sizes:
Plots.plot(img1, size=(w1,h1))
Plots.plot(img2, size=(w2,h2))
Plots.plot(img3, size=(w3,h3))
Or use ImageView.jl:
using Images, ImageView
imshow(img1)
imshow(img2)
imshow(img3)