在Matlab中使用一阶导数查找图像的梯度

时间:2015-12-17 12:34:05

标签: image matlab filtering gradient derivative

如何使用一阶导数对图像进行增强。

我不想使用索贝尔等运营商。 我想使用一阶导数找到渐变

1 个答案:

答案 0 :(得分:0)

您可以随时自由定义自己的脉冲响应,然后将其与您的图像进行对比。

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