com.unity.cinemachine icon indicating copy to clipboard operation
com.unity.cinemachine copied to clipboard

Incorrect Gaussian function formula in GaussianFilter?

Open trainINT opened this issue 6 years ago • 2 comments

Sorry in advance if I'm incorrect because I only learned about this concept recently, but shouldn't the sigma in the denominator of the Gaussian kernel formula be outside of the Mathf.Sqrt function like so? (float)(Math.Exp(-(i * i) / (2 * sigma * sigma)) / (sigma * Math.Sqrt(2.0 * Math.PI)))

trainINT avatar Jul 27 '19 14:07 trainINT

hmmm... actually it seems that the denominator ought to be 2 * pi * sigma^2, which is different both from what is there and from what you're suggesting. Thanks for the catch!

On Sat, Jul 27, 2019 at 10:34 AM Luke Lee [email protected] wrote:

Sorry in advance if I'm incorrect because I only learned about this concept recently, but shouldn't the sigma in the denominator of the Gaussian kernel formula https://github.com/Unity-Technologies/upm-package-cinemachine/blob/59d27bd58cfab07c399409c009e986421bc848f2/Runtime/Core/GaussianFilter.cs#L27 be outside of the Mathf.Sqrt function like so? (float)(Math.Exp(-(i * i) / (2 * sigma * sigma)) / (sigma * Math.Sqrt(2.0

  • Math.PI)))

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Unity-Technologies/upm-package-cinemachine/issues/19?email_source=notifications&email_token=ABRAQUSJMH3ZIPZAADGEKMTQBRMF3A5CNFSM4IHJQ4J2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HB3HP3A, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRAQUXGWITZ6GINLH6ZZQTQBRMF3ANCNFSM4IHJQ4JQ .

-- Gregory Labute Software Developer, Cinematics Unity Technologies Montreal, Canada [email protected]

glabute avatar Jul 29 '19 14:07 glabute

I think your formula actually applies the Gaussian filter twice as in the 2D case used in image processing (where one often filters once for the X axis and another time for the Y axis). My formula is for the 1D case which should be applicable here since we are only dealing with a 1D array.

trainINT avatar Sep 02 '19 03:09 trainINT