knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(picohdr)
PFM
imagePFM
(Portable Float Map) is a simple format for storing Gray or RGB colour data. Pixels
are stored as 32-bit floating point values in a simple array format.
Load and display a (PFM
) image.
Apply tone-mapping to the image and adjust the gamma correction prior to display.
filename <- system.file("image/rstats.pfm.bz2", package = "picohdr") im <- read_pfm(filename) dim(im) im |> tm_reinhard() |> adj_gamma() |> plot()
EXR
imageOpenEXR
images are a more complex HDR image container. Pixel types may
be 16-bit floats, 32-bit floats or 32-bit unsigned integers.
Images can contain any number of channels with arbitrary names - this includes data that isn't related to the colour of the display e.g. image depth, texture coordinates.
The actual image data may be stored as scanlines, tiles or deep images in single- or multi-part formats.
Currently, this package only supports reading single-part scanline images
which are using NONE
, ZIP
or ZIPS
compression.
The steps included below:
exr_info()
library(picohdr) # EXR file of meta-information about the rendered scene filename <- system.file("image/rstats.exr", package = "picohdr") # Load all images images <- read_exr(filename) dim(im) # Channel names. EXR format wants channels arranged alphabetically dimnames(images)[[3]] # Extract RGB channels. Tone-map. Adjust gamma. images[,,c('R', 'G', 'B')] |> tm_reinhard() |> adj_gamma() |> plot() # Plot the albedo Green channel plot(images[, , 'Albedo.G'])
This EXR file includes information about the surface derivative at each point in
the image in the dzdx
channel.
This value may be negative or positive, so we will map the values into the standard range [0, 1] so it can be visualised.
# Rescale the derivative channel to the range [0,1] and display images[,,'dzdx'] |> adj_rescale(0, 1) |> plot()
Meta-information about the contents of an EXR file can be extracted for all EXR image types.
exr_info(filename)
The code for handling EXR images is mostly written in base R with the exception of a core compression/decompression component which is written in C:
The ZIP compression mode applies a predictor and de-interleaves bytes. The byte predictor and interleaving can be in R but is 20x faster in C.
EXR support is for a subset of images which:
NONE
, ZIP
or ZIPS
compressionThis package does not support the following EXR features:
If you would like support for these features please file an issue on GitHub. A link to a free/openly-licensed image containing your requested features would be appreciated.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.