Skip to content
Alexander Forsythe edited this page Jul 5, 2017 · 2 revisions

Overview

rawtoaces uses one of three methods to convert RAW image files to ACES.

  1. Camera spectral sensitivities and illuminant spectral power distributions
  2. Camera file metadata
  3. Camera data included in the libraw software

The preferred, and most accurate, method of converting RAW image files to ACES is to use camera spectral sensitivities and illuminant spectral power distributions, if available. If spectral sensitivity data is available for the camera, rawtoaces uses the method described in Academy document P-2013-001 (.pdf download).

While preferred, camera spectral sensitivity data is not commonly known to general users. When that is the case, rawtoaces can use either the metadata embedded in the camera file or camera data included in libraw to approximate a conversion to ACES.

Help message

A help message with a description of all command line options can be obtained by typing the following command:

$ rawtoaces --help
	rawtoaces - convert RAW digital camera files to ACES

Usage:
  rawtoaces file ...
  rawtoaces [options] file
  rawtoaces --help
  rawtoaces --version

IDT options:
  --help                  Show this screen
  --version               Show version
  --wb-method [0-4]       White balance factor calculation method
							0=white balance using file metadata 
							1=white balance using user specified illuminant [str] 
							2=Average the whole image for white balance
							3=Average a grey box for white balance <x y w h>
							4=Use custom white balance  <r g b g>
							(default = 0)
  --mat-method [0-2]      IDT matrix calculation method
							0=Calculate matrix from camera spec sens
							1=Use file metadata color matrix
							2=Use adobe coeffs included in libraw
							(default = 0)
							(default = /usr/local/include/rawtoaces/data/camera)
  --headroom float        Set highlight headroom factor (default = 6.0)
  --cameras               Show a list of supported cameras/models by LibRaw
  --valid-illums          Show a list of illuminants
  --valid-cameras         Show a list of cameras/models with available
						  spectral sensitivity datasets

Raw conversion options:
  -c float                Set adjust maximum threshold (default = 0.75)
  -C <r b>                Correct chromatic aberration
  -P <file>               Fix the dead pixels listed in this file
  -K <file>               Subtract dark frame (16-bit raw PGM)
  -k <num>                Set the darkness level
  -S <num>                Set the saturation level
  -n <num>                Set threshold for wavelet denoising
  -H [0-9]                Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild) (default = 0)
  -t [0-7]                Flip image (0=none, 3=180, 5=90CCW, 6=90CW)
  -j                      Don't stretch or rotate raw pixels
  -W                      Don't automatically brighten the image
  -b <num>                Adjust brightness (default = 1.0)
  -q [0-3]                Set the interpolation quality
  -h                      Half-size color image (twice as fast as "-q 0")
  -f                      Interpolate RGGB as four colors
  -m <num>                Apply a 3x3 median filter to R-G and B-G
  -s [0..N-1]             Select one raw image from input file
  -G                      Use green_matching() filter
  -B <x y w h>            Use cropbox

Benchmarking options:
  -v                      Verbose: print progress messages (repeated -v will add verbosity)
  -F                      Use FILE I/O instead of streambuf API
  -d                      Detailed timing report
  -E                      Use mmap()-ed buffer instead of plain FILE I/O

RAW conversion options

In most cases the default values for all "RAW conversion options" should be sufficient. Please see the help menu for details of the RAW conversion options.

Conversion using spectral sensitivities

If spectral sensitivity data for your camera is included with rawtoaces then the following command will convert your RAW file to ACES using that information.

$ rawtoaces input.raw

This command is equivalent to :

$ rawtoaces --wb-method 0 --mat-method 0 input.raw

To process mutiple raw files, you can try:

$ rawtoaces input1.raw input2.raw

To batch-process raw files in a directory, you can try:

$ rawtoaces input_dir

To batch-process raw files from multiple directories, you can try:

$ rawtoaces input_dir1 input_dir2

This is the preferred method as camera white balance gain factors and the RGB to ACES conversion matrix will be calculated using the spectral sensitivity data from your camera. This provides the most accurate conversion to ACES.

By default, rawtoaces will determine the adopted white by finding the set of white balance gain factors calculated from spectral sensitivities closest to the "As Shot" (aka Camera Multiplier) white balance gain factors included in the RAW file metadata. This default behavior can be overridden by including the desired adopted white name after the white balance method. The following example will use the white balance gain factors calculated from spectral sensitivities for D60.

$ rawtoaces --wb-method 1 D60 --mat-method 0 input.raw

If you have spectral sensitivity data for your camera but it is not included with rawtoaces you may place that data in /usr/local/include/RAWTOACES/data/camera or use the --ss-path option to point rawtoaces to the path of the data.

