用C语言实现图像最近邻插值和双线性插值算法.pdf
文本预览下载声明
2010
最近邻插值和双线
性插值算法
用C 语言实现
用C 语言实现位图的最近邻插值算法和双线性插值算法
彭军
利达光电股份有限公司
2010/5/6
2010 年4 月
最近邻插值和双线性插值算法
30 日
/*
File Name: resize.c
Description: resize a bitmap using some specified algorithm
Author: Peng Jun
Bitmap.c and Bitmap.h, you can see my other articles.
*/
#include stdio.h
#include stdlib.h
#include Bitmap.h
int main(int argc, char *argv[])
{
Bitmap *bmp = (Bitmap*)malloc( sizeof(Bitmap) );
BYTE flag = 0;
BYTE *p = 0;
DWORD x = 0, y = 0, width = 0, height = 0, line_width = 0;
double a = 0.0, b = 0.0;
double fb1 = 0.0, fb = 0.0;
double x11 = 0, x12 = 0, x21 = 0, x22 = 0;
double f = 0.0, min = 99990.0, max = -99999.0, nf = 0.0;
double x1 = 0.0, x2 = 0.0, x3 = 0.0, x4 = 0.0;
利达光电股份有限公司 | 彭军 2
2010 年4 月
最近邻插值和双线性插值算法
30 日
if( argc == 5 )
{
flag = 1;
width = atoi( argv[3] );
height = atoi( argv[4] );
}
else if( argc == 6 )
{
width = atoi( argv[3] );
height = atoi( argv[4] );
flag = atoi( argv[5] );
}
else
{
printf(Usage: resize img_src img_dst width height
interp_method\n);
printf(For more information, please read the ReadMe.txt.\n);
free( bmp );
return -1;
}
利达光电股份有限公司 | 彭军 3
2010 年4 月
最近邻插值和双线性插值算法
30 日
load_bitmap( argv[1], bmp );
if( ISEMPTY( bmp ) || !IS8BITS( bmp ) )
{
free( bmp );
return -1;
}
line_width = ( width * bmp-bit_count + 31 ) / 32 * 4;
显示全部