Masking with per-pixel gamma

We’re getting ready to release a new version of Conduit. In addition to supporting more host platforms, this 1.6 update makes some new features available to current users of Conduit for Final Cut Studio. There’s no upgrade cost, it will be a free download.

One of these new features is the Embedded Image node. It allows you to load an image directly into the conduit — no more need to put still images in the plugin’s image wells!

Once an image is loaded into an Embedded Image node, it stays as part of the .conduit file (there’s no dependency on the original file). This is highly convenient for images that are part of the effect, such as a mask used to create a specific look. This post shows one example.

As you may already know, most nodes’ parameters in Conduit can be driven by an image. This allows a wide range of interesting per-pixel effects that are essentially impossible in traditional graphics applications. For example, in After Effects you can apply a gamma to the entire image… But what if you wanted a different gamma value applied to each pixel?

While impossible in AE, it’s a breeze in Conduit. To demonstrate, I’ll reuse this image which previously made an appearance in this post:

Here’s the mask — just a plain ellipse drawn in Photoshop, rotated and blurred:

To control each pixel’s gamma value with this image, we just need to plug the image into the Gamma node’s gamma parameter. I’d like to perform this operation in linear light colorspace, so I also need two colorspace conversion nodes. Here’s the effect:

(Notice the blue node? That’s Embedded Image.) Ok, clearly the mask image is much too contrasted, we don’t want the image to go all black in the corners. Some tone adjustment nodes should take care of that…

 

The mask image’s black level was raised and its steep falloff flattened. These are the settings for the Bezier Curve and Levels nodes.

 

What next? Maybe we could add a color tint using the same mask. For basic tinting, the Multiply node works just fine. But the mask we have is black & white — to get a duotone color image from it, we can use the Gradient node to map the black/white into colors (this technique was discussed in more detail here). The colors chosen here are light orange tones:

The result image:

Out of curiosity, what would this effect look like if we didn’t use the linear colorspace? That’s easy to find out by simply bypassing the Video->Linear and Linear->Video nodes…

This look is more artificlal, with steeper contrast and greater saturation variation in the shadows. But since Conduit is non-destructive, you can always keep experimenting to find a happy medium between these looks: things to try might be tweaking the colors plugged into the Gradient node, or entering different values for the “gamma” parameter in the Video->Linear->Video conversion nodes.

Color correction
Conduit
Mattes

Comments (0)

Permalink

Layer styles, part 3

Previous installments in my Layer Styles series showed how to create layer outlines and drop shadows in Conduit. This time I’ll look into two very similar layer effects that Photoshop calls “Inner Shadow” and “Inner Glow”. They preserve the original alpha (transparency) of the layer, applying the effect only on the layer image.

Inner Shadow is a simple variant of the Drop Shadow effect that we built previously. Let’s try it on this simple one-layer composite:

With inner shadow applied…

The conduit for this effect looks like this:

The 2D Transform node is used to move the image towards the bottom right. That determines the “light direction” — the imaginary light casting this shadow is in the opposite direction, on the top left. Then, a Separate RGBA node is used to extract the alpha, and it’s blurred with a Gaussian Blur. Familiar territory so far. (The MinMax node is disabled, but will get used soon enough.) The offsetted-and-blurred alpha looks like this:

This image is multiplied over the original image, which applies the shadow. Finally, there’s the crucial Set Matte node, which is used to restore the alpha of the shadowed image to that of the original image. The last node is a plain old Over to composite this layer over the background.

The inner shadow may not be terribly exciting, but it offers a good opportunity to extol Conduit’s pervasive floating-point capabilities. Here’s a variant where the the image is brightened before applying the shadow. Also, the shadow is not offset with a 2D Transform, but rather shrunk with a 2D Min node. This results in a look where the shadow follows the outlines of the layer (this is effectively the same as Photoshop’s Inner Glow with blending mode set to Multiply):

Notice how color and detail is preserved in the bright areas that were blown out and then darkened by the shadow? For comparison, the following image shows what the effect looks like if the brightened image is clipped. This is the result you get in a compositor that doesn’t support floating-point color:

