Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Digital Audio, Video

  • Print
  • + Share This
This chapter is from the book

Color Matching with the Grade Node

The Grade node is built specifically to make some color correction operations easier. One of these operations is matching colors from one image to another.

When matching colors, the normal operation is to match black and white points between the foreground and background (only changing the foreground), then match the level of the gray midtones, and finally match the midtone hue and saturation.

Using the Grade Node

The Grade node is made out of a few of the building blocks mentioned earlier. TABLE 4.2 shows a list of its seven properties.

TABLE 4.2 Grade Node Properties

Property

Definition

Blackpoint

This is the reverse operation of lift. It works in the same way, but a higher number will result in stronger blacks instead of lighter blacks. Basically, the color chosen here becomes black.

Whitepoint

This is the reverse operation of Multiply. It works in the same way, but higher numbers will result in lower highlights instead of stronger highlights. Basically, the color chosen here becomes white.

Lift

A Lift operation.

Gain

A Multiply operation.

Multiply

Another Multiply operation.

Offset

An Add operation.

Gamma

A Gamma operation.

By using Blackpoint and Whitepoint to set a perfect black and a perfect white, you can stretch the image to a full dynamic range. When you have a full dynamic range, then you can easily set the black point and white point to match those of the background using Lift and Gain. You then have Multiply, Offset, and Gamma to match midtones and for final tweaking.

Let’s practice color matching, starting with a fresh script.

  1. If you want, you can save your script. When you are finished, press Ctrl/Cmd-W to close the script and leave Nuke open with an empty script.
  2. From your chapter04 folder, bring in two images: CarAlpha.png and IcyRoad.png.
  3. Make sure that CarAlpha.png is called Read1 and IcyRoad.png is Read2. You can change the name of a node in the topmost property.

    You will quickly composite these images together and then take your time in color matching the foreground image to the background.

  4. Select Read1 and press the M key to insert a Merge node after it.
  5. Connect Merge1’s B input to Read2 and view Merge1 in the Viewer (FIGURE 4.21).

    FIGURE 4.21

    FIGURE 4.21 The car is over the dashboard—this is wrong.

    The composite is almost ready. You just need to punch a hole in the foreground car so it appears to be behind the snow that’s piling up on the windshield. For that, you’ll bring in another image (you will learn how to creates mattes yourself in Chapter 6).

  6. From your chapter04 folder, bring in Windshield.png and display it in the Viewer.

    Here you can see this is a matte of the snow. It is a four-channel image with the same image in the R, G, B, and alpha. You need to use this image to punch a hole in your foreground branch. To do this, you need another Merge node.

  7. Select Read3 and insert a Merge node after it.
  8. Drag Merge2 on the pipe between Read1 and Merge1 until the pipe highlights. When it does, release the mouse button to insert Merge2 on that pipe (FIGURE 4.22).

    FIGURE 4.22

    FIGURE 4.22 Inserting a node on an existing pipe

  9. View Merge1 (FIGURE 4.23).

    FIGURE 4.23

    FIGURE 4.23 All that white on the dashboard shouldn’t be there.

    You can see here that this is not the desired result. You still need to change the Merge2 operation to something that will cut the B image with the A image. This operation is called Stencil. Stencil is used often to combine mattes in the same way we’re using it now. The reverse of this operation, which is just as important, is called Mask, which masks the B image inside the A image’s alpha channel. Mask holds image B inside the alpha channel of image A, and Stencil holds image B outside image A.

  10. In Merge2’s Properties panel, choose Stencil from the Operation drop-down menu (you can see the result in FIGURE 4.24).

    FIGURE 4.24

    FIGURE 4.24 The car is now correctly located behind the dashboard.

    Looking at your comp, you can see that it now works—short of a color difference between the foreground and background. Let’s use a Grade node to fix this shift.

  11. Select Read1 and press the G key to insert a Grade node after it.

    As you know from Chapter 2, you are not allowed to color correct premultiplied images. It is often hard to tell if an image is premultiplied or not, but in this case it is. You can also look at the RGB versus the alpha channels and see that the areas that are black in the alpha are also black in the RGB.

    Since you can’t color correct premultiplied images, you have to unpremult them. You can do this in one of two ways: using an Unpremult node before the color correction (in this case, Grade1) and then a Premult node after it, or using the (Un)premult By Switch in your Color nodes. Let’s practice both.

  12. Bring the Grade1’s Offset property up to around 0.4 (FIGURE 4.25).

    FIGURE 4.25

    FIGURE 4.25 The whole image turned brighter.

    You can see that the whole image, except the dashboard area, turned brighter, even though you are correcting only the car image. This is due to the lack of proper premultiplication. Let’s do the two-node method first.

  13. Click Read1 and, from the Merge toolbox, add an Unpremult node.
  14. Click Grade1 and, from the Merge toolbox, add a Premult node and look at the Viewer (FIGURE 4.26).

    FIGURE 4.26

    FIGURE 4.26 The proper premultiplication fixed the problem.

    The problem has been fixed. This is one way to use proper premultiplication. Let’s look at another.

  15. Select Unpremult1 and Premult1, and press the Delete key.
  16. In Grade1’s Properties panel, choose rgba.alph from the (Un)premult By menu; this automatically selects the associated check box (FIGURE 4.27).

    FIGURE 4.27

    FIGURE 4.27 Using the (Un)premult By property does the same thing as the Unpremult and Premult nodes workflow.

    The resulting image looks exactly as it did before (in FIGURE 4.26). This technique does exactly the same thing as the first method, just without using other nodes. I usually prefer the first method, as it shows clearly in the DAG that the premultiplication issues are handled. However, if you look at Grade1 in the DAG now, you will see that, although the change is not as noticeable, Grade1 is showing that it is dividing the RGB channels with the alpha channel. The label now says “rgb/alpha” (FIGURE 4.28).

    FIGURE 4.28

    FIGURE 4.28 The node’s label changes to show the Unpremult and Premult operations are happening inside the node.

    Let’s use the second method you have set up already. You will now be color correcting an unpremultiplied image but outputting a premultiplied image.

    After a little rearranging, the tree should look like the one in FIGURE 4.29.

    FIGURE 4.29

    FIGURE 4.29 Your tree should look like this at this point.

  17. Bring the Offset property back to 0.

