| Title: | Publication-Grade Artistic Visualization of Hyperspectral Imagery |
|---|---|
| Description: | Creates artistic compositions and descriptive summaries from hyperspectral imaging cubes or numeric arrays. Provides radial spectral mandalas, cumulative spectral change, multi-band fusions, exact spectral density histograms, and experimental RMS spectral slope and within-pixel spectral quartiles. Returns composable 'ggplot' objects with explicit validity rules, display domains and compact original-rendering provenance. Does not read recordings, calibrate input values or infer physiology. |
| Authors: | R. Heller [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-8006-9742>) |
| Maintainer: | R. Heller <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0.9001 |
| Built: | 2026-11-03 18:11:24 UTC |
| Source: | https://github.com/CTTIR/hyperspectaculR |
A deterministic synthetic cube for examples and tests, shaped like an
hsi_cube so the art functions can be demonstrated without hyperspectR
or any recorded data.
hsa_demo_cube(rows = 48L, cols = 64L, bands = 24L, seed = 42L)hsa_demo_cube(rows = 48L, cols = 64L, bands = 24L, seed = 42L)
rows, cols
|
Spatial dimensions. Default |
bands |
Number of bands. Default |
seed |
Random seed. Default |
A list with data and wavelengths, classed as hsi_cube.
cube <- hsa_demo_cube() dim(cube$data)cube <- hsa_demo_cube() dim(cube$data)
Builds a colour composite by equally averaging three groups of measured bands. Averaging may reduce independent band noise but does not calibrate values. Explicit groups may overlap; singleton groups are allowed, including identical channels from one band. Each channel uses its own stretch.
hsa_fusion( cube, red = NULL, green = NULL, blue = NULL, by = c("index", "wavelength"), stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE, missing = c("propagate", "available") )hsa_fusion( cube, red = NULL, green = NULL, blue = NULL, by = c("index", "wavelength"), stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE, missing = c("propagate", "available") )
cube |
An |
red, green, blue
|
Integer vectors of band indices, or numeric
wavelengths in nm when |
by |
Either |
stretch |
Contrast stretch: |
probs |
Percentiles for |
display_limits |
Two increasing finite endpoints used as the fixed
colour domain for |
value_label |
A truthful label for the input values. Default
|
interpolate |
Logical; interpolate raster pixels. Default |
missing |
Missing-band policy. |
A ggplot2 object.
cube <- hsa_demo_cube() hsa_fusion(cube)cube <- hsa_demo_cube() hsa_fusion(cube)
Renders the scene as concentric annuli, each drawn from a sampled spectral band: the innermost ring uses the first band and the outermost uses the last. The result is a spatial composition; unequal annular areas do not estimate the spectral distribution. A single ring selects the first band.
hsa_mandala( cube, centre = NULL, n_rings = 36L, palette = "magma", stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE, sampling = c("index", "wavelength") )hsa_mandala( cube, centre = NULL, n_rings = 36L, palette = "magma", stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE, sampling = c("index", "wavelength") )
cube |
An |
centre |
Numeric length-2 vector |
n_rings |
Number of annuli. Default |
palette |
Palette name passed to |
stretch |
Contrast stretch: |
probs |
Percentiles for |
display_limits |
Two increasing finite endpoints used as the fixed
colour domain for |
value_label |
A truthful label for the input values. Default
|
interpolate |
Logical; interpolate raster pixels. Default |
sampling |
Ring targets: |
This uses the spectral dimension for a spatial composition. A single band or repeated ring selections can produce a degenerate single-band result. The default radius-to-band-index mapping is linear. Wavelength sampling uses equally spaced physical targets and nearest measured bands, with ties toward shorter wavelengths. Repeated selections and empty rings retain the geometry and are disclosed in the caption and provenance.
A ggplot2 object.
cube <- hsa_demo_cube() hsa_mandala(cube, n_rings = 12)cube <- hsa_demo_cube() hsa_mandala(cube, n_rings = 12)
Returns colour ramps suitable for scientific imagery. The palettes other
than "turbo" are perceptually uniform and monotonic in lightness, so
ordering survives greyscale printing and remains legible to colourblind
readers. "turbo" is retained with a warning for compatibility.
hsa_palette( name = c("viridis", "magma", "inferno", "plasma", "cividis", "mako", "rocket", "turbo"), n = 256L, direction = 1 )hsa_palette( name = c("viridis", "magma", "inferno", "plasma", "cividis", "mako", "rocket", "turbo"), n = 256L, direction = 1 )
name |
Palette name. One of |
n |
Number of colours. Default |
direction |
|
A character vector of hex colours.
head(hsa_palette("magma", n = 5))head(hsa_palette("magma", n = 5))
Returns the compact calculation and display record attached when a
hyperspectaculR plot was created. Later arbitrary ggplot modifications may
change the visible plot without updating this original-rendering record.
Ordinary + ggplot2::theme() and + ggplot2::labs() additions preserve it.
Inspect individual component plots before assembling a patchwork; a combined
patchwork has no single calculation record. Full actual band selections,
endpoints, fallback reasons, exclusions and quantity definitions remain
inspectable even when plot labels abbreviate them. Source cubes and arbitrary
input metadata are not retained in the record.
hsa_provenance(plot)hsa_provenance(plot)
plot |
A plot returned by a hyperspectaculR renderer. |
A compact named list describing the original rendering.
Draws the joint distribution of input values and spectral coordinates as an exact two-dimensional histogram. A binned mean and binned 5–95% pixel envelope are calculated from the retained histogram counts.
hsa_spectral_density( cube, nbins = 128L, limits = NULL, transform = c("log1p", "identity"), normalise = c("none", "band"), palette = "mako", show_limits = FALSE, probs = c(0.02, 0.98), value_label = "input value" )hsa_spectral_density( cube, nbins = 128L, limits = NULL, transform = c("log1p", "identity"), normalise = c("none", "band"), palette = "mako", show_limits = FALSE, probs = c(0.02, 0.98), value_label = "input value" )
cube |
An |
nbins |
Number of value bins. Must be an integer of at least two.
Default |
limits |
Numeric length-two value range to bin over. |
transform |
Display transform: |
normalise |
|
palette |
Palette name passed to |
show_limits |
Logical. Draw global raw eligible-value percentiles using
|
probs |
Two increasing finite probabilities between zero and one for
the global raw eligible-value references when |
value_label |
A truthful label for the input values. Default
|
Values outside limits are dropped rather than clipped into the end bins.
Masks and nonfinite values are excluded. The overlay describes the retained
pixel distribution; it is not a confidence interval.
A ggplot2 object with compact original-rendering provenance.
cube <- hsa_demo_cube() hsa_spectral_density(cube)cube <- hsa_demo_cube() hsa_spectral_density(cube)
Sums the absolute change between consecutive bands at every pixel, giving a field of total spectral variability. Flat spectra appear dark; pixels whose input values change across the spectrum appear bright.
hsa_spectral_flux( cube, palette = "inferno", normalise = TRUE, stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE, normalization = NULL )hsa_spectral_flux( cube, palette = "inferno", normalise = TRUE, stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE, normalization = NULL )
cube |
An |
palette |
Palette name passed to |
normalise |
Logical. Divide by the number of band steps, so the value
is a mean absolute step rather than a total. Default |
stretch |
Contrast stretch: |
probs |
Percentiles for |
display_limits |
Two increasing finite endpoints used as the fixed
colour domain for |
value_label |
A truthful label for the input values. Default
|
interpolate |
Logical; interpolate raster pixels. Default |
normalization |
|
Unlike a single-band image this cannot be produced from any one wavelength, and unlike a variance map it is sensitive to the ordering of the bands, so it responds to spectral shape rather than spread alone.
Wavelength-span normalization requires at least two physical wavelengths in nm and a finite positive representable span. It measures mean absolute slope of the piecewise-linear spectrum in input-value units per nm. Gaps bridge unobserved structure; this does not correct sampling density, unresolved peaks, or measurement noise. Every band must be finite at a valid pixel. Nonrepresentable requested arithmetic raises an error.
A ggplot2 object.
cube <- hsa_demo_cube() hsa_spectral_flux(cube)cube <- hsa_demo_cube() hsa_spectral_flux(cube)
An experimental descriptive image of the nonnegative RMS magnitude of the wavelength derivative of each pixel's piecewise-linear spectrum.
hsa_spectral_gradient( cube, palette = "inferno", stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE )hsa_spectral_gradient( cube, palette = "inferno", stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE )
cube |
An |
palette |
Palette name passed to |
stretch |
Contrast stretch: |
probs |
Percentiles for |
display_limits |
Two increasing finite endpoints used as the fixed
colour domain for |
value_label |
A truthful label for the input values. Default
|
interpolate |
Logical; interpolate raster pixels. Default |
For interval widths h = diff(wavelengths) and endpoint span L, G = sqrt(sum(h * (diff(x)/h)^2)/L). Values have input-value units per nm. This is neither a signed derivative, a spatial gradient, nor uncertainty. Short intervals and measurement noise can dominate the result. Gaps in sampling bridge unresolved structure; no smoothing or noise correction is applied. Physical wavelength metadata in nm and at least two bands are required, with finite positive representable intervals and span. A masked or incomplete spectrum is transparent; missing bands are never bridged. Nonrepresentable requested arithmetic raises an error.
A ggplot object with raw values and original-rendering provenance.
hsa_spectral_gradient(hsa_demo_cube())hsa_spectral_gradient(hsa_demo_cube())
An experimental descriptive composition with equal-band type-7 quartiles computed over the measured bands within each spatial pixel.
hsa_spectral_quartiles( cube, palette = "magma", stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE )hsa_spectral_quartiles( cube, palette = "magma", stretch = c("percentile", "range", "none"), probs = c(0.02, 0.98), display_limits = c(0, 1), value_label = "input value", interpolate = TRUE )
cube |
An |
palette |
Palette name passed to |
stretch |
Contrast stretch: |
probs |
Percentiles for |
display_limits |
Two increasing finite endpoints used as the fixed
colour domain for |
value_label |
A truthful label for the input values. Default
|
interpolate |
Logical; interpolate raster pixels. Default |
The panels are the 25th percentile, median and 75th percentile.
Every band must be finite and the pixel unmasked; validity is shared by all
panels. One band is allowed and gives three identical values. Bands have
equal weight, regardless of wavelength spacing. These summaries omit
spectral ordering, depend on sampling density, and are not confidence
intervals or uncertainty estimates. A single stretch pools the three
rendered raw panel values; all panels share its domain and legend. With a
stretch the legend labels display values on 0-1; with stretch = "none"
it labels raw input values in the supplied display_limits domain.
One faceted ggplot object, retaining raw panel values and provenance.
hsa_spectral_quartiles(hsa_demo_cube())hsa_spectral_quartiles(hsa_demo_cube())
A dark, chrome-free theme for image-like panels. Axes, grids and panel backgrounds are removed, because for a rendered scene they carry no information and compete with the image.
hsa_theme( base_size = 11, base_family = "", background = "#0B0B0F", ink = "#E8E8EC" )hsa_theme( base_size = 11, base_family = "", background = "#0B0B0F", ink = "#E8E8EC" )
base_size |
Base font size in points. Default |
base_family |
Font family. Default |
background |
Panel and plot background colour. Default |
ink |
Foreground colour for text. Default |
Deliberately standalone: it does not require hyperspectR, so figures
can be produced anywhere a cube is available, while remaining visually
compatible with hyperspectR::theme_hsi().
A ggplot2 theme object.
library(ggplot2) ggplot(data.frame(x = 1, y = 1), aes(x, y)) + geom_point() + hsa_theme()library(ggplot2) ggplot(data.frame(x = 1, y = 1), aes(x, y)) + geom_point() + hsa_theme()