<< Chapter < Page | Chapter >> Page > |
Use the Find Local Maxima block to find the location of the maximum value in the Hough matrix. Set the block parameters as follows:
Use the Selector blocks to separate the indices of the rho and theta values, which are output at the Idx port, that are associated with the maximum value in the Hough matrix. Set the Selector block parameters as follows:
Set the Selector1 block parameters as follows:
Use the Variable Selector blocks to index into the rho and theta vectors and determine the rho and theta values that correspond to the longest line in the original image. Set the parameters of the Variable Selector blocks as follows:
Use the Hough Lines block to determine where the longest line intersects the edges of the original image. You use these coordinates to superimpose a white line on the original image. Use the default parameters.
Use the Draw Shapes block to draw a white line over the longest line on the original image. Set the block parameters as follows:
Use the Video Viewer block to display the original image with a white line superimposed over the longest line in the image. Set the Input image type parameter to Intensity.
Connect the blocks as shown in the figure below. Use the file circuit.tif as input.
Create a Subsystem for the Hough algorithm. Select the blocks as shown in the following picture:
In the main menu, click on Edit/Create Subsystem (you may also enter Ctrl+G), as follows:
Your model should resemble the following figure:
Double-click the "Hough Algorithm", and you should see:
Create a Subsystem for the “Line Drawing and Image Construction”. Select the blocks as shown in the following picture:
In the main menu, click on Edit/Create Subsystem (you may also enter Ctrl+G),
Your model should resemble the following figure:
Double-click the " Line Drawing and Image Construction ", and you should see:
Create a Subsystem for the “Line Detection”. Select the blocks as shown in the following picture:
The model should look as follows:
Save the file as "LineDetection.mdl"
Set the configuration parameters. Open the Configuration dialog box by selecting Configuration Parameters from the Simulation menu. Set the parameters as follows:
Run your model.
The Video Viewer window displays the edges found in the original image in white and the background in black. To view the image at its true size, right-click the window and select Set Display To True Size.
Running this gives you the images in Figure 1.
Notification Switch
Would you like to follow the 'From matlab and simulink to real-time with ti dsp's' conversation and receive update notifications?