Displaying Images

The imview and implot functions are very similar. Both allow any abstract array of numbers to be rendered into an image or a Plots.jl image series. implot is largely a superset of imview because it also supports colorbars, tick marks, WCS grid lines, overplotting other data & shapes, and automatic axis and title naming (from the FITS header if available).


Any AbstractArray (including an AstroImage) can be displayed using imview. This function renders an arbitrary array into an array of RGBA values using a number of parameters. If the input is an AstroImage{<:Number}, an AstroImage{RGBA} will be returned that retains headers, WCS information, etc.

The defaults for the imview function are:

img = randn(50,50);
imview(img; clims=Percent(99.5), cmap=:magma, stretch=identity, contrast=1.0, bias=0.5)

We can adjust the color limits explicitly:

imview(img; clims=(-1, 1))

Or pass a function/callable object to calculate them for us:

imview(img; clims=Zscale())

We can turn off the colormap and use it in grayscale mode:

imview(img; cmap=nothing)

Pass any color scheme from ColorSchemes.jl:

imview(img; cmap=:ice)
imview(img; cmap=:seaborn_rocket_gradient)

Or an RGB or named color value:

imview(img; cmap="#F00")
imview(img; cmap="red")

Let's now switch to an astronomical image:

fname = download(
eagle = AstroImage("eagle-656nmos.fits")

We can apply a non-linear stretch like a log-scale, power-scale, or asinh stretch:

imview(eagle, stretch=asinhstretch)