32 public array $kernel = [];
34 public readonly
float $weightSum;
37 public array $kernel1D = [];
39 public readonly
float $weightSum1D;
41 public function __construct(
public int $smoothSize){
42 $bellSize = 1 / $this->smoothSize;
43 $bellHeight = 2 * $this->smoothSize;
45 for($sx = -$this->smoothSize; $sx <= $this->smoothSize; ++$sx){
46 $bx = $bellSize * $sx;
48 $this->kernel1D[$sx + $this->smoothSize] = sqrt($bellHeight) * exp(-($bx * $bx) / 2);
50 $this->kernel[$sx + $this->smoothSize] = [];
51 for($sz = -$this->smoothSize; $sz <= $this->smoothSize; ++$sz){
52 $bz = $bellSize * $sz;
53 $this->kernel[$sx + $this->smoothSize][$sz + $this->smoothSize] = $bellHeight * exp(-($bx * $bx + $bz * $bz) / 2);
57 $this->weightSum1D = array_sum($this->kernel1D);
58 $this->weightSum = $this->weightSum1D ** 2;