# Dilate/Erode: Difference between Step and Distance mode?

What is the difference between the Dilate/Erode nodes Step and Distance modes? I can tell they are doing different things, but I'm interested in the technical details and the documentation does not cover it.

In Step and Distance mode, the Erode/Dilate node samples through all pixels and compares their value to the neighbouring pixels. If a neighbouring pixel has a lesser value, than it is matched the sample pixels value.

The following pseudo python shall demonstrate.

FOREACH a OF allPixels:
FOREACH b NEXT TO a:
IF (a > b):
b = a


In Step mode, the adjacent pixels are right, top, left, bottom.

In Distance mode, the adjacent pixels include diagonal connections.

Here is a comparison of an example.