本代码主要工作是对图片的数据进行高斯平滑处理。高斯平滑有另一种意思叫“低通滤波”,即LPF,一张图片针对色差进行研究,当色差比较大的地方,便是高频信号较强的地方,色差越大,高频信号越强。
根据这现象,可想采用相邻的像素点三色度平均或均分的方式,降低高频强度,使图片变得更平滑。
本次研究,采用1,1,4,1,1的方式进行均分,针对一个原像点,原像素点占0.5,上下左右各占0.125。
| 0 | 1 | 0 |
| 1 | 4 | 1 |
| 0 | 1 | 0 |
实现代码如下:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ADD 0
#define SUB 1
#define MUL 2
#define DIV 3
#define Y_ADD 0
#define Y_SUB 1
#define CUR_POS(x,y,width) ((y)*width+(x))
#define X_POS(pos) ((pos)%PicWidth)
#define Y_POS(pos) ((pos)/PicWidth)
#define RANGE(x) (x<0?0:(x>255?255:x))
//---------------picattribute----------------------
unsignedint PicWidth;
unsignedint PicHeight;
//----------------functions---------------------------
voidGraphBrightHandle(unsigned char *src, unsigned char *dest, int size, int type,double num);
voidGraphLPFHandle(unsigned char *src, unsigned char *dest, unsigned int Width,unsigned int Height);
//---------------------main------------------------
intmain(int argc,char** argv)
{
int nErrorCode=0;
FILE *fin;
FILE *fout_Bright;
FILE *fout_LPF;
char szInFilename[256];
char szOutFilename[256];
if(argc>=2)
{
strcpy(szInFilename ,argv[1]);
}
else
{
strcpy(szInFilename, "44.raw");
} &nb