We propose two simple planar structures that enable spatial differentiation of the profile of optical beams propagating in a slab waveguide. The differentiator operating in transmission consists of a single subwavelength dielectric ridge on the surface of a slab waveguide. The differentiator operating in reflection consists of two grooves on the surface of a slab waveguide. In both cases the differentiation is performed at oblique incidence of the beam and is associated with the resonant excitation of the considered structures eigenmodes localized at the ridge or at the ridge between two grooves. It is shown that the required balance between the differentiation quality and the amplitude of the differentiated beam can be achieved by manipulating the quality factor of the resonance. The presented numerical simulation results demonstrate high-quality differentiation. The proposed differentiator may find application in ultrafast analog computing and signal processing systems.