Digital Gradient

next up previous 
Next: Compass Gradient Operations Up: gradient Previous: The Gradient Operator 

Digital Gradient

For discrete digital images, the derivative in gradient operation 

egin{displaymath}D_x[f(x)]=frac{d}{dx}f(x)=lim_{Delta x 
ightarrow 0}frac{f(x+Delta x)-f(x)}{Delta x} end{displaymath}

becomes the difference 

egin{displaymath}D_n[f[n]]=f[n+1]-f[n],;;;;mbox{or};;;;frac{f[n+1]-f[n-1]}{2} end{displaymath}

Two steps for finding discrete gradient of a digital image:

  • Find the difference: in the two directions: 

    egin{displaymath}g_m[m,n]=D_m[f[m,n]]=f[m+1,n]-f[m,n] end{displaymath}


    egin{displaymath}g_n[m,n]=D_n[f[m,n]]=f[m,n+1]-f[m,n] end{displaymath}

  • Find the magnitude and direction of the gradient vector: 

    egin{displaymath}vertvert g[m,n]vertvert=sqrt{g^2_m[m,n]+g^2_n[m,n]},;;......n]vertvert=vertvert g_mvertvert+vertvert g_nvertvert end{displaymath}


    egin{displaymath}angle g[m,n]=	an^{-1} left(frac{g_n[m,n]}{g_m[m,n]}
ight) end{displaymath}

The differences in two directions $g_m$ and $g_n$ can be obtained by convolution with the following kernels:

  • Roberts 

    egin{displaymath}left[ egin{array}{rr} -1 & 1  0 & 0 end{array} 
ight],......left[ egin{array}{rr} -1 & 0  1 & 0 end{array} 
ight]end{displaymath}

    or 

    egin{displaymath}left[ egin{array}{rr} 0 & 1  -1 & 0 end{array} 
ight],......left[ egin{array}{rr} 1 & 0  0 & -1 end{array} 
ight]end{displaymath}

  • Sobel (3x3) 

    egin{displaymath}left[ egin{array}{rrr} -1 & 0 & 1  -2 & 0 & 2  -1 & 0 ......} -1 & -2 & -1  0 & 0 & 0  1 & 2 & 1end{array} 
ight]end{displaymath}

  • Prewitt (3x3) 

    egin{displaymath}left[ egin{array}{rrr} -1 & 0 & 1  -1 & 0 & 1  -1 & 0 ......} -1 & -1 & -1  0 & 0 & 0  1 & 1 & 1end{array} 
ight]end{displaymath}

  • Prewitt (4x4) 

    egin{displaymath}left[ egin{array}{rrrr} -3 & -1 & 1 & 3  -3 & -1 & 1 & 3......1 & -1 \1 & 1 & 1 & 1  3 & 3 & 3 & 3 end{array} 
ight]end{displaymath}

Note Sobel and Prewitt operators first find the averages of one direction and then find the difference of these averages in the another direction.


next up previous 
Next: Compass Gradient Operations Up: gradient Previous: The Gradient Operator
Ruye Wang 2013-11-08

 



原文地址:https://www.cnblogs.com/fireae/p/3699119.html