I knew the formula but fumbled the normalization part at first.
Start by explaining the 2D Gaussian formula and how to compute distances from the kernel center. Then, walk through the implementation steps: create a k x k grid, compute the Gaussian value for each cell, and normalize by dividing each value by the sum. Finally, discuss practical considerations like handling even k and computational efficiency.
Pro tip: Mention that for even k, the center is between pixels, so you should use (i - (k-1)/2) for coordinates to maintain symmetry. Also, note that normalization ensures the kernel sums to 1, preserving image brightness.
State the 2D Gaussian formula: G(x, y) = (1 / (2 * pi * sigma^2)) * exp(-(x^2 + y^2) / (2 * sigma^2)). Explain that x and y are distances from the center.
Generate a k x k grid where each cell (i, j) has coordinates (x, y) = (i - center, j - center), with center = (k-1)/2. This ensures the kernel is centered.
For each cell, plug x and y into the Gaussian formula to get the unnormalized weight. Optionally, omit the constant factor since it cancels during normalization.
Sum all computed values and divide each by the sum to ensure the kernel sums to 1. This preserves image intensity after convolution.
Mention handling even k (center offset), computational efficiency (separable convolution), and edge cases like sigma=0 or very small sigma.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.