# How to Compute Image Gradients?

How to compute Image gradients?

In X Direction - Kernel : -1 0 1

In Y Direction - Kernel : -1 0 1

Let's assume my input image is: unsigned char* imgImage;

Could any one please share code. I am newbie to image processing. Is it possible to do in OpenCV with this same kernel?

Thanks a lot in advance!

• The simplest way is to make FFT of your kernel, by-pixel multiply it on image's FFT and make IFFT. But in your case, when kernel is so small, it would be better to make direct convolution. – Eddy_Em Jul 4 '13 at 7:19