📄 imagesmooth.c
字号:
/************************************************************************************************
* Function :the is a inter face of image process,user only can change mem from 54 bytes
* Desinger : wujiancong
* Date : 04.05.T07
* Verision : 5.0
* Parameter : FILE *fptr; pointer to source file pointer
*************************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
unsigned char *mem;
unsigned char *buffer;
static int srcwidth=720;
static int srcheight=588;
/**********************************************************************************
*
*
* Image Smooth
*
*
*************************************************************************************/
// template
int itemplate(unsigned char *src,unsigned char *dst,int width,\
int height,int tempw,int temph,int tempmx,int tempmy,float fcoef,float *fparry)
{
int i,j,k,l,m,n;
long widthbyte=srcwidth;
float fresult0;
for(i=tempmx;i<height-tempmx;i++)
{
for(j=tempmy;j<width-tempmx;j++)
{
fresult0=0.0;
for(k=0;k<temph;k++)
{
for(l=0;l<tempw;l++)
{
m=i-tempmy+k;n=(j-tempmx+l);
fresult0+=(float)(*(src+m*widthbyte+n))*(*(fparry+k*tempw+l));
}
}
fresult0*=fcoef;
fresult0=fabs(fresult0);
if(fresult0>255) *(dst+i*widthbyte+j)=(unsigned char)255;
else *(dst+i*widthbyte+j)=(unsigned char)(fresult0+0.5);
}
}
return 0;
}
int ImageSmooth()
{
int i,j;
int temph=3,tempw=3;
int tempmx=1,tempmy=1;
int rowbi=srcwidth*3;
float ftmpc=1.0/16.0;
float arry[9]={1.0,2.0,1.0,2.0,4.0,2.0,1.0,2.0,1.0};
for(i=0;i<srcheight;i++)
for(j=0;j<rowbi;j++)
*(buffer+i*rowbi+j) = *(mem+i*rowbi+j);
itemplate( mem,buffer,srcwidth,srcheight,tempw,temph,tempmx,tempmy,ftmpc,arry);
for(i=0;i<srcheight;i++)
for(j=0;j<rowbi;j++)
*(mem+i*rowbi+j)=*(buffer+i*rowbi+j);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -