[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] libvob vob/color/spaces.py vob/demo/lava/gamma....
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] libvob vob/color/spaces.py vob/demo/lava/gamma.... |
Date: |
Tue, 23 Sep 2003 06:38:32 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/09/23 06:38:32
Modified files:
vob/color : spaces.py
vob/demo/lava : gamma.py
Added files:
doc/pegboard/glmosaictext_java--tjl: peg.rst
Log message:
Arch sync
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/doc/pegboard/glmosaictext_java--tjl/peg.rst?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/color/spaces.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/lava/gamma.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: libvob/vob/color/spaces.py
diff -u libvob/vob/color/spaces.py:1.5 libvob/vob/color/spaces.py:1.6
--- libvob/vob/color/spaces.py:1.5 Mon Sep 22 04:49:01 2003
+++ libvob/vob/color/spaces.py Tue Sep 23 06:38:32 2003
@@ -37,32 +37,48 @@
G = .30,.60
B = .15,.06
-# coordinates of the white point (i.e., R = G = B = 1) --
+# Chromaiticy coordinates of the white point (i.e., R = G = B = 1) --
# this determines the relative luminances of the primaries
# W = .312713,.329016 # = D65 standard illuminant
W = .3127268660,.3290235126 # = D65 standard illuminant [CIE 15.2, p.55]
-# The gamma used for converting linear RGB to monitor RGB
-gamma = 2.2
+# The gamma and offset used for converting linear RGB to monitor RGB
+gamma = 2.4 # sRGB standard
+offset = .055
# The uncorrected display gamma of PC's is typically 2.2, i.e.,
# RGB values map to physical intensities with an exponent of 2.2.
-# So, gamma correction of 2.2 here should result in linear intensity.
-
-# These may later be changed to use the sRGB standard
-# (which is almost the same as the simple 2.2 gamma).
+# So, gamma correction of 2.2 (or 2.4 with .055 offset)
+# here should result in linear intensity.
def linear_to_monitor(rgb):
def f(x):
if x < 0: return -f(-x)
- return x**(1.0/gamma)
+ if offset == 0: return x**(1.0/gamma)
+
+ # Use a linear segment near zero
+ t = offset / (gamma - 1)
+ t2 = (t * gamma / (1 + offset))**gamma
+ c = t / (t * gamma / (1 + offset))**gamma
+ if x < t2:
+ return x * c
+
+ return x**(1.0/gamma) * (1 + offset) - offset
+
return (f(rgb[0]), f(rgb[1]), f(rgb[2]))
def monitor_to_linear(rgb):
def f(x):
if x < 0: return -f(-x)
- return x**gamma
-
+ if offset == 0: return x**gamma
+
+ # Use a linear segment near zero
+ t = offset / (gamma - 1)
+ c = t / (t * gamma / (1 + offset))**gamma
+ if x < t:
+ return x / c
+
+ return ((x + offset) / (1 + offset))**gamma
return (f(rgb[0]), f(rgb[1]), f(rgb[2]))
@@ -272,16 +288,19 @@
# a luminance component and a color plane vector whose angle and
# radius specify the hue and saturation, respectively.
#
-# The Y component is the CIE Y luminance (but the weights can be changed) and
-# the ST-plane has the RGB primaries 120 (R = 0, G = 120, B = 240) degrees
apart
-# at radius 1.
+# The Y component is the CIE Y luminance and
+# the ST-plane has the RGB primaries 120 (R = 0, G = 120, B = 240)
+# degrees apart at radius 1.
#
-# Luminance weights of the RGB primaries used in YST color space functions
+# Luminance weights of the RGB primaries used in YST color space
+# functions:
#Wr = 0.212671
#Wg = 0.715160
#Wb = 0.072169
-#Note: the weigths are computed from the values specified at the beginning
-#of this file
+# Note: the weigths are computed from the values specified at the
+# beginning of this file
+# Note: the YST color space is device dependent unless
+# a standardized RGB space is used
def YSTtoRGB(v):
mat = [ [1, Wg+Wb, (Wb - Wg) / math.sqrt(3) ],
Index: libvob/vob/demo/lava/gamma.py
diff -u libvob/vob/demo/lava/gamma.py:1.1 libvob/vob/demo/lava/gamma.py:1.2
--- libvob/vob/demo/lava/gamma.py:1.1 Mon Sep 22 04:49:01 2003
+++ libvob/vob/demo/lava/gamma.py Tue Sep 23 06:38:32 2003
@@ -36,7 +36,8 @@
def __init__(self):
self.key = KeyPresses(
self,
- SlideLin("gamma", 2.2, .05, "exponent", "Down", "Up"),
+ SlideLin("gamma", 2.4, .05, "exponent", "Down", "Up"),
+ SlideLin("offset", .055, .005, "offset", "Left", "Right"),
)
code = """
@@ -70,6 +71,22 @@
self.stripe2 = getDList(code)
code = """
+ LineWidth 1.0
+ Begin LINES
+ """
+ for i in range(0,N):
+ if i % 3 != 1:
+ code += """
+ Vertex .6666 %s
+ Vertex 1 %s
+ """ % (i, i)
+
+ code += """
+ End
+ """
+ self.stripe3 = getDList(code)
+
+ code = """
Begin QUAD_STRIP
Vertex .3333 0
Vertex .6666 0
@@ -81,6 +98,7 @@
def scene(self, vs):
vob.color.spaces.gamma = self.gamma
+ vob.color.spaces.offset = self.offset
vs.put( background( (0, 0, 0) ) )
@@ -88,17 +106,30 @@
i = 0
for cs in css:
col = [(1,1,1),(0,1,0),(1,0,0),(0,0,1)][i&3]
- f = (1 - (i / 4) * .2)**3
+ f = .5 * (1 - (i / 4) * .2)**3
i += 1
col = [c * f for c in col]
- col1 = [c * 1.5 for c in col]
- col2 = [c * .5 for c in col]
- vs.put(color(col))
- vs.map.put(self.stripe, cs)
+ col1 = [c * 2 for c in col]
+ col2 = [c * 3 for c in col]
+ col3 = [c * 3 / 2 for c in col]
+
if (col1[0] <= 1.0001 and
col1[1] <= 1.0001 and
col1[2] <= 1.0001):
vs.put(color(col1))
+ vs.map.put(self.stripe, cs)
+
+ if (col2[0] <= 1.0001 and
+ col2[1] <= 1.0001 and
+ col2[2] <= 1.0001):
+ vs.put(color(col2))
vs.map.put(self.stripe2, cs)
- vs.put(color(col2))
+ elif (col3[0] <= 1.0001 and
+ col3[1] <= 1.0001 and
+ col3[2] <= 1.0001):
+ vs.put(color(col3))
+ vs.map.put(self.stripe3, cs)
+
+ vs.put(color(col))
vs.map.put(self.block, cs)
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] libvob vob/color/spaces.py vob/demo/lava/gamma....,
Tuomas J. Lukka <=