A nanophotonic diffractive network performs morphological image processing, including dilation and erosion, purely through light propagation.