OpenCL で線形補間を行っていますが、結果は期待どおりではありません。そこで、以下に示すカーネルコードの簡単なテストを行いました。
const sampler_t sampler = CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR | CLK_ADDRESS_CLAMP_TO_EDGE;
// Kernel block.
kernel void interpolate(
global float4*input,
image3d_t image,
global float4*output)
{
size_t i = get_global_id(0);
float4 coord = input[i];
float4 tap = read_imagef(image, sampler, coord);
output[i] = tap;
}
2x2x2 画像のピクセル (RGBA) は次のとおりです。
cl_float4 image_data[8] = {
{0, 0, 0, 0},
{100, 0, 0, 0},
{0, 100, 0, 0},
{100, 100, 0, 0},
{0, 0, 100, 0},
{100, 0, 100, 0},
{0, 100, 100, 0},
{100, 100, 100, 0},
};
11 の座標 ((0, 0, 0), (0.1, 0.1, 0.1)...(1, 1, 1)、ステップ 0.1 で 0 から 1) を使用して画像を読み取りました。 (0, 0, 0), (10, 10, 10)...(100, 100, 100) ですが、次のようになりました。
coordinate:0.000000, result: 0.000000
coordinate:0.100000, result: 0.000000
coordinate:0.200000, result: 0.000000
coordinate:0.300000, result: 10.156250
coordinate:0.400000, result: 30.078125
coordinate:0.500000, result: 50.000000
coordinate:0.600000, result: 69.921875
coordinate:0.700000, result: 89.843750
coordinate:0.800000, result: 100.000000
coordinate:0.900000, result: 100.000000
coordinate:1.000000, result: 100.000000
座標が 0.25 より小さいか 0.75 より大きい場合、エッジ値を返すだけです。
誰でもこれを説明できますか?ありがとう。