<< Chapter < Page Chapter >> Page >
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.

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).

The Edge Detection Block

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

The Edge Detection Block Configuration Window for Sobel, Prewitt and Roberts Methods

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.

The Edge Detection Block Configuration Window for the Canny Method

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.
    The Edge Detection Simulation Model for Stills
  4. Running this gives you the images shown in Figure 5.

    Input picture

    The processed picture

    Edge Detection - Simulation Results

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).
    The Edge Detection Real Time Implementation Model
  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.

    The original color picture

    The original grayscale picture

    The received image(after edge detection)

    Edge Detection on the DSK6416

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).
    The Edge Detection Simulation Model for Video
  4. Run the model. A single frame of the input and output video is shown in Figure 9.

    Input video

    Processed video

    Edge Detection on Video

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.).
    The Edge Detection Real Time Implementation Model
  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.
    Configuration Parameters for CCS
    Edge Detection on Real-time Video

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, From matlab and simulink to real-time with ti dsp's. OpenStax CNX. Jun 08, 2009 Download for free at http://cnx.org/content/col10713/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'From matlab and simulink to real-time with ti dsp's' conversation and receive update notifications?

Ask