An edge is a sharp change in values within an input array. In a one-dimensional signal, a large difference between successive elements marks an edge; in an image, an abrupt color change marks an edge. Flat regions carry less semantic information than boundaries such as a person’s silhouette. section 10.1.2 section 10.3.2
Convolution detects edges by weighting neighboring values with positive and negative kernel elements. Uniform neighborhoods cancel toward zero, while a sharp transition produces a large positive or negative response. A one-dimensional filter therefore spikes at jump locations, and two-dimensional kernels can distinguish vertical from horizontal edges. section 10.1.2 section 10.3.2
Detecting an image edge with PyTorch
For a grayscale image, a fixed 2 × 2 kernel such as [[−0.25, 0.25], [−0.25, 0.25]] responds to horizontal changes across its columns. PyTorch represents the image and kernel as four-dimensional tensors, shaped N × C × H × W, then applies Conv2d with the weights held fixed. section 10.3.3
Figure 10.6 Graph of the input array solid) and output array (dashed) from figure 10.3. The output the input. Edges provide vital clues for understanding the signal.
Compare the input signal with its convolution output and see how response spikes align with edge locations. section 10.1.2