Using CurveTool and Pixel Analyzer to match black and white points

Think back to the introduction of this section; how are you going to find the darkest and lightest points in these two images so you can match them together?

One way, which is valid and happens often, is by using your eyes to gauge which are the darkest and brightest pixels. However, the computer is so much better at these kinds of things, and it doesn’t have to contend with light reflections on the screen and other such distractions.

The node to use for this is the CurveTool node, which you used in Chapter 3 to find the edges of the pilot element. You can also use this node to find out other color-related stuff about your image. Let’s bring in a CurveTool node to gauge the darkest and brightest point in the foreground and use that data to stretch the foreground image to a full dynamic range.

  1. Select Read1 and branch out by Shift-clicking a CurveTool node in the Image toolbox.

    This time you are going to use the Max Luma Pixel Curve Type. This finds the brightest and darkest pixels in the image.

  2. In CurveTool1’s Properties panel, switch the Curve Type drop-down menu to Max Luma Pixel.
  3. While viewing CurveTool1 in the Viewer, click the Go! button.
  4. In the dialog box that opens, click OK since you want to process only one frame.
  5. Switch to the MaxLumaData tab and view CurveTool1 in the Viewer (FIGURE 4.30).

    FIGURE 4.30

    FIGURE 4.30 The MaxLumaData tab’s two sections

    The purpose of this operation is to find the darkest and lightest pixels in the image. When switching to this tab you see two sections, the one showing the lightest pixel (Maximum) and the darkest pixel (Minimum). For each, the X and Y location and the RGB values are displayed.

    Looking closely, you can see that the value of the minimum pixel is 0 in every property. This is because this image is a premultiplied image, and as far as CurveTool is concerned, all that black in the image is as much a part of the image as any other part of it. You need to find a way to disregard that black area. Let’s do the following.

  6. From the Image toolbox, create a Constant node.

    A Constant node creates a solid color with a chosen resolution.

  7. Change Constant1’s Color value to 0.5.
  8. Select Read1 and branch a Merge node from it by pressing Shift-M.
  9. Connect Merge3’s B input to Constant1, and then view Merge3 in the Viewer (FIGURE 4.31).

    FIGURE 4.31

    FIGURE 4.31 The car is on a gray background.

    What you did here was replace, momentarily, the black background with a middle gray background. This way, you get rid of the black and replace it with a color that is not the darkest nor the lightest in the image. This new image is the image you want to gauge using the CurveTool. You’ll need to move the pipe coming in to CurveTool1 (FIGURE 4.32).

    FIGURE 4.32

    FIGURE 4.32 Moving the pipe from Read1’s output to Merge3’s output

  10. Click the top half of the pipe going into CurveTool1, which will enable you to move it to the output of Merge3.
  11. Double-click CurveTool1 to display its Properties panel in the Properties Bin. Switch to the CurveTool tab (the first one), click Go! again, and click OK.
  12. Switch to the MaxLumaPixel tab again and have a look (FIGURE 4.33).

    FIGURE 4.33

    FIGURE 4.33 The updated CurveTool1’s MaxLumaData tab

    Now you can see that the minimum values are far from being all 0. You are getting a true result that shows the lightest and darkest pixels. Let’s make use of them.

  13. Close all Properties panels in the Properties Bin to clear some room.
  14. Double-click CurveTool1 and then double-click Grade1.
  15. View Merge1 in the Viewer.
  16. Click the 4 icon next to Grade1’s Blackpoint, Whitepoint, Lift, and Gain to enable the four fields.
  17. Ctrl/Cmd-drag from CurveTool1’s Minimum Luminance Pixel value’s Animation menu to Grade1’s Blackpoint Animation menu and release the mouse button to create an Expression link between them.
  18. Do the same from Maximum Luminance Pixel value to Whitepoint (FIGURE 4.34).

    FIGURE 4.34

    FIGURE 4.34 The green arrow shows the Expression link between the two nodes.

    The foreground image’s dynamic range now spans from a perfect black to a perfect white. This enables you to push those colors to new black and white points to match these points to the background image. You can use another CurveTool to find those points in the background image, but just for fun, let’s use the Pixel Analyzer for that this time.

    The Pixel Analyzer is a new panel in Nuke 8.0. It helps you analyze the pixel values in your image.

  19. From the Properties Bin’s Content menu, choose “Split Vertical”.
  20. From the newly created pane’s Content menu, choose Pixel Analyzer (FIGURE 4.35).

    FIGURE 4.35

    FIGURE 4.35 The Pixel Analyzer now lives at the bottom right of the interface.

    This is the aforementioned Pixel Analyzer.

  21. While holding Ctrl/Cmd, drag on the screen (FIGURE 4.36).

    FIGURE 4.36

    FIGURE 4.36 Dragging on the screen creates this dotted line if the Pixel Analyzer is open.

    Notice this time around that a line of red dots appears on the screen? All those points accumulate to fill the five color boxes in the Pixel Analyzer with values.

    The five boxes represent:

    • Current: the last pixel dragged
    • Min: the lowest or darkest value dragged
    • Max: the highest or brightest value dragged
    • Average: the average pixel value of all pixels dragged
    • Median: out of all values dragged, the middle value

    Clicking any of the boxes shows the values of that color below—RGBA and HSVL (Hue, Saturation, Value, Luminance).

    Dragging on the screen is all well and good, but the whole frame is what you need to know about. There’s a feature for that too.

  22. View Read2 in the Viewer.
  23. From the Mode menu, choose Full Frame.

    This option checks every pixel of the frame that’s currently in the Viewer and returns the corresponding values in the five boxes. This is a really quick way to find your black point and white point in a given frame.

    You now have two sets of data to match to: new black points and white points. Let’s copy them to your Grade node.

  24. Close all Properties panels in the Properties Bin to clear some room.
  25. Double-click Grade1.

    Because the Pixel Analyzer is a panel and not a node, you can’t link to it, but you can very easily copy the values across from the Pixel Analyzer to the property where the values are needed by dragging.

  26. Drag from the Pixel Analyzer’s Min box to Grade1’s Lift Color swatch to copy the values across (FIGURE 4.37).

    FIGURE 4.37

    FIGURE 4.37 Dragging from the Pixel Analyzer

  27. Do the same from the Max box to the Gain Color swatch.
  28. You don’t need the Pixel Analyzer anymore, so from its Content menu choose Close Pane.
  29. View Merge1 in the Viewer.

    You have now matched the foreground’s shadows and highlights to those of the background (FIGURE 4.38).

    FIGURE 4.38

    FIGURE 4.38 Shadows and highlights now match.

