Jump to: Board index » General » Fusion

Most efficient way to isolate certain colors or brightness?

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

Dazzer

  • Posts: 228
  • Joined: Sat Aug 24, 2019 8:31 am
  • Real Name: Daz Harris

Most efficient way to isolate certain colors or brightness?

PostTue Aug 16, 2022 12:56 pm

Hi folks,

Imagine i've got a greyscale image with large blocks of solid whites, greys and blacks. Some areas are light grey, others are darker grey.

What is the cheapest and most efficient way to isolate one of these blocks, and have the rest invisible (removed)? So unless an area has that exact same color value, it gets deleted.

I guess the chroma keyer does it, and also the luma keyer. But i'm curious what anyone would suggest as the best way to do it.

Thanks!
Offline

Hardy-

  • Posts: 218
  • Joined: Sun Jun 19, 2022 4:39 am
  • Real Name: Hardy Heinlin

Re: Most efficient way to isolate certain colors or brightne

PostTue Aug 16, 2022 1:09 pm

Hi,

I would use the Qualifier in a node on the Color page, deselect the Qualifier's hue and saturation function (if it's all greyscale anyway), just use its luma function to isolate the desired solid gray block, then invert the Qualifier, and finally use the alpha output of that node for the actual isolation.
Offline

Dazzer

  • Posts: 228
  • Joined: Sat Aug 24, 2019 8:31 am
  • Real Name: Daz Harris

Re: Most efficient way to isolate certain colors or brightne

PostTue Aug 16, 2022 1:12 pm

Hardy- wrote:Hi,

I would use the Qualifier in a node on the Color page, deselect the Qualifier's hue and saturation function (if it's all greyscale anyway), just use its luma function to isolate the desired solid gray block, then invert the Qualifier, and finally use the alpha output of that node for the actual isolation.


Thanks, so i guess you're talking about Fusion in Resolve, right? (i tend to only use standalone Fusion although i noticed Fusion in Resolve seems to be a lot faster recently than it used to be!)

I'm going to try this but does anyone else have a suggestion for standalone Fusion?
Offline

Hardy-

  • Posts: 218
  • Joined: Sun Jun 19, 2022 4:39 am
  • Real Name: Hardy Heinlin

Re: Most efficient way to isolate certain colors or brightne

PostTue Aug 16, 2022 1:19 pm

Oh, sorry, I didn't notice this is the Fusion subforum. No, I meant the Color page in Resolve.

Anyway, in Fusion I would use the luma keyer. If the entire image is pure greyscale why would you need to key the hue and saturation?
Offline

Dazzer

  • Posts: 228
  • Joined: Sat Aug 24, 2019 8:31 am
  • Real Name: Daz Harris

Re: Most efficient way to isolate certain colors or brightne

PostTue Aug 16, 2022 1:28 pm

Ok!

To be honest, i don't really understand how to set this up properly with the Luma keyer, because it doesn't have a color picker (it fades the tones in and out with the channel left / right sliders but i just want to nuke all values apart from one). Any chance you could show me the correct setup?
Attachments
Greyscale color wheel.png
Greyscale color wheel.png (8.42 KiB) Viewed 971 times
Last edited by Dazzer on Tue Aug 16, 2022 1:40 pm, edited 1 time in total.
Offline

Sander de Regt

  • Posts: 3500
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Most efficient way to isolate certain colors or brightne

PostTue Aug 16, 2022 1:30 pm

I'd use the chroma keyer in this case set to 'color' - that will do what you want as far as I can tell.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

Hardy-

  • Posts: 218
  • Joined: Sun Jun 19, 2022 4:39 am
  • Real Name: Hardy Heinlin

Re: Most efficient way to isolate certain colors or brightne

PostTue Aug 16, 2022 1:30 pm

Will the image stay like this? If so, I would just manually draw a rectangle mask around the desired block.
Offline

Dazzer

  • Posts: 228
  • Joined: Sat Aug 24, 2019 8:31 am
  • Real Name: Daz Harris

Re: Most efficient way to isolate certain colors or brightne

PostTue Aug 16, 2022 1:39 pm

Sander de Regt wrote:I'd use the chroma keyer in this case set to 'color' - that will do what you want as far as I can tell.


