TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Gaussian Blur Kernel

Computer Vision
Medium

Generate a normalized square Gaussian blur kernel. For every position, measure offsets xxx and yyy from the center and compute:

G(x,y)=exp⁡(−x2+y22σ2)G(x,y)=\exp\left(-\frac{x^2+y^2}{2\sigma^2}\right)G(x,y)=exp(−2σ2x2+y2​)

Here, σ\sigmaσ is the supplied standard deviation. Divide every weight by the sum of all unnormalized weights so the final kernel sums to one. Return the kernel as a two-dimensional list of floats.

Loading visualization...

Examples

Input: size = 3, sigma = 1

Output: [[0.075114, 0.123841, 0.075114], [0.123841, 0.20418, 0.123841], [0.075114, 0.123841, 0.075114]]

Explanation: The center receives the largest weight, the kernel is symmetric, and all weights sum to one.

Input: size = 1, sigma = 1

Output: [[1]]

Hint 1

Use size // 2 as the center coordinate.

Hint 2

Accumulate all unnormalized weights before dividing each value by their total.

Requirements

  • Center coordinates around the middle kernel element
  • Compute one Gaussian weight per position
  • Normalize all weights by their total
  • Return a square two-dimensional list

Constraints

  • Size is a positive odd integer
  • Sigma is positive
Try Similar Problems
Conv2d Image FilteringSobel Edge DetectionMorphological OperationsBilinear InterpolationImage Histogram

Sign in to take notes on this problem

Case 1
Case 2

Accepts: number

Accepts: number

You must run your code first.
PrevNext

Gaussian Blur Kernel

Computer Vision
Medium

Generate a normalized square Gaussian blur kernel. For every position, measure offsets xxx and yyy from the center and compute:

G(x,y)=exp⁡(−x2+y22σ2)G(x,y)=\exp\left(-\frac{x^2+y^2}{2\sigma^2}\right)G(x,y)=exp(−2σ2x2+y2​)

Here, σ\sigmaσ is the supplied standard deviation. Divide every weight by the sum of all unnormalized weights so the final kernel sums to one. Return the kernel as a two-dimensional list of floats.

Loading visualization...

Examples

Input: size = 3, sigma = 1

Output: [[0.075114, 0.123841, 0.075114], [0.123841, 0.20418, 0.123841], [0.075114, 0.123841, 0.075114]]

Explanation: The center receives the largest weight, the kernel is symmetric, and all weights sum to one.

Input: size = 1, sigma = 1

Output: [[1]]

Hint 1

Use size // 2 as the center coordinate.

Hint 2

Accumulate all unnormalized weights before dividing each value by their total.

Requirements

  • Center coordinates around the middle kernel element
  • Compute one Gaussian weight per position
  • Normalize all weights by their total
  • Return a square two-dimensional list

Constraints

  • Size is a positive odd integer
  • Sigma is positive
Try Similar Problems
Conv2d Image FilteringSobel Edge DetectionMorphological OperationsBilinear InterpolationImage Histogram

Sign in to take notes on this problem

Case 1
Case 2

Accepts: number

Accepts: number

You must run your code first.