Despill and Edge Blending with GW_Despill (V1.00)
Updated: Aug 17, 2021
Hey, there, my pixel wizarding friends!!
This post is intended to accompany the video on youtube which describes my new despill tool. (Below..)
You can Grab the tool here -->
(Nukepedia link for tool ---> http://www.nukepedia.com/gizmos/keyer/gw_despill_v1 )
The sections below describe the tool and how it works:
About Despill ... (in general)
I won't go into much detail about how despill algorithms work because it has already been done (and by people smarter and more eloquent than I am). Instead; below is a link to an excellent article by Ben McEwan (benmcewan.com) about how despill works:
"Despilling is arguably the most important step to get right when pulling a key. A great despill can often hide imperfections in your alpha channel & prevents the tedious painting from fixing edges manually. You’re already aware that keyers like Keylight, Primatte, IBK, etc., despill your image, but what happens if their results are coming up short? It’s worth your time to dig into some maths & understand how despill algorithms work, and how you can implement them using the Expression node in Nuke." READ MORE...
About the tool (gw_despill_v1.00)...
I should be clear in saying that this is not an original idea of any sort... I took inspiration for the tool after watching a Youtube video from CompLair where there was a tech challenge to create a despill gizmo using only Nuke native nodes.. this inspired me to make my spin on a version of the tool.
The Link to the video is below for reference and is definitely worth a watch!
What does the tool do?
The purpose or use-case for the tool is to help with both Despill and Despill edge-blending when keying.
The tool uses a keylight to remove the spill and then essentially separates the areas of the image which have spill.
You can then choose how to use this "spill-map" to help blend the keyed image with the intended background image.
The tool does this by separating the spill so that you can "inject" either a solid colour, extended edge or the actual intended BG image into the spill area before adding this back to the source image.
Usually, it's a common practice technique to use keylight for despill, then to minus this from the original image, which gives you the original luminance (or spill map), which you desaturate then plus this back over to restore luminance lost in the despill process.
My tool takes this a few steps further and allows for additional operations on the "spill map" before putting it back over the image so that the edges can blend better. (It allows for the straightforward putting back of original luminance if that's what you need, though!) :)
if we jump inside the group, you can see that the "core" of the tool revolves around the keylight node.
..It's from the Keylight that we extract the "Spill Map", which is just the difference between the original image and the keylight despill.
Once we have this "spill map", we can look to manipulate it in some ways...
A) Desaturate it and put it back (Plus) into the main plate --> this restores the original Luminance.
B) Add Solid Colour to the spill (Changing spill colour and luminance) Then put it back (Plus) onto the main plate (only in spill areas):
C) Extend Edges (Basic Edge Blur Technique <Premult+Blur+Unpremult+Blur>) then put it back (Plus) onto the main plate (only in spill areas):
D) Extend Edges *IBK Version* (IBK using clean plate input then unpremultiply) then put it back (Plus) onto the main plate (only in spill areas). This is the only method inside of the group that does not use keylight to start with. *Keylight is still used for the despill though and to create "spill map"* We have a couple of extra controls here as sometimes there are artefacts caused by IBK.. These are easily controlled with saturation and by adjusting alpha, however.
E) Replace spill with the Background (BG) image, then put it back (Plus) onto the main plate (only in spill areas). Here we are taking the actual BG plate as an input and placing the actual BG pixels into the spill areas so that edges should blend perfectly (or close to) with the BG once this is "cut" by the alpha. For this method, I took inspiration from Steve Wright's adaptive despill techniques and applied them here in a more simple and reliable way because it can be placed straight into the spill areas without first needing to mess with or offsetting the BG.
I have tried to make the tool as easy to use as I can with my limited knowledge of python.
The tool is laid out in logical order from top to bottom for the most part in the order that you would use the controls.
At the very top is the colour selector. this is where and when you choose the colour of the green/blue screen which you want to despill (in other words: this is where you would select the colour of the spill that you want to remove/replace)
This works just like any other colour picker or selector in Nuke - you can use values by typing them directly into the RGB fields or you can use the colour picker or you can click the colour wheel to change to sliders:
...or CTR/CMD+Click to pop out the colour wheel:
however you select the colour, your aim here is to get as good of a representative colour as possible - close to the subject as this will likely be the most accurate representation of spill and will give the best results.
At the heart of the tool is the "Despill Blending Method " control.
What you choose here will affect the controls which are visible in the rest of the tool..
As we discovered when we looked "under the hood" - There are 5 options to choose from, starting with "None":
This option does not implement any additional spill blending. it is straightforward despill but with luminance added back to the plate (*note: you can select which luminance math is used in the desaturation method in control below - we will explain that in a moment but you can jump to that section now if you wish*).
This method is new to me and I'm still not 100% sure I have the implementation correct but..
This is an "Inside-Outwards" operation (using values from inside the keyed alpha to blend into the edges) and is a variation on the "Edge Extend" option only instead of extending the edges using the standard unpremult-blur-premult way of extending edges, we use IBK gizmo and unpremult which can sometimes give better results in terms of sharpness of fine detail.
**Note that this method requires Clean-plate connected to "CP" input in order to work**
Some common issues that I have found in using this method are colour artefacts around the edges. This can be controlled however through a combination of saturation and raising the IBK Gamma / Gain until it is under control (*if there are any such artefacts in the core of the image - these can easily be masked out using the blending mask options)
IBK Extend Controls:
Screen Type: this is where you set the colour of your screen to either green or blue.
IBK Alpha / Gamma Gain: These control the alpha which is generated by the IBK gizmo "under the hood" before it is premulted for edge extending.
I included these to help with any unwanted artefacts which might occur depending on your image.
This controls how saturated the clean plate is and can help with unwanted artefacts - especially when used in conjunction with the Alpha controls (above).
Like the IBK Extend, this is another "inside-outwards" technique. Only this time we are using the classic Blur method. It's important to note that this is not as hard-core as some other edge extension nodes. The key here is subtlety - blurring only a few pixels tends to work best. Remember: we're only pushing into the edge spill areas and not fixing broken edges.
Edge Extend Controls:
Edge Blur size:
Controls how much the image is blurred before premulting.
Constant Colour Despill:
This is the first of the "outside-inwards" - putting values that exist outside of the source image into the despill areas. It is also the simplest. the idea here is that you choose a colour (in the same way that you chose the source colour) and that colour will be placed inside all of the spill areas. This option is handy when you need to target a specific area then it can be masked in.
Use BG input:
This is the last option and another "outside-inwards" method. This method requires the "BG" input to be connected to the node.
This blending method takes the BG input and places this inside the spill area so that it can often blend close to perfectly depending on the BG image. I have included some additional controls to help with blending:
Blur Amount: Sets amount of blur - this will blur the BG image before placing it into the spill. BG Gamma / Gain:
Controls Gamma and Gain of BG image - brightness values before placing into the spill.
Controls saturation for BG image before placing into the spill.
This is the math method used to desaturate the spill so that it can be manipulated later. Rec 709 is usually closest in terms of the amount of luminance that was in the original plate. trying out the different options though can sometimes help give better results...
For the masks, i included the ability to mask either the whole effect (so the tool will not affect anything that is not included the in the mask) or you can mask just the despill blending effect.
If you choose to mask only the despill blending effect then the overall despill (keylight despill) will still be in place and the blending method will be masked.
...Hope this guide helps you to understand and use my despill tool. If you have any comments or suggestions about how to improve the tool... or if you just want to reach out to me for any reason.. then feel free to get in touch!
...Very best wishes and HAPPY COMPING!!