Top > エフェクト-色調補正

エフェクト-色調補正

画面の色味を補正するもの。
計算式や実装など本来の物と違ったらごめんなさい。


モノクロ

 effect-color_control-mono.JPG

RGB色空間をYCbCr色空間に変換。
輝度Yだけ取り出す。

const float3 RGBtoY = {0.299, 0.587, 0.114};

// RGBから輝度Yに変換
float y = dot(hrgb, RGBtoY);

// 輝度YをRGBカラーに適用し、モノクロ化
return float4((float3)y, hrgb.a);

サンプル:filemono.fx

セピア

 effect-color_control-sepia.JPG

モノクロ化した後に、Cb, Cr に適当な数値をいれて、再度RGBに戻す。

const float3 RGBtoY = {0.299, 0.587, 0.114};
float3x3 YCbCrtoRGB = {
    {1.0,  0.00000,  1.40200},
    {1.0, -0.34414, -0.71414},
    {1.0,  1.77200,  0.00000},
};

// RGBから輝度Yに変換
// Cb Crには適当な値を入れる
float3 YCbCr;
YCbCr.x = dot(hrgb, RGBtoY);
YCbCr.y = -0.091;
YCbCr.z = 0.056;

// YCbCrからRGBへ復元
return float4(mul(YCbCrtoRGB, YCbCr), hrgb.a);

サンプル:filesepia.fx

ネガポジ反転

 effect-color_control-nega.JPG

色を反転。

float4 ret;
ret.r = 1.0 - hrgb.r;
ret.g = 1.0 - hrgb.g;
ret.b = 1.0 - hrgb.b;
ret.a = hrgb.a;
return ret;

サンプル:filenega.fx

ガンマ補正

 effect-color_control-gamma.JPG

ガンマ補正の式:out = color ^ (1.0f / gamma)
より

return float4(pow(abs(hrgb.rgb), (float3)(1.0 / gamma)), hrgb.a);

サンプル:filegamma.fx

コントラスト調整

 effect-color_control-contrast.JPG

明るい所は明るく、暗い所は暗く強調する。
色は0.0~1.0なので、中間の0.5を基準に上下に引っ張ってます。

return float4(hrgb.rgb * (1.0 + contrast) / 1.0 - contrast * 0.5, hrgb.a);

サンプル:filecontrast.fx


添付ファイル: filesepia.fx 371件 [詳細] filenega.fx 394件 [詳細] filemono.fx 378件 [詳細] filegamma.fx 373件 [詳細] filecontrast.fx 419件 [詳細] fileeffect-color_control-contrast.JPG 452件 [詳細] fileeffect-color_control-gamma.JPG 448件 [詳細] fileeffect-color_control-nega.JPG 456件 [詳細] fileeffect-color_control-mono.JPG 460件 [詳細] fileeffect-color_control-sepia.JPG 443件 [詳細]

リロード   新規 編集 凍結 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2011-08-07 (日) 13:03:09 (4645d)