From 6e78f4c8fdb16e4a95dd683539b3f06530a77f35 Mon Sep 17 00:00:00 2001 From: giriPHM <94209767+giriPHM@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:43:34 -0500 Subject: [PATCH] Fix Gaussian filter (#45) --- Project.toml | 2 +- src/gaussian_filter.jl | 10 ++++++---- src/new_filter.jl | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 src/new_filter.jl diff --git a/Project.toml b/Project.toml index c211d5c3..abb457ef 100644 --- a/Project.toml +++ b/Project.toml @@ -50,7 +50,7 @@ DSP = "0.6, 0.7" DocStringExtensions = "0.8, 0.9" ElasticArrays = "1" FFTW = "1" -FillArrays = "0.8.4, 0.9, 0.10, 0.11, 0.12, 0.13, 1" +FillArrays = "0.13, 1" FunctionChains = "0.1" GPUArraysCore = "0.1" IntervalSets = "0.7" diff --git a/src/gaussian_filter.jl b/src/gaussian_filter.jl index a59ca72a..2fdf161b 100644 --- a/src/gaussian_filter.jl +++ b/src/gaussian_filter.jl @@ -27,10 +27,10 @@ $(TYPEDFIELDS) length::T = 100. "the amount of standard deviations to cover in the gaussian window" - alpha::U = 1. + alpha::U = 3. "scaling factor" - beta::U = 100. + beta::U = 1. end export Gauss1DFilter @@ -67,8 +67,10 @@ function gaussian_coeffs(N::Int, sigma::V, alpha::U, beta::U xᵢ::T = -sigma*alpha Δx::T = abs(2*xᵢ)/(N-1) for i=Base.OneTo(N) - y[i] = beta*exp(-0.5*(xᵢ/alpha)^2) / N + y[i] = beta*exp(-0.5*(xᵢ/sigma)^2) xᵢ += Δx end - y + sum_arr=sum(y) + y_norm= y./sum_arr + y_norm end \ No newline at end of file diff --git a/src/new_filter.jl b/src/new_filter.jl new file mode 100644 index 00000000..b4f98baa --- /dev/null +++ b/src/new_filter.jl @@ -0,0 +1 @@ +#Just kidding. lol