[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3991] trunk/py/scripts/addons: Adding Film Response addon from mango.

Daniel Salazar zanqdo at gmail.com
Tue Nov 20 22:46:51 CET 2012


Revision: 3991
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3991
Author:   zanqdo
Date:     2012-11-20 21:46:50 +0000 (Tue, 20 Nov 2012)
Log Message:
-----------
Adding Film Response addon from mango. This addon will generate the corresponding look up table from a specific film response to the active RGB curves compositor node

Added Paths:
-----------
    trunk/py/scripts/addons/compositing_film_response/
    trunk/py/scripts/addons/compositing_film_response/__init__.py
    trunk/py/scripts/addons/compositing_film_response/film_response_curves.py

Added: trunk/py/scripts/addons/compositing_film_response/__init__.py
===================================================================
--- trunk/py/scripts/addons/compositing_film_response/__init__.py	                        (rev 0)
+++ trunk/py/scripts/addons/compositing_film_response/__init__.py	2012-11-20 21:46:50 UTC (rev 3991)
@@ -0,0 +1,199 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+bl_info = {
+    "name": "Film Response Curves",
+    "author": "Brecht Van Lommel",
+    "version": (0, 1),
+    "blender": (2, 6, 3),
+    "location": "Node Editor > Panels > Film Response",
+    "description": "Apply film response preset to RGB Curves node",
+    "warning": "",
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"\
+        "Scripts/Render/Film_Response",
+    "tracker_url": "https://projects.blender.org/tracker/index.php?"\
+        "func=detail&aid=33246",
+    "support": 'OFFICIAL',
+    "category": "Compositing"}
+
+import bpy
+import math
+
+def srgb_to_linearrgb(c):
+    if c < 0.04045:
+        if c < 0.0:
+            return 0.0
+        else:
+            return c * (1.0 / 12.92)
+    else:
+        return math.pow((c + 0.055) * (1.0 / 1.055), 2.4)
+
+def apply_curve_table(curve, table):
+    num = len(table)
+    
+    while len(curve.points) > 2:
+        curve.points.remove(curve.points[0])
+    
+    curve.points[0].location = (0.0, srgb_to_linearrgb(table[0]))
+    curve.points[-1].location = (1.0, srgb_to_linearrgb(table[-1]))
+    
+    for i in range(1, num-1, 5):
+        x = i/(num-1)
+        y = srgb_to_linearrgb(table[i])
+        
+        curve.points.new(x, y)        
+
+def apply_curvemapping(node, response_name):
+    from . import film_response_curves
+    
+    Rcurve, Gcurve, Bcurve = node.mapping.curves[0:3]
+    
+    for FR in film_response_curves.FILM_RESPONSE:
+        brand, name, log, isrgb, I_R, B_R, I_G, B_G, I_B, B_B = FR
+        
+        if name == response_name:            
+            apply_curve_table(Rcurve, B_R)
+            
+            if isrgb:
+                apply_curve_table(Gcurve, B_G)
+                apply_curve_table(Bcurve, B_B)
+            else:
+                apply_curve_table(Gcurve, B_R)
+                apply_curve_table(Bcurve, B_R)
+            
+            node.mapping.update()
+            node.inputs[0].default_value = node.inputs[0].default_value
+        
+#ntree = bpy.context.scene.node_tree
+#node = ntree.nodes["RGB Curves"]
+
+response_curve_items = (
+("", "Agfa", ""),
+("Agfacolor Futura 100", "Futura 100", ""),
+("Agfacolor Futura 200", "Futura 200", ""),
+("Agfacolor Futura 400", "Futura 400", ""),
+("Agfacolor Futura II 100", "Futura II 100", ""),
+("Agfacolor Futura II 200", "Futura II 200", ""),
+("Agfacolor Futura II 400", "Futura II 400", ""),
+("Agfacolor HDC 100 plus", "HDC 100 plus", ""),
+("Agfacolor HDC 400 plus", "HDC 400 plus", ""),
+("Agfacolor HDC 200 plus", "HDC 200 plus", ""),
+("Agfacolor Optima II 100", "Optima II 100", ""),
+("Agfacolor Optima II 200", "Optima II 200", ""),
+("Agfacolor Ultra 050", "Ultra 050", ""),
+("", "Agfa", ""),
+("Agfacolor Vista 100", "Vista 100", ""),
+("Agfacolor Vista 200", "Vista 200", ""),
+("Agfacolor Vista 400", "Vista 400", ""),
+("Agfacolor Vista 800", "Vista 800", ""),
+("Agfachrome CT Precisa 100", "CT Precisa 100", ""),
+("Agfachrome CT Precisa 200", "CT Precisa 200", ""),
+("Agfachrome RSX2 050", "Agfachrome RSX2 050", ""),
+("Agfachrome RSX2 100", "Agfachrome RSX2 100", ""),
+("Agfachrome RSX2 200", "Agfachrome RSX2 200", ""),
+("Advantix 100", "Advantix 100", ""),
+("Advantix 200", "Advantix 200", ""),
+("Advantix 400", "Advantix 400", ""),
+("", "Kodak", ""),
+("Gold 100", "Gold 100", ""),
+("Gold 200", "Gold 200", ""),
+("Max Zoom 800", "Max Zoom 800", ""),
+("Portra 100T", "Portra 100T", ""),
+("Portra 160NC", "Portra 160NC", ""),
+("Portra 160VC", "Portra 160VC", ""),
+("Portra 800", "Portra 800", ""),
+("Portra 400VC", "Portra 400VC", ""),
+("Portra 400NC", "Portra 400NC", ""),
+("", "Kodak", ""),
+("Ektachrome 100 plus", "Ektachrome 100 plus", ""),
+("Ektachrome 320T", "Ektachrome 320T", ""),
+("Ektachrome 400X", "Ektachrome 400X", ""),
+("Ektachrome 64", "Ektachrome 64", ""),
+("Ektachrome 64T", "Ektachrome 64T", ""),
+("Ektachrome E100S", "Ektachrome E100S", ""),
+("Ektachrome 100", "Ektachrome 100", ""),
+("Kodachrome 200", "Kodachrome 200", ""),
+("Kodachrome 25", "Kodachrome 25", ""),
+("Kodachrome 64", "Kodachrome 64", ""),
+("", "Fujifilm", ""),
+("F-125", "F-125", ""),
+("F-250", "F-250", ""),
+("F-400", "F-400", ""),
+("FCI", "FCI", ""),
+("FP2900Z", "FP2900Z", ""),
+("", "Eastman", ""),
+("Double X Neg 12min", "Double X Neg 12min", ""),
+("Double X Neg 6min", "Double X Neg 6min", ""),
+("Double X Neg 5min", "Double X Neg 5min", ""),
+("Double X Neg 4min", "Double X Neg 4min", ""),
+("", "Canon", ""),
+("Optura 981111", "Optura 981111", ""),
+("Optura 981113", "Optura 981113", ""),
+("Optura 981114", "Optura 981114", ""),
+("Optura 981111.SLRR", "Optura 981111.SLRR", "")
+)
+
+def film_response_update(self, context):
+    bpy.ops.node.film_response()
+
+bpy.types.Scene.mango_response_curve = bpy.props.EnumProperty(name="Response Curve", description="Measured camera film response",
+        items=response_curve_items, default="Advantix 400", update=film_response_update)
+
+class FilmResponseOperator(bpy.types.Operator):
+    '''Set film response preset on active RGB Curves node'''
+    bl_idname = "node.film_response"
+    bl_label = "Set Film Response"
+
+    @classmethod
+    def poll(cls, context):
+        node = context.active_node
+        return node and node.type == 'CURVE_RGB'
+
+    def execute(self, context):
+        node = context.active_node
+        apply_curvemapping(node, context.scene.mango_response_curve)
+        return {'FINISHED'}
+
+class NODE_PT_film_response(bpy.types.Panel):
+    bl_space_type = 'NODE_EDITOR'
+    bl_region_type = 'UI'
+    bl_label = "Film Response"
+
+    @classmethod
+    def poll(cls, context):
+        node = context.active_node
+        return node and node.type == 'CURVE_RGB'
+
+    def draw(self, context):
+        layout = self.layout
+        
+        layout.prop(context.scene, "mango_response_curve", text="")
+
+def register():
+    bpy.utils.register_class(FilmResponseOperator)
+    bpy.utils.register_class(NODE_PT_film_response)
+
+def unregister():
+    bpy.utils.unregister_class(FilmResponseOperator)
+    bpy.utils.unregister_class(NODE_PT_film_response)
+
+if __name__ == "__main__":
+    register()
+    

