feat(validation): add input validation for Bilateral and Blma constructors; enhance Butter and Mgdi calculations with NaN handling

This commit is contained in:
Miha Kralj
2025-12-25 20:53:56 -08:00
parent ac8b2dbb3f
commit 0d077c24d8
15 changed files with 195 additions and 66 deletions
+4 -1
View File
@@ -265,6 +265,9 @@ public sealed class Bilateral : AbstractBase
{
if (period <= 0)
throw new ArgumentException("Period must be greater than 0", nameof(period));
if (destination.Length < source.Length)
throw new ArgumentException("Destination must have length >= source length", nameof(destination));
// Precalculate spatial weights
double sigmaS = Math.Max(period * sigmaSRatio, 1e-10);
@@ -304,7 +307,7 @@ public sealed class Bilateral : AbstractBase
for (int i = 0; i < source.Length; i++)
{
double val = source[i];
if (double.IsNaN(val))
if (!double.IsFinite(val))
{
val = lastValid;
}