Explicit image and density conversions
ot_image.RdImages use row-major order: x increases to the right and y increases upwards. Intensities are treated as pixel masses and normalized, discarding total intensity. Density grids use trapezoidal quadrature weights at the grid nodes; this is a finite approximation to the supplied curve, not a continuous density.
Arguments
- image
A nonempty nonnegative numeric matrix.
- x, y
Optional pixel-center coordinates. x must increase by column and y must decrease by row. Values encode pixel mass, including on nonuniform grids.
- grid
A strictly increasing finite numeric vector of at least two nodes.
- density
Nonnegative finite density heights at the nodes.
Examples
ot_image(matrix(c(1, 0, 0, 2, 0, 1), 2, 3))
#> Finite probability measure: 6 atoms in 2 dimension(s)
#> Representation: image_pixels | total mass: 1
ot_density(seq(-3, 3, length.out = 21), dnorm(seq(-3, 3, length.out = 21)))
#> Finite probability measure: 21 atoms in 1 dimension(s)
#> Representation: density_grid_quadrature | total mass: 1