Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Add sRGB colorspace
Browse files Browse the repository at this point in the history
Now Rec709 is a child of sRGB.
  • Loading branch information
mfe committed Dec 11, 2013
1 parent 85a3f68 commit 0d01824
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions utils/colorspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,10 @@ def gamma_to_lin(self, value):
pass


class Rec709(AbstractColorspace):
"""rec709 colorspace
class sRGB(AbstractColorspace):
"""sRGB colorspace
"""
def __init__(self):
self._alpha = 1.099
self._beta = 0.018
self._round_depth = 3

def get_red_primaries(self):
return 0.64, 0.33

Expand All @@ -99,6 +94,28 @@ def get_blue_primaries(self):
def get_white_point(self):
return 0.3127, 0.3290

def lin_to_gamma(self, value):
if value > 0.0031308:
return 1.055 * pow(value, 1.0 / 2.4) - 0.055
else:
return 12.92 * value

def gamma_to_lin(self, value):
if value > 0.04045:
return pow((value + 0.055) / 1.055, 2.4)
else:
return value / 12.92


class Rec709(sRGB):
"""rec709 colorspace
"""
def __init__(self):
self._alpha = 1.099
self._beta = 0.018
self._round_depth = 3

def lin_to_gamma(self, value):
if value < self._beta:
return value * 4.5
Expand Down Expand Up @@ -229,11 +246,13 @@ def gamma_to_lin(self, value):
REC2020_10B = Rec2020(is_ten_bits=True)
REC2020_12B = Rec2020(is_ten_bits=False)
ACES = ACES()
sRGB = sRGB()
COLORSPACES = {
'REC709': REC709,
'ALEXALOGCV3': ALEXALOGCV3,
'WIDEGAMUT': WIDEGAMUT,
'REC2020_10bits': REC2020_10B,
'REC2020_12bits': REC2020_12B,
'ACES': ACES,
'sRGB': sRGB,
}

0 comments on commit 0d01824

Please sign in to comment.