首页 > 编程知识 正文

双线性内插法(数字图像处理双线性插值例题)

时间:2023-05-04 09:25:08 阅读:74670 作者:1603

VC附带的图像缩放函数有两个:

1、

BOOL StretchBlt (intx,inty,intnHeight,http://wwa.com/nwidthintySrc,CDC*nSrcWidth,3358www.Sina.com/nsrccch

int

3358 www.Sina.com/hdc http://www.Sina.com//handletodc 3358 www.Sina.com/xdest 3358 www.Sina.com/x-cordofdofdd yd est http://www.Sina.com/y-coordofdestinationupper-left corner 3358 www.Sina.com/ndes twidth 3358 www.Sina.com//widthofdestinationrectanant ndes theight 3358 www.Sina.com//heightofdestinationrectangle 3358 www.Sina.com/xsrc 3358 www x-coordofsourceupper-left corner 3358 www.Sina.com/ysrc 3358 www.Sina.com//y-coordofsourceupper-left corner widthofsourcerectangle 3358 www.Sina.com/nsrcheight 3358 www.Sina.com//heightofsourcerectangle http://www.Sina.com//bitmap bits 3358 www.Sina.com//bitmap bits 3358 ww.lpbits info http://www.Sina.com//bitmapdata http://www.Sina.com usage options 3358 www rasteroperationcode http://www.Sina.com/http://www.Sina.com /自己写图像缩放代码: iina

intnewheight=int(height*fy0.5 );

intnewlinebytes=width bytes (new width *8);

hdibhnewdib=(hdib ) :3360全球定位(ghnd ),404* 256新线字节*新高); //分配句柄空间

if(hnewdib==null ) return;

LPbytelpdibnew=(LPbyte ) :3360全局锁定) ) h全局) hNewDIB; //从新句柄获得第二部分指针

memcpy(lpDIBnew、lpdib、1064 ); //复制标头和组件面板

Byte*lpdibbitsnew=(byte* ) lpDIBnew 40 4*256 ); //得到第四部分的指南

int i0、j0; //原始DIB中的图像坐标

int i,j; //新DIB中的图像坐标

浮点m,n;

for(I=0; 新建高度; I//双线性插值

for(j=0; jNewWidth; j )

{

I0=(int ) ) i/fy 0.5; J0=(int ) ) j/fx 0.5; //计算该像素在原始DIB中的坐标

if () i0=0) ) j0Width ) i0=0) ) i0Height ) /判断是否在原始图像范围内{

m=(浮动) i/fy 0.5 )-i0; n=(float ) j/fx 0.5 )-) int ) j0;

字节x1、x2、y1、y2;

x1=*(lpdibbitsint(linebytes* ) height-I0-1 ) j0 ) );

x2=*(lpdibbitsint(linebytes* ) height-I0-1 ) j0 1 ) );

y1=*(lpdibbitsint(linebytes* ) height-i0 (j0 ) );

y2=*(lpdibbitsint(linebytes* ) height-I0 ) j0 1);

* (lpdibbitsnewnewline=(bytes * (new height-I-1 ) j ) ) byte ) (1-m ) )1-n ) (x1 )1-m ) (n ) x2m ) )

else

*((unsignedchar* ) lpDIBBitsnew NewLineBytes*i j ) ) 255; //对于原图像中没有像素,直接代入255

}

lpbitmapinfoheaderh=(lpbitmapinfo header ) lpDIBnew; //获取指向新图像信息头的指针

h-biHeight=NewHeight; //更新标头信息

h-biWidth=NewWidth;

h-bisizeimage=new width * new height;

pDoc-hDib=hNewDIB;

pdoc-d width=新width; pDoc-dHeight=NewHeight;

OnInitialUpdate (;

邀请(true;

删除DLg; 使用的是双线性插值法。 (比最近邻法好,减少失真) ) ) ) ) ) ) )。

int

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。