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.