An example of the use of the --ss-path option would be

$ rawtoaces --ss-path /path/to/my/ss/data/ input.raw

JSON Schema for Spectral Datasets

The schema takes its roots in IES TM-27-14 but implements support for multiple spectral datasets while adopting JSON over XML for the simplicity of its grammar.

rawtoaces expects the spectral dataset to have the following shape: (380, 780, 5), i.e. starting from 380nm and ending at 780nm with a 5nm interval/bin size.

The attributes are defined as follows:

  • header
    • schema_version
      • description: Required, schema version of the current document.
      • type: "string"
    • catalog_number
      • description: Optional,
      • type: ["string", "null"]
    • comments
      • description: Optional, additional information for the spectral dataset.
      • type: ["string", "null"]
    • description
      • description: Required, description of the spectral dataset.
      • type: "string"
    • document_creation_date
      • description: Required, document creation date expressed as per RFC 3339 - Date and Time on the Internet: Timestamps, e.g. 2017-01-01T12:00:00Z.
      • type: "string"
      • format: "date-time"
    • document_creator
      • description: Required, creator of the document, e.g. company, individual, laboratory, etc.
      • type: "string"
    • laboratory
      • description: Optional, laboratory or company that performed the measurements.
      • type: ["string", "null"]
    • license
      • description: Required, usage license of the document, e.g. "CC-BY-NC-ND".
      • type: "string"
    • manufacturer
      • description: Optional, manufacturer of the device being tested.
      • type: ["string", "null"]
    • measurement_equipment
      • description: Optional, measurement equipment used to test the device.
      • type: ["string", "null"]
    • model
      • description: Optional, model of the device being tested.
      • type: ["string", "null"]
    • unique_identifier
      • description: Optional, generated unique identifier for the document, e.g. SHA256.
      • type: ["string", "null"]
  • spectral_data
    • bandwidth_FWHM
      • description: Optional, spectro-radiometer full-width at half-maximum bandwidth in nm.
      • type: ["number", "null"]
    • bandwidth_corrected
      • description: Optional, whether bandwidth correction has been applied to the spectral data.
      • type: ["boolean", "null"]
    • data
      • description: Required, defines the spectral dataset, requiring at least one key from index whose value is an object containing wavelength/value pairs.
      • type: "object"
    • index
      • description: Required, indexes the spectral dataset.
      • type: "object"
    • reflection_geometry
      • description: Required if units is reflectance, reflection geometry attributes as per CIE 15:2004.
      • type: ["string", "null"]
      • enum: ["di:8", "de:8", "8:di", "8:de", "d:d", "d:0", "45a:0", "45c:0", "0:45a", "45x:0", "0:45x", "other", null]
    • transmission_geometry
      • description: Required if units is transmittance, transmission geometry attributes as per CIE 15:2004.
      • type: ["string", "null"]
      • enum: ["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other", null]
    • units
      • description: Required, unit or quantity of measurement for the spectral dataset.
      • type: "string"
      • enum: ["flux", "absorptance", "transmittance", "reflectance", "intensity", "irradiance", "radiance", "exitance", "R-Factor", "T-Factor", "relative", "other"]