(Technology insight interlude: many video/graphics editing and compositing packages don’t support floating-point color at all. Those that do usually have a separate floating-point mode, and users avoid using floating-point color unless absolutely necessary because it entails heavy performance hit and more limited features; e.g. many Photoshop and After Effects filters are disabled in floating-point mode. In contrast, Conduit simply defaults to floating-point — you need to explicitly enable clipping in a node if you don’t want high dynamic range color. We can afford to do this because the core of Conduit is a highly efficient concatenation engine that breaks down the conduit into optimized GPU programs. Expensive memory bus traffic is minimized as the pixel data is kept in high-precision GPU registers as long as possible. That’s how Conduit can do realtime HD playback with effects that might take something like 10 seconds per frame to render in a previous-generation compositor like Shake. Now back to the tutorial…)

Instead of just a black shadow, we might want to colorize it. That’s pretty simple to accomplish: just mix a color into the shadow image (the blurred alpha). We’ll use a Screen node for this, because we want to keep the white intact in order to avoid colorizing the entire layer when the shadow is applied. Here’s the shadow image colorized using Screen:

The result image:

And the conduit:

The brightening is accomplished with a Bezier Curve node (which brings down the highlights a bit) followed by Exposure. Here are the exact settings for these nodes, in case you’re curious:

As a tiny reward for the patience you’ve shown by reading this far, here’s a glimpse into one of the new Conduit products that will be released soon. Watch this space! :)

Conduit
Layer effects

Comments (1)

Permalink

Layer styles, part 2

In the previous post (which was much too long ago considering this was supposed to be a regular series of posts…) we built a simple graphical layer style which added a plain black border to a text layer generated in FCP.

To expand upon that technique, let’s turn the black border into a drop shadow by blurring and offsetting the text’s outline:

Drop shadow nodes

The 2D Transform node allows you to move and resize an image. The parameter values are relative to the image size — e.g. to move the image 10% to the left, you’d enter a value of -0.1 for “X translation”; to stretch the image to twice its original height, you’d enter a value of 2 for “Y scaling”, and so on.

For a tiny bit of extra interest, the originally white text was tinted to yellow using a Multiply node on the left-hand side of this tree. As in the previous version, the Over node at the end composites the original text (left-hand side nodes) over the drop shadow (right-hand side nodes).

The subtitle layer now looks like this:

Conduit
Layer effects

Comments (1)

Permalink

Layer styles, part 1

I enjoy playing around with nodes and exploring abstract image processing concepts with the freedom granted by a nodal interface, but I realize that not everyone has a passion for tinkering. I’d like to be able to convince those people that Conduit can also be used to solve everyday practical problems in Final Cut Pro and other host applications.

To that aim, I’m starting a series of posts about “layer styles”. The name comes from the set of effects available through Photoshop’s Layer Styles dialog, which looks like this in my ancient copy of Photoshop 7.0 (the first version of Photoshop that ran on OS X, not so long ago!)…

If I recall correctly, this dialog was added in Photoshop 6. Before that, designers had to manually build and update these effects for each layer — a time-consuming process, considering how common it is to have something like a drop shadow or translucent gradient fill applied to a bunch of layers.

Layer styles would be just as useful in Final Cut Pro, but the only thing we get by default is the “Drop Shadow” settings in the Motion tab for a clip. Luckily, armed with Conduit we can easily build “layer style” effects. Applying a Conduit-created custom effect to multiple clips is as easy as copy&pasting the Conduit effect from one clip’s filter properties into another.

Here’s an image from the brand-new exciting soap opera created by the Anteeksi design collective:

The Finnish-language subtitling is created with Final Cut Pro’s standard tools as a text clip on the topmost track. The problem is that the white text goes unreadable on a light background. A plain black border would be a nice solution, but FCP’s text tool doesn’t offer the possibility.

We’ll apply Conduit to the text clip. In Conduit, we’ll: 1) pull the alpha of the text to get its outlines, 2) use a “2D Max” node to expand the text outlines, 3) fill the expanded outlines with black, 4) composite the original white text on top of the expanded black text.

Here’s how this task is accomplished using nodes in the Conduit Editor:

Basically there’s a node for each of the four steps I described above, and one additional node for the black color. (Instead of a Color node we could alternatively use a Color Picker node, which would allow us to easily change the border color in the Conduit filter’s properties in FCP without opening the Conduit Editor itself.)

Here’s what the black outlines look like. Much improved on-screen readability!

Conduit
Layer effects

Comments (0)

Permalink

High-pass filter, because you’re worth it

