The purpose of this step is to convert the “blurred” edges in the image of the gradient magnitudes to “sharp” edges. Basically this is done by preserving all local maxima in the gradient image,
and deleting everything else. The algorithm is for each pixel in the gradient image:
Round the gradient direction θ to nearest 45◦ , corresponding to the use of an 8-connected neighbourhood.
Compare the edge strength of the current pixel with the edge strength of the pixel in the positive and negative gradient direction. I.e. if the gradient direction is north (theta = 90◦ ), compare with the pixels to the north and south.
If the edge strength of the current pixel is largest; preserve the value of the edge strength. If not, suppress (i.e. remove) the value