Gaussian blur is the most widely used smoothing filter in image processing and computer vision. The filter is defined by a 2D kernel whose weights follow a Gaussian distribution, giving more influence to nearby pixels and less to distant ones.
Given an odd kernel size and a standard deviation sigma, generate the normalized 2D Gaussian kernel.
Input:
size = 3, sigma = 1.0
Output (rounded to 4 decimals):
[[0.0751, 0.1238, 0.0751], [0.1238, 0.2042, 0.1238], [0.0751, 0.1238, 0.0751]]
The center has the largest weight. The kernel is symmetric and sums to 1.0.
Input:
size = 1, sigma = 1.0
Output:
[[1.0]]
A single-element kernel always normalizes to 1.0 regardless of sigma.
The center of a kernel of size n is at index n // 2. Offsets x and y measure distance from this center.
After computing all raw Gaussian values, divide each by the total sum. This ensures the kernel sums to 1.0 without needing the full Gaussian normalization constant.
Sign in to take notes on this problem
Accepts: number
Accepts: number
Gaussian blur is the most widely used smoothing filter in image processing and computer vision. The filter is defined by a 2D kernel whose weights follow a Gaussian distribution, giving more influence to nearby pixels and less to distant ones.
Given an odd kernel size and a standard deviation sigma, generate the normalized 2D Gaussian kernel.
Input:
size = 3, sigma = 1.0
Output (rounded to 4 decimals):
[[0.0751, 0.1238, 0.0751], [0.1238, 0.2042, 0.1238], [0.0751, 0.1238, 0.0751]]
The center has the largest weight. The kernel is symmetric and sums to 1.0.
Input:
size = 1, sigma = 1.0
Output:
[[1.0]]
A single-element kernel always normalizes to 1.0 regardless of sigma.
The center of a kernel of size n is at index n // 2. Offsets x and y measure distance from this center.
After computing all raw Gaussian values, divide each by the total sum. This ensures the kernel sums to 1.0 without needing the full Gaussian normalization constant.
Sign in to take notes on this problem
Accepts: number
Accepts: number