二、实现
GIMP中有IIR型高斯滤波的实现,代码位于contrast-retinex.c中,读者可自行查看。下面给出本人实现的核心代码:
typedef struct
{
float B;
float b[4];
} gauss_coefs;
//参数计算
void compute_coefs3(gauss_coefs *c,float sigma)
{
float q, q2, q3;
if (sigma >= 2.5)
{
q = 0.98711 * sigma - 0.96330;
}
else if ((sigma >= 0.5) && (sigma < 2.5))
{
q = 3.97156 - 4.14554 * (float) sqrt ((float) 1 - 0.26891 * sigma);
}
else
{
q = 0.1147705018520355224609375;
}
q2 = q * q;
q3 = q * q2;
c->b[0] = 1/(1.57825+(2.44413*q)+(1.4281 *q2