Main Content

Draw Hough Lines on Image

This example shows you how to find the Cartesian coordinates of lines using rho and theta pairs, and draw those lines on an image.

Example Model

Open the Simulink® model.

modelname = "ex_blkhoughlines.slx";
open_system(modelname);

This model reads an input image using an Image From File block with the File name parameter set to bricks.jpg.

To find the Cartesian coordinates of lines by using rho and theta pairs, the model uses a Hough Lines block with the Sine value computation method set to Trigonometric function.

To draw lines on the image, the model uses a Draw Shapes block with these parameters:

  • ShapeLines

  • Line width15

The Video Viewer block displays the line-embedded output image.

Simulate the Model

Run the model. The Video Viewer block displays the cartesian coordinates and the line-embedded output image.

sim(modelname);