As you can see from the image, the shadows and highlights are matched, but the image is far from looking matched. The midtones, in this case, make a lot of difference.

Matching midtones by eye

You now need to match the midtones, which is a much more difficult task. You’ll start by matching its luma level by eye. Because it is hard to tell what the midtones are, though, you are going to view the luminance of the image in the Viewer.

  1. Hover your mouse pointer in the Viewer and press the Y key to view the luminance.

    To change the midtones now, use the Gamma property. You can see that the whitish snow on the right is a darker gray than the whitish car. Let’s bring down the whitish car to that level.

  2. Start dragging the Gamma slider down. I stopped at around 0.6.

    Notice that the midtones don’t match well with a higher Gamma value. Now, however, the lower midtones aren’t matching well. You need to use the Multiply property to produce a good match.

  3. Bring the Gamma slider up to 0.85 and bring the Multiply slider down a bit to 0.9 (FIGURE 4.39).

    FIGURE 4.39

    FIGURE 4.39 The midtones match better now.

  4. Hover your mouse pointer in the Viewer and press the Y key to view the RGB channels (FIGURE 4.40).

    FIGURE 4.40

    FIGURE 4.40 You still have work to do on the color of the midtones.

    OK, so the midtones’ brightness is better now, but you need to change the color of the car’s midtones. At the moment, the car is too warm for this winter’s day. Matching color is a lot more difficult because you always have three options: red, green, and blue. Matching gray is a lot easier because you need to decide only whether to brighten or darken it. However, as each color image is made out of three gray channels, you can use the individual channels to match color too. Here’s how.

  5. Hover your mouse pointer in the Viewer and press the R key to view the red channel (FIGURE 4.41).

    FIGURE 4.41

    FIGURE 4.41 Viewing the red channel

    Now you are looking only at levels of gray. If you change the red sliders, you will get a better color match while still looking only at gray.

  6. Display the In-panel Color Picker for the Gamma property by clicking the Color Picker button.

    You also want to change the Multiply and Offset values to achieve a perfect result. This is because, even though you matched the black point and white point, the distance of the car from the camera means the black point will be higher and the white point lower. At the end of the day, it will look right only when it does match, math aside.

    Let’s display those extra color wheels.

  7. Click the Color Picker button for the Multiply and Offset properties. Your screen should look like FIGURE 4.42.

    FIGURE 4.42

    FIGURE 4.42 Opening three color wheels to easily control three properties

  8. Since you are looking at the red channel in the Viewer, change the red sliders for Gamma, Multiply, and Offset until you are happy with the result; little changes go a long way. I left mine at Gamma: 0.8, Multiply: 0.82, and Offset: 0.02.
  9. Display the green channel in the Viewer, and then move the green sliders to change the level of green in your image. My settings are Gamma: 0.85, Multiply: 0.89, and Offset: 0.025.
  10. Do the same for the blue channel. My settings are Gamma: 1.05, Multiply: 1, and Offset: 0.065.
  11. Switch back to viewing the RGB channels (FIGURE 4.43).

    FIGURE 4.43

    FIGURE 4.43 Not a bad result at the end of it all.

This is as far as I will take this comp. Of course, you can use your already somewhat-developed skills to make this a better comp, but I’ll leave that to you.

Save your script if you wish, and we will move on.

  • + Share This
  • 🔖 Save To Your Account