Nokia Imaging SDK で赤目軽減アルゴリズムを実装しようとしています。私は目の円を選ぶためのコントロールを書いたので、セグメンテーション/顔検出フェーズは必要ありません(円内にポイントリストがあります)-私はそれを次のように実装しました:
protected override void OnProcess(PixelRegion sourcePixelRegion, PixelRegion targetPixelRegion)
{
int currentRow = 0;
targetPixelRegion.ForEachRow((index, width, position) =>
{
for (int x = 0; x < width; ++x)
{
uint currentPixelColor = sourcePixelRegion.ImagePixels[index + x];
if (_selectedRegionProvider.IsPointInSelectedRegion(position.X + x, position.Y + currentRow))
{
uint alphaChannel = (currentPixelColor & AlphaBitMask) >> 24;
uint redChannel = (currentPixelColor & RedBitMask) >> 16;
uint greenChannel = (currentPixelColor & GreenBitMask) >> 8;
uint blueChannel = (currentPixelColor & BlueBitMask);
float greenBlueChannelAvg = (greenChannel + blueChannel)/2.0f;
float redIntensity = (float) (redChannel/greenBlueChannelAvg);
if (redIntensity > 0.5)
redChannel = Math.Min(255, (uint)((greenChannel+blueChannel)/2.0));
currentPixelColor = (alphaChannel << 24) | (redChannel << 16) | (greenChannel << 8) | blueChannel;
}
targetPixelRegion.ImagePixels[index + x] = currentPixelColor;
}
currentRow++;
});
}
ここ
AlphaBitMask = 0xFF000000
で
RedBitMask = 0x00FF0000
、、、
GreenBitMask = 0x0000FF00
_
BlueBitMask = 0x000000FF
しかし、私は奇妙な結果を得ます:
問題は、Nokia Imaging SDK がアルファ ブレンディングを使用するかどうかです。アルファチャンネルはどうすればいいですか? もう 1 つの重要な質問 - 対処した人はいCustomFilterBase
ますか? ポイントのリストのみを処理するにはどうすればよいですか (_selectedRegionProvider.GetAllSelectedPoints()
ポイントの IEnumerable を返すものを使用できOnProcess
ます)。