[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49358] branches/soc-2011-tomato/source/ blender: == compositor ==
Peter Schlaile
peter at schlaile.de
Sun Jul 29 17:48:38 CEST 2012
Revision: 49358
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49358
Author: schlaile
Date: 2012-07-29 15:48:38 +0000 (Sun, 29 Jul 2012)
Log Message:
-----------
== compositor ==
This adds an inpaint node to blender.
In case, you don't know, inpainting does this:
http://en.wikipedia.org/wiki/Inpainting
It's use cases in blender are
* wire removal
* green screen background reconstruction
The node isn't tile based (for fundamental reasons), but very fast,
since it first builds a manhatten distance map and after that performs
color convolution only on the edges.
That's something, one should probably add also to the dilate node (in
step mode) to make it perform a lot better for dilate iterations greater
than 3.
It will bring it's computing time from O(n^3) down to O(n^2).
Take a look here for the details:
http://ostermiller.org/dilate_and_erode.html )
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
branches/soc-2011-tomato/source/blender/blenkernel/SConscript
branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt
branches/soc-2011-tomato/source/blender/compositor/intern/COM_Converter.cpp
branches/soc-2011-tomato/source/blender/editors/space_node/drawnode.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_node_types.h
branches/soc-2011-tomato/source/blender/makesrna/RNA_access.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_nodetree_types.h
branches/soc-2011-tomato/source/blender/nodes/CMakeLists.txt
branches/soc-2011-tomato/source/blender/nodes/NOD_composite.h
Added Paths:
-----------
branches/soc-2011-tomato/source/blender/compositor/nodes/COM_InpaintNode.cpp
branches/soc-2011-tomato/source/blender/compositor/nodes/COM_InpaintNode.h
branches/soc-2011-tomato/source/blender/compositor/operations/COM_InpaintOperation.cpp
branches/soc-2011-tomato/source/blender/compositor/operations/COM_InpaintOperation.h
branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_inpaint.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h 2012-07-29 15:06:50 UTC (rev 49357)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h 2012-07-29 15:48:38 UTC (rev 49358)
@@ -661,6 +661,7 @@
#define CMP_NODE_KEYINGSCREEN 269
#define CMP_NODE_KEYING 270
#define CMP_NODE_TRACKPOS 271
+#define CMP_NODE_INPAINT 272
#define CMP_NODE_GLARE 301
#define CMP_NODE_TONEMAP 302
Modified: branches/soc-2011-tomato/source/blender/blenkernel/SConscript
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/SConscript 2012-07-29 15:06:50 UTC (rev 49357)
+++ branches/soc-2011-tomato/source/blender/blenkernel/SConscript 2012-07-29 15:48:38 UTC (rev 49358)
@@ -3,7 +3,11 @@
import os
sources = env.Glob('intern/*.c')
+sources.remove('intern' + os.sep + 'mask_rasterize.c')
+sources.remove('intern' + os.sep + 'mask.c')
+sources_mask = env.Glob('intern/mask*.c')
+
incs = '. #/intern/guardedalloc #/intern/memutil'
incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager'
incs += ' ../render/extern/include #/intern/decimation/extern ../makesrna'
@@ -117,7 +121,10 @@
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs += ' ' + env['BF_PTHREADS_INC']
+
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25]) #, cc_compileflags = env['CCFLAGS'].append('/WX') )
else:
env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [166,25,0] )
+
+env.BlenderLib ( libname = 'bf_blenkernel_mask', sources = sources_mask, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [200,25,0] )
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c 2012-07-29 15:06:50 UTC (rev 49357)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c 2012-07-29 15:48:38 UTC (rev 49358)
@@ -1892,6 +1892,7 @@
register_node_type_cmp_bilateralblur(ttype);
register_node_type_cmp_vecblur(ttype);
register_node_type_cmp_dilateerode(ttype);
+ register_node_type_cmp_inpaint(ttype);
register_node_type_cmp_defocus(ttype);
register_node_type_cmp_valtorgb(ttype);
Modified: branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt 2012-07-29 15:06:50 UTC (rev 49357)
+++ branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt 2012-07-29 15:48:38 UTC (rev 49358)
@@ -286,6 +286,8 @@
nodes/COM_FilterNode.h
nodes/COM_DilateErodeNode.cpp
nodes/COM_DilateErodeNode.h
+ nodes/COM_InpaintNode.cpp
+ nodes/COM_InpaintNode.h
nodes/COM_BlurNode.cpp
nodes/COM_BlurNode.h
nodes/COM_BokehBlurNode.cpp
@@ -590,6 +592,8 @@
operations/COM_ConvolutionEdgeFilterOperation.cpp
operations/COM_DilateErodeOperation.cpp
operations/COM_DilateErodeOperation.h
+ operations/COM_InpaintOperation.cpp
+ operations/COM_InpaintOperation.h
operations/COM_GlareThresholdOperation.cpp
operations/COM_GlareThresholdOperation.h
operations/COM_GlareBaseOperation.cpp
Modified: branches/soc-2011-tomato/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/intern/COM_Converter.cpp 2012-07-29 15:06:50 UTC (rev 49357)
+++ branches/soc-2011-tomato/source/blender/compositor/intern/COM_Converter.cpp 2012-07-29 15:48:38 UTC (rev 49358)
@@ -74,6 +74,7 @@
#include "COM_HueSaturationValueNode.h"
#include "COM_IDMaskNode.h"
#include "COM_ImageNode.h"
+#include "COM_InpaintNode.h"
#include "COM_InvertNode.h"
#include "COM_KeyingNode.h"
#include "COM_KeyingScreenNode.h"
@@ -303,6 +304,9 @@
case CMP_NODE_DILATEERODE:
node = new DilateErodeNode(b_node);
break;
+ case CMP_NODE_INPAINT:
+ node = new InpaintNode(b_node);
+ break;
case CMP_NODE_LENSDIST:
node = new LensDistortionNode(b_node);
break;
Added: branches/soc-2011-tomato/source/blender/compositor/nodes/COM_InpaintNode.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/nodes/COM_InpaintNode.cpp (rev 0)
+++ branches/soc-2011-tomato/source/blender/compositor/nodes/COM_InpaintNode.cpp 2012-07-29 15:48:38 UTC (rev 49358)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor: Peter Schlaile
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_InpaintNode.h"
+#include "DNA_scene_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_InpaintOperation.h"
+#include "BLI_math.h"
+
+InpaintNode::InpaintNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
+
+void InpaintNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+
+ bNode *editorNode = this->getbNode();
+
+ /* if (editorNode->custom1 == CMP_NODE_INPAINT_SIMPLE) { */
+ if (true) {
+ InpaintSimpleOperation *operation = new InpaintSimpleOperation();
+ operation->setbNode(editorNode);
+ operation->setIterations(editorNode->custom2);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+}
Added: branches/soc-2011-tomato/source/blender/compositor/nodes/COM_InpaintNode.h
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/nodes/COM_InpaintNode.h (rev 0)
+++ branches/soc-2011-tomato/source/blender/compositor/nodes/COM_InpaintNode.h 2012-07-29 15:48:38 UTC (rev 49358)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor: Peter Schlaile
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_InpaintNode_h_
+#define _COM_InpaintNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief InpaintNode
+ * @ingroup Node
+ */
+class InpaintNode : public Node {
+public:
+ InpaintNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif
Added: branches/soc-2011-tomato/source/blender/compositor/operations/COM_InpaintOperation.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_InpaintOperation.cpp (rev 0)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_InpaintOperation.cpp 2012-07-29 15:48:38 UTC (rev 49358)
@@ -0,0 +1,278 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor: Peter Schlaile
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_InpaintOperation.h"
+#include "BLI_math.h"
+#include "COM_OpenCLDevice.h"
+
+// Inpaint (simple convolve using average of known pixels)
+InpaintSimpleOperation::InpaintSimpleOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->m_inputImageProgram = NULL;
+ this->pixelorder = NULL;
+ this->manhatten_distance = NULL;
+ this->m_cached_buffer = NULL;
+ this->cached_buffer_ready = false;
+}
+void InpaintSimpleOperation::initExecution()
+{
+ this->m_inputImageProgram = this->getInputSocketReader(0);
+
+ this->m_cached_buffer = NULL;
+ this->pixelorder = NULL;
+ this->manhatten_distance = NULL;
+ this->m_cached_buffer = NULL;
+ this->cached_buffer_ready = false;
+
+ this->initMutex();
+}
+
+void InpaintSimpleOperation::clamp_xy(int & x, int & y)
+{
+ int width = this->getWidth();
+ int height = this->getHeight();
+
+ if (x < 0) {
+ x = 0;
+ }
+ if (x >= width) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list