| gradient | images.imfilter | gradient |
gradient -- convolve a list of images with the gradient filter
gradient input output gradient
GRADIENT convolves the list of images specified by input with one of eight three by three gradient kernels specified by gradient and places the output images in output . If the image names in output equal the image names in input the gradient operation is performed in place and the original images are overwritten. Out of bounds pixels are computed using the algorithm specified by boundary .
GRADIENT acts like a simple edge detector or high pass filter which is sensitive to both the magnitude and direction of changes in intensity in an image. For example, if an image's pixel values are specified by the sum of their x and y coordinates (z = x + y) and boundary extension effects are ignored, the "0", "45", "90", "135", "180", "225", "270", and "315" gradient kernels will each produce a constant image containing the numbers 1, sqrt (2), 1, 0, -1, -sqrt (2), -1, and 0 respectively.
The eight gradient filters are listed below. The I[*,*] are the elements of the input image and the O[*,*] are elements of the output image.
0
- I[-1,1] + 0*I[0,1] + I[1,1]
O[0,0] = - I[-1,0]*sqrt(2) + 0*I[0,0] + I[1,0] * sqrt(2)
- I[-1,-1] + 0*I[0,-1] + I[-1,-1]
45
+ I[-1,1]*0 + I[0,1] + I[1,1]/2/sqrt(2)
O[0,0] = - I[-1,0] + I[0,0]*0 + I[1,0]
- I[-1,-1]/2/sqrt(2) - I[0,-1] + I[1,-1]*0
90
+ I[-1,1] + I[0,1]*sqrt(2) + I[1,1]
O[0,0] = + I[-1,0]*0 + I[0,0]*0 + I[1,0]
- I[-1,-1] - I[0,-1]*sqrt(2) - I[-1,-1]
135
+ I[-1,1]/2/sqrt(2) + I[0,1] + I[1,1]*0
O[0,0] = + I[-1,0] + I[0,0]*0 - I[1,0]
+ I[-1,-1]*0 - I[0,-1] - I[1,-1]/2/sqrt(2)
180
+ I[-1,1] + 0*I[0,1] - I[1,1]
O[0,0] = + I[-1,0]*sqrt(2) + 0*I[0,0] - I[1,0]*sqrt(2)
+ I[-1,-1] + 0*I[0,-1] - I[-1,-1]
225
+ I[-1,1]*0 - I[0,1] - I[1,1]/2/sqrt(2)
O[0,0] = + I[-1,0] + I[0,0]*0 - I[1,0]
+ I[-1,-1]/2/sqrt(2) + I[0,-1] + I[1,-1]*0
270
- I[-1,1] - I[0,1]*sqrt(2) - I[1,1]
O[0,0] = + I[-1,0]*0 + I[0,0]*0 + I[1,0]*0
+ I[-1,-1] + I[0,-1]*sqrt(2) + I[-1,-1]
315
- I[-1,1]/2/sqrt(2) - I[0,1] + I[1,1]*0
O[0,0] = - I[-1,0] + I[0,0]*0 + I[1,0]
+ I[-1,-1]*0 + I[0,-1] + I[1,-1]/2/sqrt(2)
1. Calculate the gradient in the 180 degree direction using nearest neighbour boundary extension.
cl> gradient m83 m83.odeg 180
GRADIENT requires approximately 2.0 cpu seconds to convolve a 512 square real image with a 3 by 3 gradient kernel on a Sparc Station 1.
convolve, gauss, laplace, boxcar