The familiar Gaussian blur filter eliminates sharp detail, leaving only large shapes of color. If we think of the image pixels as a waveform, the blurred image contains only the low frequencies of the original image – the Gaussian blur is therefore a low-pass filter. Sometimes we might want the opposite: an image filter that eliminates large scale color variation and leaves only sharp details. This kind of high-pass filter would therefore be the functional inverse of a Gaussian blur.

We can in fact build a high-pass filter simply by subtracting a blurred image from the original:

Let’s try using the high-pass filter for smoothing skin. Here’s a DV image of some wrinkles… (Yeah, I didn’t need to go very far to get this image.)

The result of the above high-pass filter looks like this:

And with a couple more nodes….

….my hand looks 20 years younger. (Of course what really matters is the way it makes me feel. More self-confidence thanks to the new, improved formula!) Roll over to compare with original image.

Quick overview of how the effect is constructed: the high-pass matte is slightly expanded and blurred, then used as a mask to composite a blur over the original image. (The blurred image is marked as “wrinkle fill image” in the node screenshot above.) The result is then masked using a Color Range Key into the shadows and midtones of the hand. This is because I didn’t want the blur to smoothen out those illuminated hairs on the hand – the result would have looked too artificial.

What is this effect good for? I would imagine that certain segments of the video production industry have an interest in making skin look airbrushed… But I wouldn’t know anything about that.

Of course you don’t have to settle for smoothing out details. The “wrinkle fill” image could just as well be a sharpened version of the original, in case you want to make those wrinkles really pop out – for example if you’ve shot a documentary in Afghanistan, but the 97-year old refugee doesn’t look quite old enough.
(Disclaimer: you may lose your Oscar if the trick is exposed. Please don’t take documentary production advice from me.)

Conduit
Mattes

Comments (5)

Permalink

Introduction to curves

Many are probably familiar with the Curves tool as found in Photoshop and After Effects. Curves are powerful because they let you control the tone values of the image with much more precision than other typical adjustments such as Levels. The curve is actually a function which maps the original luminance values (on the X axis of the graph) onto new values (on the Y axis). But don’t be afraid of the mathematical definition – the easiest way to understand how the Curves tool works is simply to try it yourself. Place a point in the top-left quarter and pull it up, and you’ll see the image’s highlights getting brighter. Do the opposite in the bottom-right corner, and the shadows will get darker.

The curve nodes in Conduit obey the same logic as in those Adobe apps I mentioned above, with the difference that we offer several variants of curves which have slightly different characteristics. The main reason for this is that Photoshop/AE traditionally operate only on 8-bpc images, whereas Conduit works purely in a 32-bit floating point HDR color space. So while Photoshop can get away with using a precomputed low-precision lookup table (LUT) to perform the curve operation, Conduit actually computes the function separately for each pixel. What you gain is perfect precision: operations in Conduit never produce banding, and the effect of the curve is accurately applied down to the most minuscule tone variations.
(By the way, Photoshop’s reliance on old-fashioned lookups is the reason why Curves – and most other adjustments – are not available when working on 32-bit HDR images in Photoshop CS2.)

The most basic curve is the Cubic with no scaling and no weighting:

You can move any of the four control points vertically, but that’s all. Although that sounds limiting, it’s enough for a lot of typical needs. What you gain by using this no-frills curve is performance: this plain Cubic consumes as little as 3-4 GPU instructions. (Whether that matters at all depends completely on your GPU hardware — I’ll talk about that in a moment.)

When you need more flexibility, the Cubic stretches further by enabling “X weighting”:

In this mode, you can move the two control handles in the middle horizontally, but they always move together (=the distance between them can’t be modified). The price you pay for this degree of freedom is a few more GPU instructions.

You can also modify output levels (i.e. move the start/end points of the curve horizontally) by enabling “X scaling”:

If the tricked-out Cubic isn’t enough for you, you’ll have to move up to the Bézier curve, which lets you manipulate the two control handles independently:

Bézier Curve can cost up to 16 GPU instructions, so it’s one of the most computationally expensive nodes in Conduit.

Whether you need to care about the instruction count depends purely on the graphics hardware in your system: on older GPUs you’ll start to see rendering performance slow down if the number of instructions used by your conduit grows too large. The ATI Radeon 9600/9700 are particularly vulnerable to large instruction counts. OTOH, on more recent GPUs such as the NVidia Geforce 6800 or Radeon X1600 you shouldn’t have any problems even if you go nuts with Béziers. Still, it certainly doesn’t hurt to use Cubics if you can – just think, having the GPU doing less work could result in savings of 0.0000214% on your power bill ;)

The Cubic and Bézier curves are only properly defined for input colors that fall into the so-called standard range, i.e. values between 0 and 1. For that reason, you’ll generally want to keep the “Clip input” option enabled. The following screenshot from the Plot view illustrate the point. First, with input clipping enabled:

Without the clipping, the curve math can end up doing unexpected stuff for values outside the standard tone range:

This is a problem only if you need to apply a curve to a HDR image. Of course in Conduit it’s very easy to create HDR values (by intent, or sometimes by accident)… If you need to work with HDR input in curves and can’t accept clipping, an easy solution is to apply Levels before and after the curve so the image values are temporarily scaled within the legal 0-1 range. For example: you know your brightest HDR values are around 6.0, so you would apply Levels with “input white” at 6.0 before the curve, and another Levels with “output white” at 6.0 after the curve.

If you need separate control of RGB tone values, currently you have to use three separate nodes, maybe like this:

As you can see, it’s possible to individually shrink or grow nodes in Conduit to make the graph more readable. These scaling options can be found in the right-click context menu for the selected node.

Finally, an operation that is often handy: use a curve node to select a luminance range from an image, and use the result as a matte:

In this example, the Cubic curve isolates the highlight tones from the image, so the Multiply operation with the bright yellow color doesn’t get applied to the entire image. (With Curves, Multiply, Add and Gamma, you have the “raw materials” to build your own 3-way HDR color corrector with lift/gain/gamma controls and editable range curves. That could be your advanced level homework, if you choose to accept it…)

Color correction
Conduit

Comments (0)

Permalink

Smooth matte operator

I’ve finally installed Final Cut Pro 5.1.4 (I was hesitant to upgrade a working 5.1.2 installation), and it seems to work fine. Thanks to the fine developers at Apple for taking rapid action to fix the issues in 5.1.3!

In this post I’ll show a simple way of smoothing out the wrinkles in a matte’s edge. Images speak louder etc., so here’s “before” and “after”:


The initial jaggy matte image was actually created using the following simple keyer:

For the smoothed effect, all we need to add is another Levels node and a Gaussian Blur:

The important trick here is that the second Levels node has been set to not clip values into 0-1 range (which you can tell by the color — the Levels node above is red, which always indicates clipping in Conduit). The parameter settings on the Levels node look like this:

These numbers 0.547 and 0.601 were simply “eyeballed” by dragging the sliders, they have no special significance… What happens with these settings is that the Levels node stretches tone range 0.547-0.601 into the range 0-1. And because clipping is off, it also stretches values outside that range in the same proportion: anything below 0.547 in the original image will go below zero, and anything above 0.601 will go above one. Thus the result image contains values that are mostly far outside the 0-1 range.

Applying the Gaussian Blur to such an unclipped image naturally results in an image that has a similarly “strange” value range. But we can’t really see those values — upon display, any pixel values below zero is clipped to black, and anything above one is clipped to white. So although there’s a HDR blur contained in the black and white areas, all we see is a sharp outline:

Does this make sense to you? Dealing with floating point images may require shifting some mental gears about what digital color and pixels really are… But in the long run, you can benefit from adding these little HDR tricks into your effect arsenal. The edge smoothing effect is pretty strong in the above image for demonstration purposes, but when applied frugally, it might be just what you need for tidying up a key on some occasion — or perhaps you can think of some artistic use for it.

Conduit
Mattes

Comments (0)

Permalink

Final Cut Pro 5.1.3 breaks Conduit

Apple released Final Cut Pro 5.1.3 some few days ago. Unfortunately, this upgrade breaks many 3rd party plug-ins, including Conduit (but also Automatic Duck, Colorista…)

Any projects that use Conduit will continue to render as they should, but you’ll be unable to access the Conduit Editor because of what appears to be a bug in the FCP FxPlug GUI host.

Until the problem is resolved, please hold off on the 5.1.3 upgrade!

Conduit
FCP-specific

Comments (3)

Permalink

Aura of credibility

Do you often need to conceal the identity of a person appearing in a production? I don’t, but if I ever get the chance, I’ve now got the effect ready. The traditional tricks like mosaic masks or black bars have been seen too often already:

