[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50124] branches/soc-2011-tomato/source/ blender: despeckle node for tomato only

Campbell Barton ideasman42 at gmail.com
Wed Aug 22 17:08:42 CEST 2012


Revision: 50124
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50124
Author:   campbellbarton
Date:     2012-08-22 15:08:41 +0000 (Wed, 22 Aug 2012)
Log Message:
-----------
despeckle node for tomato only

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
    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/COM_defines.h
    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/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_DespeckleNode.cpp
    branches/soc-2011-tomato/source/blender/compositor/nodes/COM_DespeckleNode.h
    branches/soc-2011-tomato/source/blender/compositor/operations/COM_DespeckleOperation.cpp
    branches/soc-2011-tomato/source/blender/compositor/operations/COM_DespeckleOperation.h
    branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_despeckle.c

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h	2012-08-22 15:04:11 UTC (rev 50123)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_node.h	2012-08-22 15:08:41 UTC (rev 50124)
@@ -680,7 +680,8 @@
 #define CMP_NODE_KEYINGSCREEN		269
 #define CMP_NODE_KEYING			270
 #define CMP_NODE_TRACKPOS		271
-#define CMP_NODE_INPAINT                272
+#define CMP_NODE_INPAINT    272
+#define CMP_NODE_DESPECKLE  273
 
 #define CMP_NODE_GLARE		301
 #define CMP_NODE_TONEMAP	302

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c	2012-08-22 15:04:11 UTC (rev 50123)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/node.c	2012-08-22 15:08:41 UTC (rev 50124)
@@ -2139,6 +2139,7 @@
 	register_node_type_cmp_vecblur(ttype);
 	register_node_type_cmp_dilateerode(ttype);
 	register_node_type_cmp_inpaint(ttype);
+	register_node_type_cmp_despeckle(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-08-22 15:04:11 UTC (rev 50123)
+++ branches/soc-2011-tomato/source/blender/compositor/CMakeLists.txt	2012-08-22 15:08:41 UTC (rev 50124)
@@ -284,6 +284,8 @@
 
 	nodes/COM_FilterNode.cpp
 	nodes/COM_FilterNode.h
+	nodes/COM_DespeckleNode.cpp
+	nodes/COM_DespeckleNode.h
 	nodes/COM_DilateErodeNode.cpp
 	nodes/COM_DilateErodeNode.h
 	nodes/COM_InpaintNode.cpp
@@ -592,6 +594,8 @@
 	operations/COM_ConvolutionFilterOperation.cpp
 	operations/COM_ConvolutionEdgeFilterOperation.h
 	operations/COM_ConvolutionEdgeFilterOperation.cpp
+	operations/COM_DespeckleOperation.cpp
+	operations/COM_DespeckleOperation.h
 	operations/COM_DilateErodeOperation.cpp
 	operations/COM_DilateErodeOperation.h
 	operations/COM_InpaintOperation.cpp

Modified: branches/soc-2011-tomato/source/blender/compositor/COM_defines.h
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/COM_defines.h	2012-08-22 15:04:11 UTC (rev 50123)
+++ branches/soc-2011-tomato/source/blender/compositor/COM_defines.h	2012-08-22 15:08:41 UTC (rev 50124)
@@ -84,7 +84,7 @@
 /**
  * COM_CURRENT_THREADING_MODEL can be one of the above, COM_TM_QUEUE is currently default.
  */
-#define COM_CURRENT_THREADING_MODEL COM_TM_QUEUE
+#define COM_CURRENT_THREADING_MODEL COM_TM_NOTHREAD
 // chunk order
 /**
  * @brief The order of chunks to be scheduled

Modified: branches/soc-2011-tomato/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/intern/COM_Converter.cpp	2012-08-22 15:04:11 UTC (rev 50123)
+++ branches/soc-2011-tomato/source/blender/compositor/intern/COM_Converter.cpp	2012-08-22 15:08:41 UTC (rev 50124)
@@ -56,6 +56,7 @@
 #include "COM_Converter.h"
 #include "COM_CropNode.h"
 #include "COM_DefocusNode.h"
+#include "COM_DespeckleNode.h"
 #include "COM_DifferenceMatteNode.h"
 #include "COM_DilateErodeNode.h"
 #include "COM_DirectionalBlurNode.h"
@@ -307,6 +308,9 @@
 		case CMP_NODE_INPAINT:
 			node = new InpaintNode(b_node);
 			break;
+		case CMP_NODE_DESPECKLE:
+			node = new DespeckleNode(b_node);
+			break;
 		case CMP_NODE_LENSDIST:
 			node = new LensDistortionNode(b_node);
 			break;

Added: branches/soc-2011-tomato/source/blender/compositor/nodes/COM_DespeckleNode.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/nodes/COM_DespeckleNode.cpp	                        (rev 0)
+++ branches/soc-2011-tomato/source/blender/compositor/nodes/COM_DespeckleNode.cpp	2012-08-22 15:08:41 UTC (rev 50124)
@@ -0,0 +1,50 @@
+/*
+ * 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: Campbell Barton
+ */
+
+#include "COM_DespeckleNode.h"
+#include "DNA_scene_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_DespeckleOperation.h"
+#include "BLI_math.h"
+
+DespeckleNode::DespeckleNode(bNode *editorNode) : Node(editorNode)
+{
+	/* pass */
+}
+
+void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+	bNode *editorNode = this->getbNode();
+	InputSocket *inputSocket = this->getInputSocket(0);
+	InputSocket *inputImageSocket = this->getInputSocket(1);
+	OutputSocket *outputSocket = this->getOutputSocket(0);
+	DespeckleOperation *operation = new DespeckleOperation();
+
+	operation->setbNode(editorNode);
+	operation->setThreshold(editorNode->custom3);
+	operation->setThresholdNeighbour(editorNode->custom4);
+
+	inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
+	inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph);
+	outputSocket->relinkConnections(operation->getOutputSocket());
+	addPreviewOperation(graph, operation->getOutputSocket(0));
+
+	graph->addOperation(operation);
+}

