diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-10 18:53:36 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-10 18:53:36 +0400 |
commit | ba8154e24a8565be692275ba23ed28f0891b7136 (patch) | |
tree | 95ae9e61d5a4a7713f46f952fab61dc3435efe72 /source/blender/compositor/operations/COM_KeyingDespillOperation.cpp | |
parent | 76ee9783a13ed9e1eb0d4415239ffebdab0a10b7 (diff) |
Keying screen: small fixes and improvements from tomato
- Fixed issues with calculating matte with balance != 0.5
It used to be used concave combination of minimal and maximal
channel values which could be inpredictable.
Use concave combination of two non-major channels sorted
by their index, so such combination would always use the same
coefficients for particular non-major channels.
- Added despill balance slider which defines balance between
non-major channels used for calculating average of two
colors. Difference between average value and pixel value of
major screen channel defines amount of despill. Balance of
0.5 gives the same behavior as it was before this slider
was added.
---
svn merge -r48678:48679 -r48789:48790 ^/branches/soc-2011-tomato
Diffstat (limited to 'source/blender/compositor/operations/COM_KeyingDespillOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_KeyingDespillOperation.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp index 081d9f723e8..9798ddcee94 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp @@ -47,6 +47,7 @@ KeyingDespillOperation::KeyingDespillOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->m_despillFactor = 0.5f; + this->m_colorBalance = 0.5f; this->m_pixelReader = NULL; this->m_screenReader = NULL; @@ -73,16 +74,22 @@ void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelS this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers); int screen_primary_channel = get_pixel_primary_channel(screenColor); + int other_1 = (screen_primary_channel + 1) % 3; + int other_2 = (screen_primary_channel + 2) % 3; + + int min_channel = MIN2(other_1, other_2); + int max_channel = MAX2(other_1, other_2); + float average_value, amount; - average_value = (pixelColor[0] + pixelColor[1] + pixelColor[2] - pixelColor[screen_primary_channel]) / 2.0f; - amount = pixelColor[screen_primary_channel] - average_value; + average_value = this->m_colorBalance * pixelColor[min_channel] + (1.0f - this->m_colorBalance) * pixelColor[max_channel]; + amount = (pixelColor[screen_primary_channel] - average_value); color[0] = pixelColor[0]; color[1] = pixelColor[1]; color[2] = pixelColor[2]; color[3] = pixelColor[3]; - + if (this->m_despillFactor * amount > 0) { color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->m_despillFactor * amount; } |