我使用this code example來調整我的WPF應用程序的BitmapImage的亮度和對比度。的HLSL代碼中的相關位是這樣的:爲自定義ShaderEffect創建黑色濾鏡Shader效果
sampler2D input : register(s0);
float brightness : register(c0);
float contrast : register(c1);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 color = tex2D(input, uv);
float4 result = color;
result = color + brightness;
result = result * (1.0+contrast)/1.0;
return result;
}
我想要做的就是添加一些東西過濾掉低強度pixels-的想法是,我想說的是,圖像的任何部分(我只是猜測我必須這樣做每像素)低於一定的閾值,使它黑。我試圖過濾灰度低強度的東西,使更輕的部分彈出更多(這是一個灰度圖像)。然後我會使用滑塊來調整該閾值。
我只是不知道,如果這是一個過濾器或什麼,是希望它只是一個簡單的模塊到上面的代碼。總數nb到HLSL。
函數名稱不應該是main(),而不是threshold()? –
@WaltRitscher:是的,我的錯誤。 –