Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Adobe, the Adobe logo, Lightroom, and Pixel Bender are either registered trademarks or
trademarks of Adobe Systems Inc. in the United States and/or other countries. All other
trademarks are the property of their respective owners.
The information in this document is furnished for informational use only, is subject to change
without notice, and should not be construed as a commitment by Adobe Systems Inc. Adobe
Systems Inc. assumes no responsibility or liability for any errors or inaccuracies that may appear in
this document. The software described in this document is furnished under license and may only
be used or copied in accordance with the terms of such license.
Adobe Systems Inc., 345 Park Avenue, San Jose, California 95110, USA
Adobe Pixel Bender Kernel Filter Writing
Tutorial
This tutorial assumes the user installed the Adobe® Pixel BenderTM toolkit and has a rudimentary
knowledge of image processing.
There also is a menu which will lets you control some toolkit settings.
From:
dst = sampleNearest(src,outCoord());
To:
dst = 0.5 * sampleNearest(src, outCoord());
From:
dst = 0.5 * sampleNearest(src, outCoord());
To:
float4 inputColor = sampleNearest(src, outCoord());
The new code saves the input color in a temporary variable of type float4. The float4 has
the red, green, and blue channels in the first three elements and the alpha channel in the last
element. These channels are accessible by using the first letter of their name after the dot
operator, as in the last two lines above.
From:
dst.rgb = 0.5 * inputColor.rgb;
To:
dst.rgb = pow(inputColor.rgb, float3(0.5));
We pass in the three channels to the same function. We can do this because the built-in function
pow() can support the float, float2, float3, and float4 types. We must add the
float3() constructor around the constant value, because the types of the two inputs to pow
must match.
Add the following line of code just before the evaluatePixel () function:
parameter float exposure;
From:
dst.rgb = pow(inputColor.rgb, float3(0.5));
To:
dst.rgb = pow(inputColor.rgb, float3(1.0 - exposure));
Now click Run. In the parameter user-interface portion of the toolkit, you should now see a slider
for the exposure parameter. You can slide the exposure slider to adjust the image. The 1.0 setting
is used to switch the exposure, so a positive exposure value brightens the image.
We use parameter metadata to specify the limits and default values of the parameters. We now
have a more intuitive limit around our slider, and we have enabled darkening.
Final source
<languageVersion : 1.0;>
kernel NewFilter
< namespace : "your namespace";
vendor : "your vendor";
version : 1;
description : "your description";
>
{
input image4 src;
output pixel4 dst;
void
evaluatePixel()
{
float4 inputColor = sampleNearest(src, outCoord());
dst.rgb = pow(inputColor.rgb, float3(1.0 - exposure));
dst.a = inputColor.a;
}
}
See also
Pixel Bender toolkit Install/Wiki: http://www.adobe.com/go/pixelbender_toolkit