Skip to content

Commit

Permalink
Merge pull request imageworks#4 from colour-science/feature/package_s…
Browse files Browse the repository at this point in the history
…tructure

PR: Improve package structure.
  • Loading branch information
hpd committed Jun 2, 2015
2 parents cc938ac + 9404c06 commit fcecc2e
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 213 deletions.
2 changes: 1 addition & 1 deletion aces_1.0.0/python/aces_ocio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Python
******
>>> from aces_ocio.create_aces_config import create_ACES_config
>>> from aces_ocio.aces_config import create_ACES_config
>>> aces_ctl_directory = '/path/to/github/checkout/releases/v1.0.0/transforms/ctl'
>>> config_directory = '/path/to/configuration/dir'
>>> create_ACES_config(aces_ctl_directory, config_directory, 1024, 33, True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
import sys

import PyOpenColorIO as ocio

import aces_ocio.create_aces_colorspaces as aces
import aces_ocio.create_arri_colorspaces as arri
import aces_ocio.create_canon_colorspaces as canon
import aces_ocio.create_gopro_colorspaces as gopro
import aces_ocio.create_panasonic_colorspaces as panasonic
import aces_ocio.create_red_colorspaces as red
import aces_ocio.create_sony_colorspaces as sony
import aces_ocio.create_general_colorspaces as general

from aces_ocio.colorspaces import aces
from aces_ocio.colorspaces import arri
from aces_ocio.colorspaces import canon
from aces_ocio.colorspaces import general
from aces_ocio.colorspaces import gopro
from aces_ocio.colorspaces import panasonic
from aces_ocio.colorspaces import red
from aces_ocio.colorspaces import sony
from aces_ocio.process import Process


__author__ = 'ACES Developers'
__copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
__license__ = ''
Expand Down Expand Up @@ -406,9 +405,9 @@ def create_config(config_data, nuke=False):
views.append(display)

# Works with Nuke Studio and Mari, but not Nuke
#display_name = 'Utility'
#displays.append(display_name)
# display_name = 'Utility'
# displays.append(display_name)

linear_display_space_name = config_data['linearDisplaySpace'].name
log_display_space_name = config_data['logDisplaySpace'].name

Expand Down
20 changes: 20 additions & 0 deletions aces_1.0.0/python/aces_ocio/colorspaces/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import aces
import arri
import canon
import general
import gopro
import panasonic
import red
import sony

__all__ = ['aces',
'arri',
'canon',
'general',
'gopro',
'panasonic',
'red',
'sony']
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def create_ACEScc(aces_ctl_directory,
'float',
input_scale,
1,
{'transferFunctionOnly':1},
{'transferFunctionOnly': 1},
cleanup,
aces_ctl_directory,
min_value,
Expand Down Expand Up @@ -199,12 +199,12 @@ def create_ACESproxy(aces_ctl_directory,
ctls = [os.path.join(aces_ctl_directory,
'ACESproxy',
'ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl'),
# This transform gets back to the *AP1* primaries.
# Useful as the 1d LUT is only covering the transfer function.
# The primaries switch is covered by the matrix below:
os.path.join(aces_ctl_directory,
'ACEScg',
'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
# This transform gets back to the *AP1* primaries.
# Useful as the 1d LUT is only covering the transfer function.
# The primaries switch is covered by the matrix below:
os.path.join(aces_ctl_directory,
'ACEScg',
'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
lut = '%s_to_linear.spi1d' % name

lut = sanitize(lut)
Expand Down Expand Up @@ -434,6 +434,7 @@ def fit(value, from_min, from_max, to_min, to_max):
cs.from_reference_transforms = []
return cs


# -------------------------------------------------------------------------
# *Generic Log Transform*
# -------------------------------------------------------------------------
Expand Down Expand Up @@ -504,18 +505,19 @@ def create_generic_log(aces_ctl_directory,
cs.from_reference_transforms = []
return cs


# -------------------------------------------------------------------------
# *base Dolby PQ Transform*
# -------------------------------------------------------------------------
def create_dolbypq(aces_CTL_directory,
lut_directory,
lut_resolution_1d,
cleanup,
name='pq',
aliases=[],
min_value=0.0,
max_value=1.0,
input_scale=1.0):
lut_directory,
lut_resolution_1d,
cleanup,
name='pq',
aliases=[],
min_value=0.0,
max_value=1.0,
input_scale=1.0):
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
Expand All @@ -524,9 +526,9 @@ def create_dolbypq(aces_CTL_directory,
cs.is_data = False

ctls = [os.path.join(
aces_CTL_directory,
'utilities',
'ACESlib.OCIO_shaper_dolbypq_to_lin.a1.0.0.ctl')]
aces_CTL_directory,
'utilities',
'ACESlib.OCIO_shaper_dolbypq_to_lin.a1.0.0.ctl')]
lut = '%s_to_linear.spi1d' % name

lut = sanitize(lut)
Expand Down Expand Up @@ -554,21 +556,22 @@ def create_dolbypq(aces_CTL_directory,
cs.from_reference_transforms = []
return cs


# -------------------------------------------------------------------------
# *Dolby PQ Transform that considers a fixed linear range*
# -------------------------------------------------------------------------
def create_dolbypq_scaled(aces_CTL_directory,
lut_directory,
lut_resolution_1d,
cleanup,
name='pq',
aliases=[],
min_value=0.0,
max_value=1.0,
input_scale=1.0,
middle_grey=0.18,
min_exposure=-6.0,
max_exposure=6.5):
lut_directory,
lut_resolution_1d,
cleanup,
name='pq',
aliases=[],
min_value=0.0,
max_value=1.0,
input_scale=1.0,
middle_grey=0.18,
min_exposure=-6.0,
max_exposure=6.5):
cs = ColorSpace(name)
cs.description = 'The %s color space' % name
cs.aliases = aliases
Expand All @@ -577,9 +580,9 @@ def create_dolbypq_scaled(aces_CTL_directory,
cs.is_data = False

ctls = [os.path.join(
aces_CTL_directory,
'utilities',
'ACESlib.OCIO_shaper_dolbypq_to_lin_param.a1.0.0.ctl')]
aces_CTL_directory,
'utilities',
'ACESlib.OCIO_shaper_dolbypq_to_lin_param.a1.0.0.ctl')]
lut = '%s_to_linear.spi1d' % name

lut = sanitize(lut)
Expand Down Expand Up @@ -609,6 +612,7 @@ def create_dolbypq_scaled(aces_CTL_directory,
cs.from_reference_transforms = []
return cs


# -------------------------------------------------------------------------
# *Individual LMT*
# -------------------------------------------------------------------------
Expand Down Expand Up @@ -732,6 +736,7 @@ def create_ACES_LMT(lmt_name,

return cs


# -------------------------------------------------------------------------
# *LMTs*
# -------------------------------------------------------------------------
Expand Down Expand Up @@ -816,6 +821,7 @@ def create_LMTs(aces_ctl_directory,

return colorspaces


# -------------------------------------------------------------------------
# *ACES RRT* with supplied *ODT*.
# -------------------------------------------------------------------------
Expand Down Expand Up @@ -978,6 +984,7 @@ def create_ACES_RRT_plus_ODT(odt_name,

return cs


# -------------------------------------------------------------------------
# *ODTs*
# -------------------------------------------------------------------------
Expand Down Expand Up @@ -1056,20 +1063,25 @@ def create_ODTs(aces_ctl_directory,
log2_shaper_copy_colorspace.equality_group = log2_shaper_copy_name
log2_shaper_copy_colorspace.family = log2_shaper_colorspace.family
log2_shaper_copy_colorspace.is_data = log2_shaper_colorspace.is_data
log2_shaper_copy_colorspace.to_reference_transforms = list(log2_shaper_colorspace.to_reference_transforms)
log2_shaper_copy_colorspace.from_reference_transforms = list(log2_shaper_colorspace.from_reference_transforms)
log2_shaper_copy_colorspace.to_reference_transforms = list(
log2_shaper_colorspace.to_reference_transforms)
log2_shaper_copy_colorspace.from_reference_transforms = list(
log2_shaper_colorspace.from_reference_transforms)
colorspaces.append(log2_shaper_copy_colorspace)

# Defining the *Log2 shaper that includes the AP1* primaries.
log2_shaper_api1_name = "%s - AP1" % "Log2 Shaper"
log2_shaper_api1_colorspace = ColorSpace(log2_shaper_api1_name)
log2_shaper_api1_colorspace.description = 'The %s color space' % log2_shaper_api1_name
log2_shaper_api1_colorspace.aliases = ["%s_ap1" % compact(log2_shaper_copy_name)]
log2_shaper_api1_colorspace.aliases = [
"%s_ap1" % compact(log2_shaper_copy_name)]
log2_shaper_api1_colorspace.equality_group = log2_shaper_api1_name
log2_shaper_api1_colorspace.family = log2_shaper_colorspace.family
log2_shaper_api1_colorspace.is_data = log2_shaper_colorspace.is_data
log2_shaper_api1_colorspace.to_reference_transforms = list(log2_shaper_colorspace.to_reference_transforms)
log2_shaper_api1_colorspace.from_reference_transforms = list(log2_shaper_colorspace.from_reference_transforms)
log2_shaper_api1_colorspace.to_reference_transforms = list(
log2_shaper_colorspace.to_reference_transforms)
log2_shaper_api1_colorspace.from_reference_transforms = list(
log2_shaper_colorspace.from_reference_transforms)

# *AP1* primaries to *AP0* primaries.
log2_shaper_api1_colorspace.to_reference_transforms.append({
Expand All @@ -1088,8 +1100,10 @@ def create_ODTs(aces_ctl_directory,
shaper_api1_colorspace.equality_group = shaper_api1_name
shaper_api1_colorspace.family = log2_shaper_colorspace.family
shaper_api1_colorspace.is_data = log2_shaper_colorspace.is_data
shaper_api1_colorspace.to_reference_transforms = list(log2_shaper_api1_colorspace.to_reference_transforms)
shaper_api1_colorspace.from_reference_transforms = list(log2_shaper_api1_colorspace.from_reference_transforms)
shaper_api1_colorspace.to_reference_transforms = list(
log2_shaper_api1_colorspace.to_reference_transforms)
shaper_api1_colorspace.from_reference_transforms = list(
log2_shaper_api1_colorspace.from_reference_transforms)
colorspaces.append(shaper_api1_colorspace)

# Define the base *Dolby PQ Shaper*
Expand Down Expand Up @@ -1152,7 +1166,7 @@ def create_ODTs(aces_ctl_directory,
# Pick a specific shaper
#
rrt_shaper = log2_shaper_data
#rrt_shaper = dolbypq_scaled_shaper_data
# rrt_shaper = dolbypq_scaled_shaper_data

# *RRT + ODT* combinations.
sorted_odts = sorted(odt_info.iteritems(), key=lambda x: x[1])
Expand Down Expand Up @@ -1462,7 +1476,7 @@ def create_colorspaces(aces_ctl_directory,
ACES = create_ACES()

ACEScc = create_ACEScc(aces_ctl_directory, lut_directory,
lut_resolution_1d, cleanup,
lut_resolution_1d, cleanup,
min_value=-0.35840, max_value=1.468)
colorspaces.append(ACEScc)

Expand Down Expand Up @@ -1500,15 +1514,14 @@ def create_colorspaces(aces_ctl_directory,
ACEScc)
colorspaces.extend(odts)

roles = {'color_picking' : ACEScg.name,
'color_timing' : ACEScc.name,
'compositing_log' : ACEScc.name,
'data' : '',
'default' : ACES.name,
'matte_paint' : ACEScc.name,
'reference' : '',
'scene_linear' : ACES.name,
'texture_paint' : ''}

roles = {'color_picking': ACEScg.name,
'color_timing': ACEScc.name,
'compositing_log': ACEScc.name,
'data': '',
'default': ACES.name,
'matte_paint': ACEScc.name,
'reference': '',
'scene_linear': ACES.name,
'texture_paint': ''}

return ACES, colorspaces, displays, ACEScc, roles
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import PyOpenColorIO as ocio

import aces_ocio.create_aces_colorspaces as aces
from aces_ocio.colorspaces import aces
from aces_ocio.utilities import ColorSpace, mat44_from_mat33


Expand Down Expand Up @@ -79,6 +79,7 @@ def create_generic_matrix(name='matrix',

return cs


def create_colorspaces(lut_directory,
lut_resolution_1d,
lut_resolution_3d):
Expand Down Expand Up @@ -191,6 +192,7 @@ def create_colorspaces(lut_directory,

return colorspaces


def create_raw():
# *Raw* utility space
name = "Raw"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def protune_to_linear(normalized_code_value):
if gamut == 'Protune Gamut':
cs.to_reference_transforms.append({
'type': 'matrix',
'matrix': [ 0.533448429, 0.32413911, 0.142412421, 0,
-0.050729924, 1.07572006, -0.024990416, 0,
0.071419661, -0.290521962, 1.219102381, 0,
'matrix': [0.533448429, 0.32413911, 0.142412421, 0,
-0.050729924, 1.07572006, -0.024990416, 0,
0.071419661, -0.290521962, 1.219102381, 0,
0, 0, 0, 1],
'direction': 'forward'})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def v_log_to_linear(x):
if (x <= cutInv):
return (x - 0.125) / 5.6
else:
return pow(10, (x-d)/c) - b
return pow(10, (x - d) / c) - b

cs.to_reference_transforms = []

Expand All @@ -100,10 +100,10 @@ def v_log_to_linear(x):
if gamut == 'V-Gamut':
cs.to_reference_transforms.append({
'type': 'matrix',
'matrix': [ 0.724382758, 0.166748484, 0.108497411, 0.0,
0.021354009, 0.985138372, -0.006319092, 0.0,
-0.009234278, -0.00104295, 1.010272625, 0.0,
0, 0, 0, 1.0],
'matrix': [0.724382758, 0.166748484, 0.108497411, 0.0,
0.021354009, 0.985138372, -0.006319092, 0.0,
-0.009234278, -0.00104295, 1.010272625, 0.0,
0, 0, 0, 1.0],
'direction': 'forward'})

cs.from_reference_transforms = []
Expand Down
Loading

0 comments on commit fcecc2e

Please sign in to comment.