Added: branches/soc-2011-tomato/source/blender/compositor/nodes/COM_DespeckleNode.h
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/nodes/COM_DespeckleNode.h	                        (rev 0)
+++ branches/soc-2011-tomato/source/blender/compositor/nodes/COM_DespeckleNode.h	2012-08-22 15:08:41 UTC (rev 50124)
@@ -0,0 +1,36 @@
+/*
+ * 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: Campbell Barton
+ */
+
+#ifndef _COM_DespeckleNode_h_
+#define _COM_DespeckleNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief DespeckleNode
+ * @ingroup Node
+ */
+class DespeckleNode : public Node {
+public:
+	DespeckleNode(bNode *editorNode);
+	void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif

Added: branches/soc-2011-tomato/source/blender/compositor/operations/COM_DespeckleOperation.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_DespeckleOperation.cpp	                        (rev 0)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_DespeckleOperation.cpp	2012-08-22 15:08:41 UTC (rev 50124)
@@ -0,0 +1,139 @@
+/*
+ * 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: Campbell Barton
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "COM_DespeckleOperation.h"
+
+#include "BLI_utildefines.h"
+
+DespeckleOperation::DespeckleOperation() : NodeOperation()
+{
+	this->addInputSocket(COM_DT_COLOR);
+	this->addInputSocket(COM_DT_VALUE);
+	this->addOutputSocket(COM_DT_COLOR);
+	this->setResolutionInputSocketIndex(0);
+	this->m_inputOperation = NULL;
+	this->setComplex(true);
+}
+void DespeckleOperation::initExecution()
+{
+	this->m_inputOperation = this->getInputSocketReader(0);
+	this->m_inputValueOperation = this->getInputSocketReader(1);
+}
+
+void DespeckleOperation::deinitExecution()
+{
+	this->m_inputOperation = NULL;
+	this->m_inputValueOperation = NULL;
+}
+
+BLI_INLINE int color_diff(const float a[3], const float b[3], const float threshold)
+{
+	return ((fabsf(a[0] - b[0]) > threshold) ||
+	        (fabsf(a[1] - b[1]) > threshold) ||
+	        (fabsf(a[2] - b[2]) > threshold));
+}
+
+void DespeckleOperation::executePixel(float output[4], int x, int y, void *data)
+{
+	float w = 0.0f;
+	float color_org[4];
+	float color_mid[4];
+	float color_mid_ok[4];
+	float in1[4];
+	int x1 = x - 1;
+	int x2 = x;
+	int x3 = x + 1;
+	int y1 = y - 1;
+	int y2 = y;
+	int y3 = y + 1;
+	CLAMP(x1, 0, getWidth() - 1);
+	CLAMP(x2, 0, getWidth() - 1);
+	CLAMP(x3, 0, getWidth() - 1);
+	CLAMP(y1, 0, getHeight() - 1);
+	CLAMP(y2, 0, getHeight() - 1);
+	CLAMP(y3, 0, getHeight() - 1);
+	float value[4];
+	this->m_inputValueOperation->read(value, x2, y2, NULL);
+	//const float mval = 1.0f - value[0];
+
+
+	this->m_inputOperation->read(color_org, x2, y2, NULL);
+
+#define TOT_DIV_ONE 1.0
+#define TOT_DIV_CNR M_SQRT1_2
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list