diff options
Diffstat (limited to 'debian/lcms/lcms-1.19.dfsg2/python/testbed')
13 files changed, 556 insertions, 0 deletions
diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/cam02.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/cam02.py new file mode 100755 index 00000000..994063b2 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/cam02.py @@ -0,0 +1,37 @@ +
+#
+# Sample: CIECAM02 appearance model
+#
+
+from lcms import *
+
+
+Wt = cmsCIEXYZ()
+
+Wt.X = 95.05
+Wt.Y = 100
+Wt.Z = 108.88
+
+vc = cmsViewingConditions(Wt, 20, 20, AVG_SURROUND, 0.997)
+
+cam = cmsCIECAM02Init(vc)
+
+JCh = cmsJCh()
+XYZ = cmsCIEXYZ()
+
+XYZ.X = 19.01
+XYZ.Y = 20
+XYZ.Z = 21.78
+
+print XYZ
+
+cmsCIECAM02Forward(cam, XYZ, JCh)
+
+print JCh
+
+cmsCIECAM02Reverse(cam, JCh, XYZ)
+print XYZ
+
+cmsCIECAM02Done(cam)
+
+
diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/cam97.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/cam97.py new file mode 100755 index 00000000..c365c2b1 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/cam97.py @@ -0,0 +1,37 @@ + +# +# Sample: CIECAM97s appearance model +# + +from lcms import * + + +Wt = cmsCIEXYZ() + +Wt.X = 95.05 +Wt.Y = 100 +Wt.Z = 108.88 + +vc = cmsViewingConditions(Wt, 20, 20, AVG_SURROUND, 0.997) + +cam = cmsCIECAM97sInit(vc) + +JCh = cmsJCh() +XYZ = cmsCIEXYZ() + +XYZ.X = 19.01 +XYZ.Y = 20 +XYZ.Z = 21.78 + +print XYZ + +cmsCIECAM97sForward(cam, XYZ, JCh) + +print JCh + +cmsCIECAM97sReverse(cam, JCh, XYZ) +print XYZ + +cmsCIECAM97sDone(cam) + + diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/clamp.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/clamp.py new file mode 100755 index 00000000..2115b097 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/clamp.py @@ -0,0 +1,23 @@ + +# +# Sample: Gamut clamping +# + +from lcms import * + + + +Lab = cmsCIELab(80, -200, 50) +print "Original", Lab + +# +# Desaturates color to bring it into gamut. +# The gamut boundaries are specified as: +# -120 <= a <= 120 +# -130 <= b <= 130 + +cmsClampLab(Lab, 120, -120, 130, -130) + +print "Constrained", Lab + + diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/constant.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/constant.py new file mode 100755 index 00000000..ccc0e578 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/constant.py @@ -0,0 +1,30 @@ + +# +# Sample: Constants +# + +from lcms import * + + +print "D50=", cmsD50_XYZ() +print "D50=", cmsD50_xyY() + +Lab = cmsCIELab(70, -3, 45) + +print +print Lab + +LCh = cmsCIELCh(0, 0, 0) +cmsLab2LCh(LCh, Lab) +print LCh + +Lab2 = cmsCIELab(70, 3, 45) + +print +print Lab, Lab2 +print "dE (Lab) =", cmsDeltaE(Lab, Lab2) +print "dE (CIE94)=", cmsCIE94DeltaE(Lab, Lab2) +print "dE (BFD) = ", cmsBFDdeltaE(Lab, Lab2) +print "dE (CMC) = ", cmsCMCdeltaE(Lab, Lab2) + + diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/createmsh.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/createmsh.py new file mode 100755 index 00000000..b4e15cb8 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/createmsh.py @@ -0,0 +1,37 @@ +#
+# Sample: Creates and saves a matrix-shaper profile
+#
+
+from lcms import *
+
+Rec709Primaries = cmsCIExyYTRIPLE(cmsCIExyY(0.6400, 0.3300, 1.0),
+ cmsCIExyY(0.3000, 0.6000, 1.0),
+ cmsCIExyY(0.1500, 0.0600, 1.0))
+
+
+Gamma22 = GAMMATABLE(2.2, 4096)
+D65 = cmsCIExyY()
+cmsWhitePointFromTemp(6504, D65)
+
+hVirtual_sRGB = cmsCreateRGBProfile(D65,
+ Rec709Primaries,
+ (Gamma22, Gamma22, Gamma22));
+
+
+
+#
+# This should probably be bettered somehow...
+#
+
+icSigProfileDescriptionTag = icTagSignature(0x64657363)
+text = StrPointer("Sample sRGB profile")
+
+
+cmsAddTag(hVirtual_sRGB, icSigProfileDescriptionTag, text)
+
+
+cmsSaveProfile(hVirtual_sRGB, "Virtual_sRGB.icm")
+
+cmsCloseProfile(hVirtual_sRGB)
+
+
diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/gamma.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/gamma.py new file mode 100755 index 00000000..1a1e7247 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/gamma.py @@ -0,0 +1,60 @@ +# +# Sample: Gamma tables +# + +from lcms import * + + +# +# Allocate a gamma table +# + +Gamma22 = GAMMATABLE(2.2) + +print Gamma22 + +# +# Specify num. of sampled points +# + +Gamma22 = GAMMATABLE(2.2, 1024) + +print Gamma22 + +# +# Reverse a gamma table +# + +Gamma28 = GAMMATABLE(2.8, 1024) +Rev28 = cmsReverseGamma(1024, Gamma28) +print Rev28 + +# +# Joint a Gamma 2.8 with inverse of 2.4 +# + +Joined = cmsJoinGamma(Gamma28, Gamma22) +print Joined + +# +# Same, specifying num. of points +# + +Joined = cmsJoinGammaEx(Gamma28, Gamma22, 2048) +print Joined + +# +# "Smooth" a curve. Second parameter is smothness lambda +# +cmsSmoothGamma(Joined, 0.8) +print Joined + + +# +# This should result on a line +# +Straight = cmsJoinGammaEx(Joined, Joined, 2048) +print Straight + + + diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/info.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/info.py new file mode 100755 index 00000000..a271a303 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/info.py @@ -0,0 +1,32 @@ + +# +# Sample: Get info on profile +# + +from lcms import * + + +hsRGB = cmsOpenProfileFromFile("sRGB Color Space profile.icm", "r") + + +print "Product name: ", cmsTakeProductName(hsRGB) +print "Product desc: ", cmsTakeProductDesc(hsRGB) +print "Info: ", cmsTakeProductInfo(hsRGB) + +Illuminant = cmsCIEXYZ(0, 0, 0) +cmsTakeIluminant(Illuminant, hsRGB) +print "Illuminant = ", Illuminant + +MediaWhite = cmsCIEXYZ(0, 0, 0) +cmsTakeMediaWhitePoint(MediaWhite, hsRGB) +print "Media White = ", MediaWhite + +BlackPoint = cmsCIEXYZ(0, 0, 0) +cmsTakeMediaBlackPoint(BlackPoint, hsRGB) +print "Black point = ", BlackPoint + + +cmsCloseProfile(hsRGB) + + + diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/lab2adobe.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/lab2adobe.py new file mode 100755 index 00000000..c8ac3137 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/lab2adobe.py @@ -0,0 +1,56 @@ +
+#
+# Sample: Convert from Lab to AdobeRGB, perceptual intent
+#
+
+from lcms import *
+
+
+print "Enter Lab values"
+
+#
+# Create placeholders
+#
+
+Lab = cmsCIELab(0, 0, 0)
+LabEncoded = COLORW()
+RGB = COLORB()
+
+Lab.L = input("L?")
+Lab.a = input("a?")
+Lab.b = input("b?")
+
+# cmsFloat2LabEncoded(LabEncoded.w, Lab)
+
+
+#
+# Open profiles
+#
+
+hLab = cmsCreateLabProfile(None)
+hAdobe = cmsOpenProfileFromFile("AdobeRGB1998.icc", "r")
+
+#
+# The transform
+#
+
+xform = cmsCreateTransform(hLab, TYPE_Lab_DBL, hAdobe, TYPE_RGB_8, INTENT_PERCEPTUAL, cmsFLAGS_NOTPRECALC)
+
+cmsDoTransform(xform, Lab, RGB, 1)
+
+#
+# Print results
+#
+
+print Lab
+print "AdobeRGB = ", RGB[0], RGB[1], RGB[2]
+
+
+#
+# Free all stuff
+#
+
+cmsDeleteTransform(xform)
+cmsCloseProfile(hAdobe)
+cmsCloseProfile(hLab)
+
diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/sRGB2adobe.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/sRGB2adobe.py new file mode 100755 index 00000000..06c22f10 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/sRGB2adobe.py @@ -0,0 +1,51 @@ + +# +# Sample: Convert from sRGB to AdobeRGB, perceptual intent +# + +from lcms import * + + +print "Enter sRGB values" + +# +# Create placeholders +# + +RGB = COLORB() + +RGB[0] = input("R?") +RGB[1] = input("G?") +RGB[2] = input("B?") + + +# +# Open profiles +# + +hsRGB = cmsCreate_sRGBProfile() +hAdobe = cmsOpenProfileFromFile("AdobeRGB1998.icc", "r") + +# +# The transform +# + +xform = cmsCreateTransform(hsRGB, TYPE_RGB_8, hAdobe, TYPE_RGB_8, INTENT_PERCEPTUAL, cmsFLAGS_NOTPRECALC) + +cmsDoTransform(xform, RGB, RGB, 1) + +# +# Print results +# + +print "AdobeRGB = ", RGB[0], RGB[1], RGB[2] + + +# +# Free all stuff +# + +cmsDeleteTransform(xform) +cmsCloseProfile(hAdobe) +cmsCloseProfile(hsRGB) + diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/srgb2lab.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/srgb2lab.py new file mode 100755 index 00000000..f9d21652 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/srgb2lab.py @@ -0,0 +1,58 @@ +
+#
+# Sample: Convert from sRGB to Lab (D50), perceptual intent
+#
+
+from lcms import *
+
+
+print "Enter sRGB values, 0..255"
+
+#
+# Create placeholder for colorant
+#
+
+color = COLORB()
+color[0] = input("R?")
+color[1] = input("G?")
+color[2] = input("B?")
+
+
+#
+# Create placeholder for Lab
+#
+
+Lab = cmsCIELab()
+
+#
+# Open profiles (does use built-ins)
+#
+
+hsRGB = cmsCreate_sRGBProfile()
+hLab = cmsCreateLabProfile(None)
+
+#
+# The transform
+#
+
+xform = cmsCreateTransform(hsRGB, TYPE_RGB_8, hLab, TYPE_Lab_DBL, INTENT_PERCEPTUAL, cmsFLAGS_NOTPRECALC)
+
+
+cmsDoTransform(xform, color, Lab, 1)
+
+#
+# Print results
+#
+
+print "sRGB = ", color[0], color[1], color[2]
+print Lab
+
+
+#
+# Free all stuff
+#
+
+cmsDeleteTransform(xform)
+cmsCloseProfile(hLab)
+cmsCloseProfile(hsRGB)
+
diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/srgb2xyz.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/srgb2xyz.py new file mode 100755 index 00000000..e4dcb39c --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/srgb2xyz.py @@ -0,0 +1,62 @@ +
+#
+# Sample: Convert from sRGB to XYZ perceptual intent
+#
+
+from lcms import *
+
+
+print "Enter sRGB values, 0..255"
+
+#
+# Create placeholder for colorant
+#
+
+color = COLORB()
+color[0] = input("R?")
+color[1] = input("G?")
+color[2] = input("B?")
+
+
+#
+# Create placeholder for Lab
+#
+
+XYZ = cmsCIEXYZ()
+
+#
+# Open profiles (does use built-ins)
+#
+
+hsRGB = cmsCreate_sRGBProfile()
+hXYZ = cmsCreateXYZProfile()
+
+#
+# The transform
+#
+
+xform = cmsCreateTransform(hsRGB, TYPE_RGB_8, hXYZ, TYPE_XYZ_DBL, INTENT_PERCEPTUAL, cmsFLAGS_NOTPRECALC)
+
+
+cmsDoTransform(xform, color, XYZ, 1)
+
+#
+# Print results
+#
+
+print "sRGB = ", color[0], color[1], color[2]
+print XYZ
+
+xyY = cmsCIExyY(0, 0, 0)
+cmsXYZ2xyY(xyY, XYZ)
+
+print xyY
+
+#
+# Free all stuff
+#
+
+cmsDeleteTransform(xform)
+cmsCloseProfile(hXYZ)
+cmsCloseProfile(hsRGB)
+
diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/virtprf.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/virtprf.py new file mode 100755 index 00000000..c364bfba --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/virtprf.py @@ -0,0 +1,46 @@ +# +# Sample: Creates a virtual profile emulating sRGB +# + +from lcms import * + +#hsRGB = cmsOpenProfileFromFile("sRGB Color Space profile.icm", "r") + +Rec709Primaries = cmsCIExyYTRIPLE(cmsCIExyY(0.6400, 0.3300, 1.0), + cmsCIExyY(0.3000, 0.6000, 1.0), + cmsCIExyY(0.1500, 0.0600, 1.0)) + + +Gamma22 = GAMMATABLE(2.2, 4096) + +print Gamma22 + +D65 = cmsCIExyY() +cmsWhitePointFromTemp(6504, D65) + +hVirtual_sRGB = cmsCreateRGBProfile(D65, + Rec709Primaries, + (Gamma22, Gamma22, Gamma22)); + + +hsRGB = cmsCreate_sRGBProfile(); + +xform = cmsCreateTransform(hsRGB, TYPE_RGB_8, hVirtual_sRGB, TYPE_RGB_8, + INTENT_PERCEPTUAL, cmsFLAGS_NOTPRECALC) + +color = COLORB() +color[0] = 155 +color[1] = 45 +color[2] = 200 + + +print color[0], color[1], color[2] + +cmsDoTransform(xform, color, color, 1) + +print color[0], color[1], color[2] + +cmsDeleteTransform(xform) +cmsCloseProfile(hsRGB) +cmsCloseProfile(hVirtual_sRGB) + diff --git a/debian/lcms/lcms-1.19.dfsg2/python/testbed/whtpnt.py b/debian/lcms/lcms-1.19.dfsg2/python/testbed/whtpnt.py new file mode 100755 index 00000000..a4e8e5a8 --- /dev/null +++ b/debian/lcms/lcms-1.19.dfsg2/python/testbed/whtpnt.py @@ -0,0 +1,27 @@ + +# +# Sample: White point from temperature +# + +from lcms import * + + +Temp = input("Temperature §K? ") + +WhitexyY = cmsCIExyY(0, 0, 1) + +cmsWhitePointFromTemp(Temp, WhitexyY) + +WhiteXYZ = cmsCIEXYZ(0, 0, 0) +cmsxyY2XYZ(WhiteXYZ, WhitexyY) + +print WhitexyY +print WhiteXYZ + +Lab = cmsCIELab(0, 0, 0) + +cmsXYZ2Lab(None, Lab, WhiteXYZ) +print "D50", Lab + + + |
