Actually, I just wanted to apply the filter [-1, 0, 1] (and its transpose), and the functions you mentioned didn't seem to do exactly that, so I just wrote the gradient function as It was very easy. Plus, it gave me the option of duplicating or not the borders which is useful in certain applications.
However, I didn't have much time and might have missed something, so if one of these functions is better, I can change that.