Perform Edge Detection by Using a Neighborhood Processing Subsystem Block
This example shows how to detect edges in an image by using a Neighborhood Processing Subsystem block to implement Laplacian edge detection. Use edge detection to identify objects and features in an image.
1. Open the model.
mdl = 'EdgeDetectionNeighborhoodExample'; open_system(mdl);
The model uses an Image From File (Computer Vision Toolbox) block to import an image of the moon, a Neighborhood Processing Subsystem block to perform edge detection, and two Video Viewer (Computer Vision Toolbox) blocks to display the image before and after processing.
2. Open the Neighborhood Processing Subsystem block.
The Neighborhood Processing Subsystem operates over a 3-by-3 neighborhood. To implement Laplacian edge detection, it uses a Gain block to multiply each neighborhood by this kernel:
The Neighborhood Processing Subsystem block then uses a Sum of Elements block to sum the resulting matrix into a scalar value, then uses a Saturation block to saturate that scalar to the range
[0, 255]. Pixels that represent edges in the image will have high values and saturate to
255 because they are different in brightness from the surrounding pixels.
Simulate Model and View Results
Simulate the model.
The modified image has bright pixels corresponding to areas in the original image that have high rates of change in brightness and dark pixels corresponding to areas that have low rates of change.
- Calculate Optical Flow by Using Neighborhood Processing Subsystem Blocks
- Perform Corner Detection by Using Neighborhood Processing Subsystem Blocks
- Perform Fog Rectification by Using Neighborhood Processing Subsystem Blocks
- Convert RGB Image to Grayscale by Using a Neighborhood Processing Subsystem Block
- Generate HDL Code from Frame-Based Models by Using Neighborhood Modeling Methods (HDL Coder)
- Use Neighborhood, Reduction, and Iterator Patterns with a Frame-Based Model or Function for HDL Code Generation (HDL Coder)