(sigma: f32)
| 111 | } |
| 112 | |
| 113 | fn kernel<const S: usize>(sigma: f32) -> [f32; S] { |
| 114 | let mut kernel = [0.0; S]; |
| 115 | let mid = S / 2; |
| 116 | |
| 117 | // calculate the Gaussian distribution |
| 118 | let variance = sigma.powi(2); |
| 119 | let factor = 1.0 / (2.0 * 3.141592 * variance); |
| 120 | let mut sum = 0.0; |
| 121 | for i in 0..S { |
| 122 | let x = (i as i32 - mid as i32) as f32; |
| 123 | let value = factor * (-x.powi(2) / (2.0 * variance)).exp(); |
| 124 | kernel[i] = value; |
| 125 | sum += value; |
| 126 | } |
| 127 | sum *= 0.997; |
| 128 | // normalize the kernel |
| 129 | for i in 0..S { |
| 130 | kernel[i] /= sum; |
| 131 | } |
| 132 | |
| 133 | kernel |
| 134 | } |
| 135 | fn blur( |
| 136 | fx: isize, |
| 137 | fy: isize, |
nothing calls this directly
no outgoing calls
no test coverage detected