1D first-order derivative mask
As you can see in the following image, the image shows the first order 1D derivative.
Now you can write this equation in terms of the previous pixel rather than the following pixel.

For a 1D differentiation, you are only interested in either the x direction (Horizontal) changes of pixel intensity values or the y direction (Vertical).

Therefore the mask will be [0 -1 1] in case of next intensity value.
Or [1 -1 0] for previous intensity value.

You can apply the same idea for vertical differentiation by taking the transpose.