smooth: 对图像进行均值平滑滤波,消除噪声
typedef unsigned char uint8;
typedef int sint32;
sint32 IMGW = 256;
// 当前处理图像的宽度
sint32 IMGH = 360;
// 当前处理图像的高度
void smooth(uint8 *lpInBuffer, uint8 *lpOutBuffer, sint32 r, sint32 d)
{
// lpInBuffer: [in] 要平滑的图像数据缓冲区
// lpOutBuffer: [out] 平滑后的图像数据缓冲区
// r: [in] 平滑滤波器半径
// d: [in] 平滑滤波器步长
sint32 x, y, i, j;
uint8 *lpSrc;
uint8 *lpRst;
sint32 sum, num;
if(d == 2)
{
for(y = 0; y < IMGH; y++)
{
for(x = 0; x < IMGW; x++)
{
lpSrc = lpInBuffer + y*IMGW + x;//原图像指针
lpRst = lpOutBuffer + y*IMGW + x;//目标图像指针
sum = 0; //像素和总量
num = 0; //像素量
for(i = -r; i <= r; i+&#