Help with Gaussian filter

I have to implement a gaussian filter in a code. So I wrote this
GLfloat Gauss2D(double m, double n, double sigma)
{
for (int m = -2; m <= 2; m++) {
for (int n = -2; n <= 2; n++) {
double feld;
feld = exp((-1.0f) * (m*m + n*n) / (2 * sigma*sigma));
feld = feld / (2 * M_PI * sigma * sigma);
}
}

return 0;

}
and after that I have to try different kernel values, implement the NxN gauss kernel and normalize the kernel, but I didnt really understand what I have to write exactly. If someone could help me a litle bit, Im gonna be really thankfull

void SetKernelGauss(std::vector<GLfloat>& kernel,
int kernelSize,
double sigma)
{
//
// the 2D kernel is stored in a 1D array
// in a row major layout.
//
// |6 7 8| |(2,0) (2,1) (2,2)|
// |3 4 5| or |(1,0) (1,1) (1,2)|
// |0 1 2| |(0,0) (0,1) (0,2)|
//
// SetKernelElement() allows to use 2D matrix
// coordinates to set its values
//
// Note: The filtered RGB-value of a pixel at position
// (x,y) is determined as the filter-weighted sum
// of its pixel neighborhood:

kernel.resize(kernelSize*kernelSize);

// setting identity kernel (see function implementation for details)
SetKernelIdentity(kernel, kernelSize);

}
- you need to post the definition of the custom type GLfloat
- Gauss2D cannot return 0, only main() returns 0 in C++ and, in any case, Gauss2D() is declared to return type GLfloat by value
- please use code-tags
- give some background in plain English what you have so far and what you still need to do ... thanks
1
2
3
4
5
6
7
8
9
10
11
12
GLfloat Gauss2D(double m, double n, double sigma)
{
    for (int m = -2; m <= 2; m++) {
        for (int n = -2; n <= 2; n++) {
            double feld;
            feld = exp((-1.0f) * (m*m + n*n) / (2 * sigma*sigma));
            feld = feld / (2 * M_PI * sigma * sigma);
        }
    }

    return 0;
}


is functionally equivalent to:
1
2
3
4
GLfloat Gauss2D(double m, double n, double sigma)
{
    return 0;
}


- Gauss2D cannot return 0, only main() returns 0 in C++

Patently untrue.
yeah, my bad
Topic archived. No new replies allowed.