Ok! But how do i isolate a single band in my PNG and nuke the rest? The chroma keyer doesn't seem to have a color picker.

Sorry, i'm a noob and only occasional Fusion user!

EDIT: i notice that although it doesn't have a color picker, if i click on a certain band, it removes it. Which is kinda cool, but i need to invert this, so it keeps the band and deletes the rest!

Hardy- wrote:Will the image stay like this? If so, I would just manually draw a rectangle mask around the desired block.


I need to isolate a certain grey value in a moving animation, so that wouldn't work! (that PNG is just used for testing)
Offline

Hardy-

  • Posts: 218
  • Joined: Sun Jun 19, 2022 4:39 am
  • Real Name: Hardy Heinlin

Re: Most efficient way to isolate certain colors or brightne

PostTue Aug 16, 2022 2:11 pm

Dazzer wrote:EDIT: i notice that although it doesn't have a color picker, if i click on a certain band, it removes it. Which is kinda cool, but i need to invert this, so it keeps the band and deletes the rest!

At the top of the Chroma Keyer tab there are four sections: Chroma | Image | Matte | Settings.

When you go to the Matte section you will find a checkbox "Invert Matte". Just click that.
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Most efficient way to isolate certain colors or brightne

PostWed Aug 17, 2022 1:14 am

Luma Keyer will only get you the ends of the luminance range (everything either brighter or darker than your target value). If what you want to isolate is in the middle, you probably want the Ranges tool instead.

Code: Select all
{
   Tools = ordered() {
      Ranges1 = RangesMask {
         Inputs = {
            Filter = Input { Value = FuID { "Fast Gaussian" }, },
            MaskWidth = Input { Value = 1920, },
            MaskHeight = Input { Value = 1080, },
            PixelAspect = Input { Value = { 1, 1 }, },
            ClippingMode = Input { Value = FuID { "None" }, },
            Image = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
            RangesRange = Input { Value = 1, },
            ColorRanges = Input {
               Value = ColorCurves {
                  Curves = {
                     {
                        Points = {
                           { 0.212, 1 },
                           { 0.259, 0.117 },
                           { 0.269, 0 },
                           { 1, 0 }
                        }
                     },
                     {
                        Points = {
                           { 0, 0 },
                           { 0.658, 0 },
                           { 0.653, 0.11 },
                           { 0.736, 1 }
                        }
                     }
                  }
               },
            },
         },
         ViewInfo = OperatorInfo { Pos = { 504, 14.3636 } },
      },
      BrightnessContrast1 = BrightnessContrast {
         CtrlWZoom = false,
         Inputs = {
            ApplyMaskInverted = Input { Value = 1, },
            Gain = Input { Value = 0, },
            Input = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
            EffectMask = Input {
               SourceOp = "Ranges1",
               Source = "Mask",
            }
         },
         ViewInfo = OperatorInfo { Pos = { 501.333, 77.6667 } },
      },
      Background1 = Background {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Type = Input { Value = FuID { "Horizontal" }, },
            TopRightRed = Input { Value = 1, },
            TopRightGreen = Input { Value = 1, },
            TopRightBlue = Input { Value = 1, },
         },
         ViewInfo = OperatorInfo { Pos = { 359.333, 53.4242 } },
      }
   }
}
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Most efficient way to isolate certain colors or brightne

PostWed Aug 17, 2022 1:23 am

I just read the original request again and have another notion. If you only want to keep the exact code value, then a CustomTool is the way to go. You'll probably want a little bit of a threshold control, though, because in floating point you'll almost never get the exact value you target. Here's an example, predicated on the assumption that you have a grayscale image:

Code: Select all
{
   Tools = ordered() {
      Background1 = Background {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Type = Input { Value = FuID { "Horizontal" }, },
            TopRightRed = Input { Value = 1, },
            TopRightGreen = Input { Value = 1, },
            TopRightBlue = Input { Value = 1, },
         },
         ViewInfo = OperatorInfo { Pos = { 359.333, 53.4242 } },
      },
      CustomTool1 = Custom {
         CtrlWZoom = false,
         Inputs = {
            NumberIn1 = Input { Value = 0.424, },
            NumberIn2 = Input { Value = 0.0018, },
            LUTIn1 = Input {
               SourceOp = "CustomTool1LUTIn1",
               Source = "Value",
            },
            LUTIn2 = Input {
               SourceOp = "CustomTool1LUTIn2",
               Source = "Value",
            },
            LUTIn3 = Input {
               SourceOp = "CustomTool1LUTIn3",
               Source = "Value",
            },
            LUTIn4 = Input {
               SourceOp = "CustomTool1LUTIn4",
               Source = "Value",
            },
            RedExpression = Input { Value = "if(c1<n1-n2, 0, if(c1>n1+n2, 0, c1))", },
            GreenExpression = Input { Value = "if(c1<n1-n2, 0, if(c1>n1+n2, 0, c1))", },
            BlueExpression = Input { Value = "if(c1<n1-n2, 0, if(c1>n1+n2, 0, c1))", },
            AlphaExpression = Input { Value = "if(r1<n1-n2, 0, if(r1>n1+n2, 0, c1))", },
            NumberControls = Input { Value = 1, },
            NameforNumber1 = Input { Value = "Target Value", },
            NameforNumber2 = Input { Value = "Threshold", },
            ShowNumber3 = Input { Value = 0, },
            ShowNumber4 = Input { Value = 0, },
            ShowNumber5 = Input { Value = 0, },
            ShowNumber6 = Input { Value = 0, },
            ShowNumber7 = Input { Value = 0, },
            ShowNumber8 = Input { Value = 0, },
            ShowPoint1 = Input { Value = 0, },
            ShowPoint2 = Input { Value = 0, },
            ShowPoint3 = Input { Value = 0, },
            ShowPoint4 = Input { Value = 0, },
            ShowLUT1 = Input { Value = 0, },
            ShowLUT2 = Input { Value = 0, },
            ShowLUT3 = Input { Value = 0, },
            ShowLUT4 = Input { Value = 0, },
            Image1 = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 482.667, 55.2424 } },
      },
      CustomTool1LUTIn1 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 204, Green = 0, Blue = 0 },
         NameSet = true,
      },
      CustomTool1LUTIn2 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 0, Green = 204, Blue = 0 },
         NameSet = true,
      },
      CustomTool1LUTIn3 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 0, Green = 0, Blue = 204 },
         NameSet = true,
      },
      CustomTool1LUTIn4 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 204, Green = 204, Blue = 204 },
         CtrlWZoom = false,
         NameSet = true,
      }
   }
}


This provides no falloff, just a slight widening of the accepted values in case it needs to catch a bit more to account for noise or floating point imprecision.

edit: I should break down the expression some since it has nested if statements.

In a CustomTool, you can use c1 to represent "this channel's value." This makes it quick to copy an expression into all three channels without having to change r1 to g1 and b1. I treated alpha slightly differently--it tests the red channel instead of itself, on the assumption that you want the pixels that test false to also be transparent.

This expression uses a nested if statement, which I'll describe in plain language, then show the actual code.

If a channel's value is less than the target value, minus the threshold, then the pixel is black, otherwise, if the channel's value is greater than the target value, plus the threshold, then the pixel is black. If neither of those things is true, then output the original value.

if(c1 < n1 - n2, 0, if(c1 > n1 + n2, 0, c1))

The if() statement has three arguments: A test, the value to return if the test passes, and the value to return if the test fails. In this case, if c1 is less than the target, it evaluates as "true" and returns the 0. If it is not less than the target, it evaluates as false and runs the second if statement.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

Dazzer

  • Posts: 228
  • Joined: Sat Aug 24, 2019 8:31 am
  • Real Name: Daz Harris

Re: Most efficient way to isolate certain colors or brightne

PostWed Aug 17, 2022 12:45 pm

Hardy- wrote:
When you go to the Matte section you will find a checkbox "Invert Matte". Just click that.


Thanks, that works!

Bryan Ray wrote:I just read the original request again and have another notion. If you only want to keep the exact code value, then a CustomTool is the way to go.


Thanks Brian, you're going deep, gonna dig into this!

Return to Fusion

Who is online

Users browsing this forum: No registered users and 47 guests