图像处理:使用输入图像中的像素的强度值进行插值

时间:2015-02-11 17:22:12

标签: image-processing interpolation bicubic

当我们进行图像插值时,我认为我们将使用输入图像中像素的强度值。

(A) 我正在从GPU Gems Chapter 24. High-Quality Filtering读取三次插值的代码。以下是他们代码的片段:

例24-9。过滤四个Texel行,然后将结果过滤为列

float4 texRECT_bicubic(uniform 
   samplerRECT tex,
                       uniform 
   samplerRECT kernelTex,
                       float2 t)
{
  float2 f = frac(t);  // we want the sub-texel portion

   float4 t0 = cubicFilter(kernelTex, f.x,
                          texRECT(tex, t + float2(-1, -1)),
                          texRECT(tex, t + float2(0, -1)),
                          texRECT(tex, t + float2(1, -1)),
                          texRECT(tex, t + float2(2, -1)));

因为他们从frac(t)得到了子纹理元素," t"并不完全在输入图像的像素位置上。 那怎么来" t"直接用于从原始图像中采样强度值,例如" texRECT(tex,t + float2(-1,-1))"?

我个人认为应该使用

t - frac(t)

(B) 来自" Zoom An Image With Different Interpolation Types"

的示例中也是如此

用于Bi-Cubic Interpolation&#34的" GLSL着色器代码片段是:

float a = fract( TexCoord.x * fWidth ); // get the decimal part
float b = fract( TexCoord.y * fHeight ); // get the decimal part

for( int m = -1; m <=2; m++ )
{
    for( int n =-1; n<= 2; n++)
    {
        vec4 vecData = texture2D(textureSampler, 
                           TexCoord + vec2(texelSizeX * float( m ), 
                texelSizeY * float( n )));

我认为我们应该使用:

TexCoord - vec2(a,b)

然后使用m和n

的偏移量

(C)现在我很困惑。我想我们将使用&#34; exact&#34;的强度值。输入图像中的像素。 我们应该采用哪种方式?

0 个答案:

没有答案