图像处理之三种常见双立方插值算法

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

图像处理之三种常见双立方插值算法

图像处理之三种常见双立方插值算法双立方插值计算

涉及到16个像素点,其中(i’, j’)表示待计算像素点在源图像

中的包含小数部分的像素坐标,dx表示X方向的小数坐标,dy表示Y方向的小数坐标。具体可以看下图:

根据上述图示与双立方插值的数学表达式可以看出,双立方插值本质上图像16个像素点权重卷积之和作为新的像素值。其中R(x)表示插值表达式,可以根据需要选择的表达式不同。常见有基于三角取值、Bell分布表达、B样条曲线表达式。1. 基于三角形采样数学公式为

最简单的线性分布,代码实现如下:[java] view plain copy private double triangleInterpolation( double f ) { f =

f / 2.0; if( f < 0.0 ) { return ( f +

1.0 ); } else { return ( 1.0 -

f ); } } 2.基于Bell分布采样的数学公式如下:

Bell分布采样数学公式基于三次卷积计算实现。代码实现如下:[java] view plain copy private double

bellInterpolation( double x ) { double f = ( x / 2.0 ) * 1.5; if( f > -1.5 && f < -0.5 )

{ return( 0.5 * Math.pow(f + 1.5, 2.0)); } else if( f > -0.5 && f < 0.5 )

{ return 3.0 / 4.0 - ( f * f ); } else if( ( f > 0.5 && f < 1.5 ) )

{ return( 0.5 * Math.pow(f - 1.5, 2.0)); } return 0.0; } 3.基于B样条曲线采样的数学公式如下:

是一种基于多项式的四次卷积的采样计算,代码如下:[java] view plain copy private double

bspLineInterpolation( double f ) { if( f < 0.0 )

{ f = -f; } if( f >= 0.0

&& f <= 1.0 ) { return ( 2.0 / 3.0 ) + ( 0.5 ) * ( f* f * f ) - (f*f); } else if( f >

1.0 && f <=

2.0 ) { return 1.0 / 6.0 * Math.pow( ( 2.0 - f ),

3.0 ); } return

1.0; } 实现图像双立方插值的完整源代码如下:[java] view plain copy package com.gloomyfish.zoom.study; import java.awt.image.BufferedImage; import

java.awt.image.ColorModel; import

com.gloomyfish.filter.study.AbstractBufferedImageOp; public class BicubicInterpolationFilter extends AbstractBufferedImageOp { public final static int TRIANGLE__INTERPOLATION = 1; public final static int BELL__INTERPOLATION = 2; public final static int BSPLINE__INTERPOLATION = 4; public

final static int CATMULLROOM__INTERPOLATION = 8; public final static double B = 0.0; public final static double C = 0.5; // constant private int destH; // zoom height private int destW; // zoom width private int type; public BicubicInterpolationFilter()

{ this.type =

BSPLINE__INTERPOLATION; } public void setType(int type) { this.type = type; } public void setDestHeight(int destH) { this.destH = destH; } public void setDestWidth(int destW) { this.destW = destW; }

private double bellInterpolation( double x )

{ double f = ( x / 2.0 ) * 1.5; if( f >

-1.5 && f < -0.5 )

{ return( 0.5 * Math.pow(f + 1.5,

2.0)); } else if( f > -0.5 &&

f < 0.5 ) { return 3.0 / 4.0 - ( f * f ); } else if( ( f > 0.5 && f < 1.5 ) ) { return( 0.5 *

Math.pow(f - 1.5, 2.0)); } return

0.0; } private double bspLineInterpolation( double f ) { if( f <

相关文档
最新文档