Added: trunk/py/scripts/addons/compositing_film_response/film_response_curves.py
===================================================================
--- trunk/py/scripts/addons/compositing_film_response/film_response_curves.py	                        (rev 0)
+++ trunk/py/scripts/addons/compositing_film_response/film_response_curves.py	2012-11-20 21:46:50 UTC (rev 3991)
@@ -0,0 +1,36129 @@
+#
+# "What is the Space of Camera Response Functions?," 
+# M.D. Grossberg and S.K. Nayar, 
+# IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 
+# Vol.II, pp.602-609, Jun, 2003.
+#
+# http://www.cs.columbia.edu/CAVE/software/softlib/dorf.php
+#
+
+FILM_RESPONSE = (
+("Agfa", "Agfacolor Futura 100", "graph-log-log-neg", True,
+(0.000000e+000, 9.775171e-004, 1.955034e-003, 2.932551e-003, 3.910068e-003, 4.887586e-003, 5.865103e-003, 6.842620e-003, 7.820137e-003, 8.797654e-003,
+9.775171e-003, 1.075269e-002, 1.173021e-002, 1.270772e-002, 1.368524e-002, 1.466276e-002, 1.564027e-002, 1.661779e-002, 1.759531e-002, 1.857283e-002,
+1.955034e-002, 2.052786e-002, 2.150538e-002, 2.248289e-002, 2.346041e-002, 2.443793e-002, 2.541544e-002, 2.639296e-002, 2.737048e-002, 2.834800e-002,
+2.932551e-002, 3.030303e-002, 3.128055e-002, 3.225806e-002, 3.323558e-002, 3.421310e-002, 3.519062e-002, 3.616813e-002, 3.714565e-002, 3.812317e-002,
+3.910068e-002, 4.007820e-002, 4.105572e-002, 4.203324e-002, 4.301075e-002, 4.398827e-002, 4.496579e-002, 4.594330e-002, 4.692082e-002, 4.789834e-002,
+4.887586e-002, 4.985337e-002, 5.083089e-002, 5.180841e-002, 5.278592e-002, 5.376344e-002, 5.474096e-002, 5.571848e-002, 5.669599e-002, 5.767351e-002,
+5.865103e-002, 5.962854e-002, 6.060606e-002, 6.158358e-002, 6.256109e-002, 6.353861e-002, 6.451613e-002, 6.549365e-002, 6.647116e-002, 6.744868e-002,
+6.842620e-002, 6.940371e-002, 7.038123e-002, 7.135875e-002, 7.233627e-002, 7.331378e-002, 7.429130e-002, 7.526882e-002, 7.624633e-002, 7.722385e-002,
+7.820137e-002, 7.917889e-002, 8.015640e-002, 8.113392e-002, 8.211144e-002, 8.308895e-002, 8.406647e-002, 8.504399e-002, 8.602151e-002, 8.699902e-002,
+8.797654e-002, 8.895406e-002, 8.993157e-002, 9.090909e-002, 9.188661e-002, 9.286413e-002, 9.384164e-002, 9.481916e-002, 9.579668e-002, 9.677419e-002,
+9.775171e-002, 9.872923e-002, 9.970674e-002, 1.006843e-001, 1.016618e-001, 1.026393e-001, 1.036168e-001, 1.045943e-001, 1.055718e-001, 1.065494e-001,
+1.075269e-001, 1.085044e-001, 1.094819e-001, 1.104594e-001, 1.114370e-001, 1.124145e-001, 1.133920e-001, 1.143695e-001, 1.153470e-001, 1.163245e-001,
+1.173021e-001, 1.182796e-001, 1.192571e-001, 1.202346e-001, 1.212121e-001, 1.221896e-001, 1.231672e-001, 1.241447e-001, 1.251222e-001, 1.260997e-001,
+1.270772e-001, 1.280547e-001, 1.290323e-001, 1.300098e-001, 1.309873e-001, 1.319648e-001, 1.329423e-001, 1.339198e-001, 1.348974e-001, 1.358749e-001,
+1.368524e-001, 1.378299e-001, 1.388074e-001, 1.397849e-001, 1.407625e-001, 1.417400e-001, 1.427175e-001, 1.436950e-001, 1.446725e-001, 1.456500e-001,

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list