Introduction
In this section, you will use the Hough Transform, Find Local Maxima, and Hough Lines blocks to find the longest line in an image. In the second step, the algorithm used for line detection will be the basis of a lane detection procedure.
Hardware and software requirements
This laboratory was originally developed using the following hardware and software:
- MATLAB® R2008a
- Code Composer Studio (CCS) v3.3
- Texas Instruments DM6437 hardware.
Related files
- Powerpoint Presentation - Shape Detection.ppt
- Simulink Model for Line Detection Simulation - LineDetection.mdl
- Simulink Model for Lane Detection Simulation - LaneDetection.mdl
- Source Image for Line - circuit.tif
- Video-clip for Lane Detection - viplane.avi
- MATLAB script for Line Detection - linedetection_script.m
- Simulink Model for Real-Time Line Detection - LineDetectionDSK6416.mdl
- Simulink Model for Real-Time Lane Detection - LaneDetection.mdl
- MATLAB script for Lane Detection - lane_tcpip_script.m
- Simulink Model for Real-Time Lane Detection (DM6437) - lane_dm6437_tcpip.mdl
- Simulink Model for Real-Time Lane Detection (PC) - lane_pcl_tcpip.mdl
Line detection
In this session we will show how to create the line detection model , and how it can be integrated in Simulation and Real-Time Implementations.
Simulation
Open the “ stills_R_W.mdl ” Simulink model (generated in the " A Framework for Image Processing with the DSK6416 " module).
Add to it the blocks shown in the following table:
Block | Library | Quantity |
Edge Detection | Video and Image Processing Blockset / Analysis&Enhancement | 1 |
Hough Transform | Video and Image Processing Blockset / Transforms | 1 |
Find Local Maxima | Video and Image Processing Blockset / Statistics | 1 |
Selector | Simulink®/ Signal Routing | 2 |
Variable Selector | Signal Processing Blockset / Signal Management / Indexing | 2 |
Terminator | Simulink / Sinks | 1 |
Hough Lines | Video and Image Processing Blockset / Transforms | 1 |
Draw Shapes | Video and Image Processing Blockset / Text&Graphics | 1 |
You are now ready to set your block parameters.
Use the Image From Workspace block to import your image from the MATLAB workspace.
Set the block parameters as follows:
- Main pane, Value = I
- Main pane, Output port labels = I
Use the Edge Detection block to find the edges in the intensity image. This process improves the efficiency of the Hough Lines block as it reduces the image area over which the block searches for lines. The block also converts the image to a binary image, which is the required input for the Hough Transform block. Use the default parameters.
Use the Video Viewer block to display the edges found by the Edge Detection block. Set the Input image type parameter to Intensity.
Use the Hough Transform block to compute the Hough matrix by transforming the input image into the rho-theta parameter space. The block also outputs the rho and theta values associated with the Hough matrix. Set the block parameters as follows: