Domanda

I found this function somewhere, quite a while ago. I do not exactly know what it is doing. I use it to manipulate a simplex noise output (with greyscale values between 0 and 255), but would like to understand it better.

int ExponentFilter(int value, int cover, double sharpness)
{
    int c = value - (255 - cover);
    if(c < 0)
        c = 0;
    return 255 - ((std::pow(sharpness,c)) * 255);
}

I use it like:

ExponentFilter(n,140,0.98f)

Where n is my value between 0 and 255.

È stato utile?

Soluzione

cover is how "shielded" the signal is from being totally cut off. cover 140 means that the 140 highest (brightest) values (116-255) can result in output > 0.

sharpness describes how fast the light fades. 0,98 means that the light fades about twice as fast, but the fading effect is not linear, it is reduced for darker areas.

I would expect this filter to darken and sharpen overexposed images.

Exponentfilter is a fitting name, since the sharpness function uses exponents (pow is the exponent function).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top