OpenEXR (.exr)

Background & Context

    • Registered MIME type: image/x-exr
    • OpenEXR raster image format.
    • Used in digital image manipulation for theatrical film production.
    • EXR is an acronym for Extended Dynamic Range.
    • Binary file format.
    • Stores 16 bit per pixel IEEE HALF-precision floating-point color channels.
    • Can optionally store 32-bit IEEE floating-point "Z" channel depth-buffer components, surface normal directions, or motion vectors.
    • Can store multiple images using either tiled or multi-view scanline modes.
    • Supports alpha channels.
    • Introduced in 2003 by Industrial Light and Magic.
    • OpenEXR is a project of the Academy Software Foundation.

Import

  • Import["file.exr"] imports an OpenEXR file as a single Image.
  • Import["file.exr",elem] imports the specified element from an OpenEXR file.
  • The import format can be specified with Import["file","OpenEXR"] or Import["file",{"OpenEXR",elem,}].
  • Export["file.exr",expr] exports expr to OpenEXR.
  • The following expressions are supported:
  • imagean Image object
    graphicsa Graphics or Graphics3D object, rasterized
    {expr1,expr2,}a list of different images, also known as views
    <|"name1"expr1,|>a list of named images
  • When exporting graphics, the resulting image has the same raster size as its displayed form.
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Data representation elements:
  • "Image"first image returned as an Image object
    "Graphics"first image returned as a Graphics object
    "EmbeddedThumbnail"thumbnail stored in the file, if available
    "Thumbnail"thumbnail of the first image
  • Import by default uses the "Image" element.
  • OpenEXR may store multiple images known as views. Images typically represent multiple resolutions or various depth levels of the same image.
  • Properties of files containing multiple views:
  • "ImageCount"number of images in the file
    "ImageNames"names of images stored in the file
    "ImageMode"mode of the OpenEXR image
    "ImageSizeRoundingMode"rounding mode used in tiled images when downsampling
  • Possible image modes are:
  • "Scanline"single image
    "OneLevel"single level
    "Mipmap"mipmap tiling
    "Ripmap"ripmap tiling
    "Deep"stores multiple depth levels
  • Elements returning multiple views:
  • "Data"arrays of numeric values
    "GraphicsList"data returned as Graphics objects
    "ImageList"data returned as Image objects
  • Elements returning multiple views give an association in the form <|name1view1,|>, where the structure of viewi depends on level mode and whether the file stores a deep image.
  • The structure of the result for each image viewi depending on the image mode is:
  • "Scanline"res
    "OneLevel"<|1res1|>
    "Mipmap"<|1res11,2res22,|>
    "Ripmap"<|1<|1res11,2res21,|>,2<|1res12,2res22,|>,|>
    "Deep"<|1deep1,2deep2,|>
  • Where every resij is downsampled in the 1^(st) dimension by a factor of i and in the 2^(nd) dimension by a factor of j.
  • Separate channel representation elements:
  • "ChannelNames"name of color channels in each view
    "Channels"the number of color channels used in each view
    "ChannelData"channel data for each view
    "ChannelImageList"list of channel images for each view
  • Channels are automatically combined for some known color spaces (e.g. combining "R", "G" and "B" channels into an RGB image, etc.).
  • Metadata elements for each view:
  • "BitDepth"number of bits used to encode a color channel in the file
    "ColorSpace"color encoding used in the file
    "ImageSize"raster dimensions
    "LevelCount"number of levels per view
  • Metadata elements for the whole file:
  • "Attributes"list of all attributes stored in the OpenEXR file
    "Author"creator name
    "Comments"user comments
    "Compression"how images are compressed in the file
    "CopyrightNotice"copyright information as a string
    "DataWindow"coordinates of the corners of the data window
    "DateTime"file creation date and time
    "DisplayWindow"coordinates of the corners of the display window
    "Summary"summary of the file
    "SummarySlideView"slide view summary of all views
    "Version"version of the OpenEXR file
  • Subelements for partial data import for elements such as "Data", "ImageList" and "ChannelImageList" can be specified. Depending on the mode of the OpenEXR file, partial access can be specified in one of the following forms:
  • "Scanline"{elem,view,channel}
    "OneLevel"{elem,view,level,channel}
    "Mipmap"{elem,view,level,channel}
    "Ripmap"{elem,view,level,level,channel}
    "Deep"{elem,view,level,channel}
  • The data representation elements are imported from the data window.

Options

  • Import options:
  • ImageSizeAutomaticoverall image size
    "ImageTopOrientation"Automaticorientation of the image as stored in the file
  • Export options:
  • "Attributes"Automaticattributes associated to the file
    "ImageMode"Automaticmode of the OpenEXR image
    "ImageSizeRoundingMode""Up"rounding mode used in tiled images when downsampling
    "EmbeddedThumbnail"Nonethumbnail to be embedded into the file

Examples

open allclose all

Basic Examples  (3)

Import an OpenEXR file:

Import the list of images from a multi-resolution OpenEXR file:

Summary of an file:

Scope  (3)

Import  (3)

Import all images:

Import the first image:

Import metadata such as image size:

Summary of a tiled OpenEXR file:

Summary of a multi-view OpenEXR file:

Import Elements  (31)

Available Elements  (2)

List of available elements:

Import all elements as a list of rules:

Data Representation  (13)

"ChannelData"  (2)

Import the data channels as NumericArray objects:

Import only specific channels:

"ChannelImageList"  (2)

Import the data channels as Image objects:

Import only specific channels:

"Data"  (2)

Import the image data as NumericArray objects:

Import specific views:

"Graphics"  (1)

Import the first image as a Graphics object:

"GraphicsList"  (2)

Import the data as Graphics objects:

Import specific views:

"Image"  (1)

Import the first image as an Image object:

This is the default element:

"ImageList"  (2)

Import the data as Image objects:

Import specific views:

"Thumbnail"  (1)

Import a thumbnail of the first image:

Metadata  (16)

"Attributes"  (1)

Import the file attributes:

"BitDepth"  (1)

Import the bit depth per view:

"ChannelNames"  (1)

Import the channel names per view:

"Channels"  (1)

Import the channel count per view:

"ColorSpace"  (1)

Import the color space per view:

"Compression"  (1)

Import the compression used:

"DataWindow"  (1)

Import the data window:

"DisplayWindow"  (1)

Import the display window:

"LevelCount"  (1)

Import the number of levels per view:

"ImageCount"  (1)

Import the number of the views:

"ImageNames"  (1)

Import the names of the views:

"ImageMode"  (1)

Import the mode of the file:

"ImageSizeRoundingMode"  (1)

Import the rounding mode used in tiled images when downsampling:

"ImageSize"  (1)

Import the image size of the first image:

"Summary"  (1)

Import the file summary:

"SummarySlideView"  (1)

Import the summary per view:

Import Options  (2)

ImageSize  (1)

By default, images are imported in their full resolution:

Specify the raster size of the imported JPEG image:

"ImageTopOrientation"  (1)

By default, images are imported with the native orientation:

Specify the side that is supposed to be on the top:

Export Options  (1)

"ImageMode"  (1)

By default, the image mode is automatically chosen based on the expression.

A single image is exported as a "Scanline":

Specify the image mode on export:

When needed, low-resolution images are automatically generated and stored in the file:

Properties & Relations  (1)

Create an image pyramid and store in an OpenEXR file:

Look at the summary of the created file: