0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Look Up Table の逆引き

Posted at

概要

非リニアの色空間からリニア空間への変換などあ、Look Up Table を作って変換すれば良いが、リニア空間から、非リニア空間への変換をやろうとすると、LookUpTableが巨大化しすぎて実用範囲から外れてしまう。

以下に、Look Up Table の逆引き関数を載せる。
なんといっても最大の特徴は、条件分岐が発生していないことである!!
これは革命である(笑

※ただし、Look Up Table は小→大の関係が維持されていること。

int	InverseGamma( float value, const float * GammaTable )
{
	int	index	= 0;

	index	=  ((GammaTable[      128]) <= value) << 7;
	index	+= ((GammaTable[index+ 64]) <= value) << 6;
	index	+= ((GammaTable[index+ 32]) <= value) << 5;
	index	+= ((GammaTable[index+ 16]) <= value) << 4;
	index	+= ((GammaTable[index+  8]) <= value) << 3;
	index	+= ((GammaTable[index+  4]) <= value) << 2;
	index	+= ((GammaTable[index+  2]) <= value) << 1;
	index	+= ((GammaTable[index+  1]) <= value) << 0;

	return	index;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?