The full JSON schema for spectral datasets can be used to validate a new user file using a validator and is defined as follows:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions": {
    },
    "id": "#",
    "properties": {
        "header": {
            "id": "/properties/header",
            "properties": {
                "schema_version": {
                    "description": "Required, schema version of the current document.",
                    "id": "/properties/header/properties/api_version",
                    "type": "string"
                },
                "catalog_number": {
                    "description": "Optional, ",
                    "id": "/properties/header/properties/catalog_number",
                    "type": ["string", "null"]
                },
                "comments": {
                    "description": "Optional, additional information for the spectral dataset.",
                    "id": "/properties/header/properties/comments",
                    "type": ["string", "null"]
                },
                "description": {
                    "description": "Required, description of the spectral dataset.",
                    "id": "/properties/header/properties/description",
                    "type": "string"
                },
                "document_creation_date": {
                    "description": "Required, document creation date expressed as per RFC 3339 - Date and Time on the Internet: Timestamps, e.g. 2017-01-01T12:00:00Z.",
                    "id": "/properties/header/properties/document_creation_date",
                    "type": "string",
                    "format": "date-time"
                },
                "document_creator": {
                    "description": "Required, creator of the document, e.g. company, individual, laboratory, etc.",
                    "id": "/properties/header/properties/document_creator",
                    "type": "string"
                },
                "laboratory": {
                    "description": "Optional, laboratory or company that performed the measurements.",
                    "id": "/properties/header/properties/laboratory",
                    "type": ["string", "null"]
                },
                "license": {
                    "description": "Required, usage license of the document, e.g. CC-BY-NC-ND",
                    "id": "/properties/header/properties/license",
                    "type": "string"
                },
                "manufacturer": {
                    "description": "Optional, manufacturer of the device being tested.",
                    "id": "/properties/header/properties/manufacturer",
                    "type": ["string", "null"]
                },
                "measurement_equipment": {
                    "description": "Optional, measurement equipment used to test the device.",
                    "id": "/properties/header/properties/measurement_equipment",
                    "type": ["string", "null"]
                },
                "model": {
                    "description": "Optional, model of the device being tested.",
                    "id": "/properties/header/properties/model",
                    "type": ["string", "null"]
                },
                "unique_identifier": {
                    "description": "Optional, generated unique identifier for the document, e.g. SHA256.",
                    "id": "/properties/header/properties/unique_identifier",
                    "type": ["string", "null"]
                }
            },
            "required": [
                "description",
                "document_creation_date",
                "document_creator",
                "license"
            ],
            "type": "object"
        },
        "spectral_data": {
            "id": "/properties/spectral_data",
            "properties": {
                "bandwidth_FWHM": {
                    "description": "Optional, spectro-radiometer full-width at half-maximum bandwidth in nm.",
                    "id": "/properties/spectral_data/properties/bandwidth_FWHM",
                    "type": ["number", "null"]
                },
                "bandwidth_corrected": {
                    "description": "Optional, whether bandwidth correction has been applied to the spectral data.",
                    "id": "/properties/spectral_data/properties/bandwidth_corrected",
                    "type": ["boolean", "null"]
                },
                "data": {
                    "description": "Required, defines the spectral dataset, requiring at least one *key* from `index` whose *value* is an *object* containing wavelength/value pairs.",
                    "id": "/properties/spectral_data/properties/data",
                    "patternProperties": {
                    	"^.*$": { "type": "object" }
                    },
                    "additionalProperties": false,
                    "type": "object"
                },
                "index": {
                    "description": "Required, indexes the spectral dataset.",
                    "id": "/properties/spectral_data/properties/index",
                    "patternProperties": {
                        	"^.*$": { "type": "array" }
                    },
                    "additionalProperties": false,
                    "type": "object"
                },
                "reflection_geometry": {
                    "description": "Required if `units` is *reflectance*, reflection geometry attributes as per CIE 15:2004.",
                    "id": "/properties/spectral_data/properties/reflection_geometry",
                    "type": ["string", "null"],
                    "enum": ["di:8", "de:8", "8:di", "8:de", "d:d", "d:0", "45a:0", "45c:0", "0:45a", "45x:0", "0:45x", "other", null]
                },
                "transmission_geometry": {
                    "description": "Required if `units` is *transmittance*, transmission geometry attributes as per CIE 15:2004.",
                    "id": "/properties/spectral_data/properties/transmission_geometry",
                    "type": ["string", "null"],
                    "enum": ["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other", null]
                },
                "units": {
                    "description": "Required, unit or quantity of measurement for the spectral dataset.",
                    "id": "/properties/spectral_data/properties/units",
                    "type": "string",
                    "enum": ["flux", "absorptance", "transmittance", "reflectance", "intensity", "irradiance", "radiance", "exitance", "R-Factor", "T-Factor", "relative", "other"]
                }
            },
            "required": [
                "data",
                "index",
                "units"
            ],
            "type": "object"
        }
    },
    "required": [
        "header",
        "spectral_data"
    ],
    "type": "object"
}

Conversion using camera file metadata

In lieu of spectral sensitivity data, camera metadata can be used to convert RAW files to ACES. This includes the camera multiplier white balance gains and any RGB to XYZ matrix included. The RGB to XYZ matrix included in the metadata will be used to calculate the final RGB to ACES matrix used for conversion. The accuracy of this method is dependent on the camera manufacturer writing correct metadata into their RAW files.

The following commands will convert RAW to ACES using the camera file metadata for both white balance and the RGB to XYZ matrix.

$ rawtoaces --wb-method 0 --mat-method 1 input.raw

Conversion using camera data included in LibRaw

libraw includes matrices for a wide range of cameras which may provide a reasonable basis for conversion from RGB to ACES. These matrices were calculated by Adobe and are often referred to as the Adobe coefficients. To use these built-in matrices the following command may be used.

$ rawtoaces --mat-method 2

libraw also provides a few other methods for calculating white balance, including averaging the entire image, averaging a specified box within the image, or explicitly specifying the white balance gain factors to be used. These options can be utilized by using --wb-method [2-4] as desired.