Skip to content Skip to navigation Skip to collection information

OpenStax-CNX

You are here: Home » Content » From MATLAB and Simulink to Real-Time with TI DSP's » Edge Detection

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.

Also in these lenses

  • Lens for Engineering

    This module and collection are included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Edge Detection

Module by: Jacob Fainguelernt. E-mail the author

Summary: This module will describe the use of the “Edge Detection” Simulink® Block, to generate real-time DSP code for image and video processing.

Introduction

This chapter will describe the use of the “Edge Detection” Simulink® Block, both for stills images and video files.

Related Files

The Edge Detection Block

The "Edge Detection" block from the "Analysis & Enhancement" group of the Video and Image Processing Blockset (Please refer to Figure 1).

Figure 1: The Edge Detection Block
Figure 1 (graphics1.png)

This block will enable you to simulate the edge detection procedure in the input image using the Sobel, Prewitt, Roberts, or Canny methods.

If the selected method is Sobel, Prewitt, or Roberts, the Edge Detection block finds the edges in an input image by approximating the gradient magnitude of the image. The block convolves the input matrix with the Sobel, Prewitt, or Roberts kernel. The block output can be either the result of this convolution operation (two gradient components of the image) or a binary image, obtained by comparing the convolution result against a threshold. If a pixel value is ‘1’, in this binary image it is an edge. Please refer to Figure 2

Figure 2: The Edge Detection Block Configuration Window for Sobel, Prewitt and Roberts Methods
Figure 2 (graphics2.png)

If the selected method is Canny, the Edge Detection block finds edges by looking for the local maxima of the gradient of the input image. It calculates the gradient using the derivative of the Gaussian filter. The Canny method uses two thresholds to detect strong and weak edges. Please refer to Figure 3.

Figure 3: The Edge Detection Block Configuration Window for the Canny Method
Figure 3 (graphics3.png)

Image (Stills) Processing

Simulation

  1. Open the “stills_R_W.mdl” Simulink model (generated in the "A Framework for Image Processing with the DSK6416" module).
  2. Add the "Edge Detection" block from the "Analysis & Enhancement" group of the Video and Image Processing Blockset (Please refer to section ).
  3. Connect the various blocks as shown in Figure 4. Save your model.
    Figure 4: The Edge Detection Simulation Model for Stills
    Figure 4 (graphics4.png)
  4. Running this gives you the images shown in Figure 5.
    Figure 5: Edge Detection - Simulation Results
    Input PictureThe Processed Picture
    (a) (b)
    Input Picture (graphics5.png)The Processed Picture (graphics6.png)

You may repeat the simulation here to experiment the various algorithms with different thresholds.

Real-Time

  1. Open the “stills_R_W.mdl” Simulink model (generated in the "A Framework for Image Processing with the DSK6416" module).
  2. Add the "Edge Detection" block from from the "Analysis & Enhancement" group of the Video and Image Processing Blockset, as it was done for the simulation.
  3. Connect the various blocks as shown in Figure 6. Save the model (EdgeDetectionPictureDSK6416.mdl).
    Figure 6: The Edge Detection Real Time Implementation Model
    Figure 6 (graphics7.png)
  4. Generate code & create project. Double-click the " Generate code &.." block.
  5. Build the project. Double-click the “Build Project” block.
  6. Load the project. Double-click the “Load Project” block.
  7. Run the target. Double-click the “Run” block.
  8. Run the file ““EdgeDetectionPicturescript.m””, this should give you the images in figure 7.
    Figure 7: Edge Detection on the DSK6416
    The Original Color Picture
    (a)
    The Original Color Picture (fig8.JPG)
    The Original Grayscale Picture
    (b)
    The Original Grayscale Picture (fig9.JPG)
    The Received Image(After Edge Detection)
    (c)
    The Received Image(After Edge Detection) (fig10.JPG)

Video Processing

Simulation

  1. Open the model “video_sim.mdl” model
  2. Add the "Edge Detection" block from from the "Analysis & Enhancement" group of the Video and Image Processing Blockset
  3. Add a second Video Viewer and connect the various blocks as shown in Figure 8. Save your model (EdgeDetectionVideoDSK6416.mdl).
    Figure 8: The Edge Detection Simulation Model for Video
    Figure 8 (graphics11.png)
  4. Run the model. A single frame of the input and output video is shown in Figure 9.
    Figure 9: Edge Detection on Video
    Input VideoProcessed Video
    (a) (b)
    Input Video (graphics12.png)Processed Video (graphics13.png)

You may repeat the simulation here to experiment the various algorithms with different thresholds.

Real-Time

  1. Connect the camera and the display to the board and open the “Video_R_W.mdl” (placed in the “A Framework for Video Processing with the DM6437 DVDP ” module.).
    Figure 10: The Edge Detection Real Time Implementation Model
    Figure 10 (graphics14.png)
  2. Change the name of the “Video Processing” block to “Edge Detection” (Please refer to Figure 10). A new window will be opened
  3. Add the "Edge Detection" block from the "Analysis & Enhancement" group of the Video and Image Processing Blockset, as it was done for the simulation.
  4. Add the "Image Data Type Conversion" block from the " Conversion" group of the Video and Image Processing Blockset.
  5. Set the model in the Simulation->Configuration Parameters, as shown in Figure 11.
  6. Generate code & create project. Double-click the " Generate code &.." block
  7. Build the project. Double-click the “Build Project” block.
  8. Load the project. Double-click the “Load Project” block.
  9. Run the target. Double-click the “Run” block. The results will be diaplyed in the screen as shown in Figure 12.
    Figure 11: Configuration Parameters for CCS
    Figure 11 (graphics15.png)
    Figure 12: Edge Detection on Real-time Video
    Figure 12 (last_fig.jpg)

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks