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

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