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

Home > Articles > Digital Audio, Video

This chapter is from the book

Color Matching with the Grade Node

The Grade node is specifically built 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), and then match the level of the midtones gray, 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 to Lift. It works in the same way, but higher numbers will result in stronger blacks instead of lighter blacks. Basically, the color chosen here will turn to black.

Whitepoint

This is the reverse operation to Multiply. It works in the same way, but higher numbers will result in lower highlights instead of stronger highlights. Basically, the color chosen here will turn to 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 you then can easily set the blackpoint and whitepoint 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 top-most 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 on the windshield. For that, you'll bring another image in (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 that you will 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 to be there.

    You can see here that this is not the desired result (FIGURE 4.23). 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 the reverse operation from Mask, which you used in Chapter 3. Mask held image B inside the alpha channel of image A, and Stencil will hold image B outside image A.

  10. In Merge2's Properties panel, choose Stencil from the Operation drop-down menu.

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

    Figure 4-24

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

  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 Grade1's Offset property up to around 0.4.

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

    Figure 4-25

    Figure 4.25 The whole image turned brighter.

  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.alpha 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 before (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 a smaller indication, 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 that 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 to match black and white points

Thinking back to the introduction of this section, how are you going to find the darkest and lightest points in these two images to match them together? One way, which is valid and happens often, is 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 doesn't have to contend with light reflections on the screen, etc.

The Node to use for this is the CurveTool node, which you used in Chapter 3 to find the edges of the lemming element. You can also use this node to find other color-related stuff about your image. Let's bring a CurveTool node in 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. Click the Go! button.
  4. In the dialog box that opens, click OK as you only want to process 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 RGB values display.

    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.
  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 are getting rid of the black and replacing 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 MaxLumaData tab again and have a look (FIGURE 4.33).
    Figure 4-33

    Figure 4.33 The updated CurveTool1's MaxLumaData tab.

    You can see now that the minimum values are far from being all 0. You are now getting a true result showing 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'll need to use another CurveTool to find those points in the background image.

  19. Click Read2 and by Shift-clicking, branch out another CurveTool from it.

    This time there is no alpha and no black background to worry about. You can simply proceed to finding the black and white points.

  20. In CurveTool2's Properties panel, choose Max Luma Pixel from the Curve Type drop-down menu.
  21. Click Go! When asked, click OK.
  22. When the processing is finished (you should see a quick flash of the Progress Bar) switch to the MaxLumaData tab.

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

  23. Close all Properties panels in the Properties Bin to clear some room.
  24. Double-click CurveTool2, then double-click Grade1.
  25. Ctrl/Cmd-drag from CurveTool2's Minimum Luminance Pixel value's Animation menu to Grade1's Lift Animation menu to create an expression link between them.

  26. Do the same from the Maximum Luminance Pixel value to Gain (FIGURE 4.35).
    Figure 4-35

    Figure 4.35 Dragging while holding Ctrl/Cmd creates a linking expression.

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

    Figure 4-36

    Figure 4.36 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. This 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, you will 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. I 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.37).

    Figure 4-37

    Figure 4.37 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.38).

    Figure 4-38

    Figure 4.38 There is still work to be done on the color of the midtones.

    OK, so the midtones' brightness is now better, 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 as you always have three options: red, green, and blue. Matching gray is a lot easier as you only need to decide whether to brighten or darken it. However, as each color image is made out of three gray channels, you can do that 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.39).

    Figure 4-39

    Figure 4.39 Viewing the red channel.

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

  6. Display the Color Wheel and Color Sliders panel for the Gamma property by clicking the Color Wheel button.

    You will 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 only look right when it does, math aside.

    Let's display those extra color wheels.

  7. Ctrl/Cmd-click the Color Wheel button for the Multiply and Offset properties. Your screen should look like FIGURE 4.40.
    Figure 4-40

    Figure 4.40 Opening three color wheels to easily control three properties.

  8. Since you are looking at the red channel in the Viewer, you should 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. Mine is Gamma: 0.85, Multiply: 0.95, and Offset: 0.025.
  10. Do the same for the blue channel. Mine is Gamma: 0.96, Multiply: 0.95, and Offset: 0.03.
  11. Switch back to viewing the RGB channels (FIGURE 4.41).

    Figure 4-41

    Figure 4.41 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.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020