Maybe this guy is a witness who’s risking his life by speaking up, but the black bars just make him look criminal. We should instead make every effort to assert his innocence and purity of spirit — behold, the Angel Witness:

Like most of my previous posts, this look also relies heavily on Conduit’s HDR capabilities (view nodes). Using a Levels node, the image’s brightness is scaled up 10x and then blurred. We want to apply the blur only on the person’s face, so a suitable matte is constructed by applying further Max and Blur nodes to the image’s luminance.

A Levels node is applied to the matte, to scale and clip the values into the 0-1 range (a matte should never contain values outside that “standard range”). Below is the Level node’s settings and the result mask:

So, if you’ve got someone who needs protection, just download the .conduit file for this effect and let them bathe in the purifying white light.

Conduit

Comments (0)

Permalink

Rive gauche looks in HDR

Some people think that video color correction should be exactly what the name says, strictly limited to correcting problems that couldn’t be fixed while shooting: matching color temperature between shots, adding a bit of gain to lighten harsh daylight shadows, and so on.

This seems to be an ascetic school of thought: rather than indulging themselves at the smörgåsbord of digital color manipulation, they refuse it completely and denounce it as destructive to the pure spirit of the transparent cinematic image, or something along those lines. Yet there’s a solid reason why so many directors, colorists and video artists go for those extreme color looks — it helps them deliver the story or emotion better.

The image below is from a DV video shoot. This shot ought to have some kind of emotional impact, but instead it’s severely hampered by its technical shortcomings. The only story it’s telling me is: “Two people are pretending to have sex on a theatre stage… And is that a bluescreen visible behind the velvet curtain?”

I didn’t have much of a vision as to what should be done with this shot, so I decided to try tossing around some “extreme” nodes in Conduit to see what comes out:

High contrast overexposure, grain, and a golden yellow tint — a bit like a Tony Scott movie set in France, perhaps.

Looking at the nodes on the right, you can see that I’m “misusing” the Cineon to Linear node for color correction purposes. Although it’s a tool intended for a very specific colorspace conversion, we can take advantage of its interesting logarithmic tone curve to pop this image’s highlights into High Dynamic Range superbright stratosphere.

The rest of the nodes are easy to explain: Channel Mixer node does the yellow tint, and Over combines the blurred noise with the HDR image. Because the result is HDR, at the end of this conduit, a Linear to Video node is used to apply display gamma to the image.

Next, I wanted to try mixing a different color into the highlights, to make this image less uniform in color. What I got is basically an “inverse glow” — the image is blurred and tinted, and the result is subtracted from the original image. The resulting juxtaposition of deep blue and yellow/orange creates a nice contrast in my eyes (although it might look quite different on your monitor, the blue is frail):

In order to knock down those overexposed highlights, I added a Highlight Knee node. This node’s sole function is to round off superbright HDR highlights in a pleasing way — here is what it looks like when the knee value is set to about 0.8:

Yeah, I think I prefer a more peaceful look to the previous overexposed mayhem. Let’s take it further and use a Saturation node to desaturate the whole image… With the added trick of using the original image’s luminance to drive the saturation amount, so we get non-uniform desaturation:

See how the Saturation parameter is driven by an image value, rather than a plain number value? This effectively gives pixel-level control over the effect, and can be really useful for building more complex effects. Almost all nodes in Conduit allow their parameters to be controlled by images in this fashion — some accept color input, some only scalar (i.e. greyscale) like Saturation here.

I applied this trick a second time, to drive the Levels node by a previous Gaussian Blur. I also played with the blur size a bit, to see if this desaturated look could be better with a larger blur. This is the final image (roll over with mouse cursor to see the original):

Do you like it, or is it too extreme? To me, this has a “Paris 1968″ kind of mood. (But then again, I was born in 1980, so what would I know about the Sixties…)

It’s important to note that this look depends entirely on Conduit’s pervasive High Dynamic Range support. It uses both superbright values — the Cineon to Linear node is generating values that go over 10.0 — and negative values (in the subtracted blur). For comparison’s sake, below the same image without HDR values at the start, that is, the Cineon to Linear node is set to clip to standard 0-1 range… Roll over to see the clipped version:

(The conduit for this effect is available for download here. If you just want to have a look at the nodes, here’s a picture — I’m not putting it inline because it’s quite large.)

Color correction
Conduit

Comments (1)

Permalink