Apply Zero Padding to an Image
Core Vision Operations DS practice problem on Onlearn.
Difficulty: easy.
Topics: Understanding Spatial Dimensions and Convolutional Neural Network Pre-processing, Zero Padding, Padding Modes, Kernel-Image Interaction, Output Feature Map Calculation, Tensor Shape Modification, Computer Vision, Linear Algebra, Digital Image Processing, Deep Learning Pre-processing, Matrix Operations, Spatial Domain Transformations, Feature Map Dimensions, Convolutional Kernel Operations, Boundary Handling, Array Manipulation.
Write a function that takes a 2D grayscale image (represented as a nested list or 2D NumPy array) and an integer 'pad width', and returns a new image padded with zeros on all four sides by the specified width.