Functions > Image Processing > Edge Finders > Example: Row and Column Gradients
  
Example: Row and Column Gradients
Use the rowgrad and colgrad functions to create row and column differences in an image matrix by subtracting successive rows (or columns) from each other. In each case the resulting matrix has one undefined row or column that is set to zero.
These functions find the row and column gradients of an image matrix resulting in a horizontally or vertically selective edge detection. Edge detection is used to enhance image readability for certain types of features that depend on boundaries. Gradients also result in a visual embossing effect.
The rowgrad function subtracts adjacent rows in an image matrix to form the output matrix. The first row is zero.
Click to copy this expression
Click to copy this expression
The colgrad function subtracts adjacent columns in an image matrix to form the output matrix. The first column is zero.
Click to copy this expression
For information on using this example, refer to About Image Processing Examples.
1. Read in an image.
Click to copy this expression
(pattern.bmp)
2. Apply the rowgrad and colgrad functions.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. Compare the resulting images with the original.
(pattern_row.bmp)
(pattern_col.bmp)
rowgrad detects the horizontal edges of the image and colgrad detects the vertical edges.