diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-06-25 12:21:55 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-06-25 12:21:55 +0400 |
commit | 44c82198d4852484493c2e33b3ca4ad67fd76fd8 (patch) | |
tree | 4bf2bc23d6034647e0006dfb0c0d2f25f0eb951c /source/blender/compositor/nodes | |
parent | 15cb064e1b853a56fc676db1c2869db47657d91a (diff) |
Optimization of Keying Blur operation
Separate X and Y passes of blurring like it's done for flat
gaussian blur. This reduces computing difficulty from size^2
to 2*size without any visual changes in matte.
Diffstat (limited to 'source/blender/compositor/nodes')
-rw-r--r-- | source/blender/compositor/nodes/COM_KeyingNode.cpp | 37 | ||||
-rw-r--r-- | source/blender/compositor/nodes/COM_KeyingNode.h | 2 |
2 files changed, 27 insertions, 12 deletions
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp index 13488cc520b..d81092f21d7 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp @@ -66,13 +66,21 @@ OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inpu addLink(graph, separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); } else { - KeyingBlurOperation *blurOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); - blurOperation->setSize(size); + blurXOperation->setSize(size); + blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); - addLink(graph, separateOperation->getOutputSocket(0), blurOperation->getInputSocket(0)); - addLink(graph, blurOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); - graph->addOperation(blurOperation); + blurYOperation->setSize(size); + blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); + + addLink(graph, separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0)); + addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); + addLink(graph, blurYOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); + + graph->addOperation(blurXOperation); + graph->addOperation(blurYOperation); } } @@ -86,17 +94,24 @@ OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inpu return convertYCCToRGBOperation->getOutputSocket(0); } -OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size) +OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBlurInput, int size) { - KeyingBlurOperation *blurOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); + + blurXOperation->setSize(size); + blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); - blurOperation->setSize(size); + blurYOperation->setSize(size); + blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); - addLink(graph, postBLurInput, blurOperation->getInputSocket(0)); + addLink(graph, postBlurInput, blurXOperation->getInputSocket(0)); + addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); - graph->addOperation(blurOperation); + graph->addOperation(blurXOperation); + graph->addOperation(blurYOperation); - return blurOperation->getOutputSocket(); + return blurYOperation->getOutputSocket(); } OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance) diff --git a/source/blender/compositor/nodes/COM_KeyingNode.h b/source/blender/compositor/nodes/COM_KeyingNode.h index cc1d447c66e..17436a32353 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.h +++ b/source/blender/compositor/nodes/COM_KeyingNode.h @@ -30,7 +30,7 @@ class KeyingNode : public Node { protected: OutputSocket *setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage); - OutputSocket *setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size); + OutputSocket *setupPostBlur(ExecutionSystem *graph, OutputSocket *postBlurInput, int size); OutputSocket *setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance); OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen, float factor); OutputSocket *setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance, |