Image processing and edge detection are at the core of several newly emerging technologies, such as augmented reality, autonomous driving and more generally object recognition. Image processing is typically performed digitally using integrated electronic circuits and algorithms, implying fundamental size and speed limitations, as well as significant power needs. On the other hand, it can also be performed in a low-power analog fashion using Fourier optics, requiring however bulky optical components. Here, we introduce dielectric metasurfaces that perform optical image edge detection in the analog domain using a subwavelength geometry that can be readily integrated with detectors. The metasurface is composed of a suitably engineered array of nanobeams designed to perform either 1st- or 2nd-order spatial differentiation. We experimentally demonstrate the 2nd-derivative operation on an input image, showing the potential of all-optical edge detection using a silicon metasurface geometry working at a numerical aperture as large as 0.35.