Search code examples
c#gaussianexponential

Exponential Decay Surrounding Bounding Box


I didn't really know how to phrase this question, its quite strange.

I have a 1d array of intensity values, and a bounding box (integer start and end point in the array). I want to keep the values within the bounding box the same, but diminish the values outside the box in an exponential way (ie the further away they are the more they are diminished). Should look something like a gaussian with a plateau where the bounding box is. Can anyone give an example of how I could do this? My brain is not working right tonight, thanks.

UPDATE:

I used this:

if (j < low) a[j] *= Logistic(t*(j + (6f/t) - low));
else if (j > high) a[j] *= Logistic(-t*(j - (6f/t) - high));

private double Logistic(double x)
{
    return (1 / (1 + Math.Exp(-x)));
}

Solution

  • Something like

    if (n<low)
      a[n] *=  exp(-t*(low-n));
    else if (n>high)
      a[n] *=  exp(-t*(n-high));
    else 
      a[n] *=  1.0;
    

    with a parameter t? Indeed the last else branch may be omitted.