Q:

In Matlab Finding gradient of an image using first derivative

How can I do enhancements on an image using the first derivative.
I do not want to use operators like sobel..
I want to find the gradient using the first derivative

A:

You're always free to define your own impulse response and then convolve that with your image. 
diff1X =[1/2, 0, -1/2]     %first derivative in the x direction 
diff1Y = [1/2; 0; -1/2]     %first derivative in the y direction

%These are finite difference approximations to the first derivative note they 
%are time reversed because the convolution involves a time reversal 

x = [1,2,3; 2,4,6; 4,8,12]
x =

 1     2     3
 2     4     6
 4     8    12

conv2(x, diff1X, 'same')   %same parameter cuts results to initial image size
ans =

 1     1    -1
 2     2    -2
 4     4    -4

%note that the image is zero padded so the derivative at the edges reflects this

conv2(x, diff1Y, 'same')
ans =

 1.0000    2.0000    3.0000
 1.5000    3.0000    4.5000
-1.0000   -2.0000   -3.0000

