You are on page 1of 7

LAB1- PM ET1408 Applied Image Processing

Introduction In this lab we are going to become familiar in using C6713 DSP card for image processing purposes. For preparation of the lab you need to read chapter 3 (37-59 pages) of the course book;
Embedded Image Processing on the TMS320C6000 DSP (Examples in Code Composer Studio and MATLAB) by Shehrzad Qureshi. The goal of the lab is to implement contrast stretching algorithm in Matlab and on the DSP card.

Brief description of the C6713 DSP Starter Kit The DSK is a standalone development platform with a Texas Instruments Digital Signal Processor (DSP: TMS320C6713) and associated peripherals, connected to a host PC via USB.

Key features include A Texas Instruments TMS320C6713 DSP operating at 225 MHz. An AIC23 stereo codec 512 Kbytes of non-volatile Flash memory (256 Kbytes usable in default configuration) 4 user accessible LEDs and DIP switches Software board configuration through registers implemented in CPLD Configurable boot options Standard expansion connectors for daughter card use JTAG emulation through on-board JTAG emulator with USB host interface or external emulator Single voltage power supply (+5V) This DSP is mainly used for digital audio processing (filtering, sampling ) designed for cell phones. But this DSK can also be used for basic digital image processing (filtering in spatial and frequency domains, edge detection). However, in order to process an image it is necessary to load it into the external memory because there is no available peripheral expansion to communicate with a camera.

CCS Compiler Code Composer Studio (CCStudio) is an Integrated Development Environment (IDE). This software combines advanced source code editors, compilers, linkers, and debugging tools to form a complete build system. This software allows programming DSPs and microcontrollers using C, C++ and assembly languages. Here we will use C language as programming language for digital image processing. You can read more about the compiler in the file code composer getting started guide.pdf file which is following the lab materials. Implementing Matlab In order to develop image processing algorithms and to show original and processed images, we used MATLAB. MATLAB is an IDE designed by The Math Works and is the mainly used
software for rapid-development technical computing, both in academia and industry. MATLAB code is structured around the concept of an M-file, which is analogous to a C module.

Basic digital image processing on the c713 DSK


As far as the algorithm of contrast stretching is explained thoroughly in the book, here a typical implementation of an algorithm on the DSP card is presented.

Setting up the system A quick start installation guide is included with the DSP Starter Kit; all the steps to install and set the communication between the board and CCStudio are detailed. You also should install an image library, provided by Texas Instruments, containing basic function to process images: Open lab1 folder Open install IMGLIB Launch the installer (C62xIMGLIB_v104b.exe) Specify the location to save files to the folder corresponding to CCStudio install. (default, C:\CCStudio_v3.x) When the communication is established, follow the instructions below to ensure that CCS and the C6713 DSK are set up properly (please note that the following test can be done if your CCS version is 3.3): Launch CCStudio from the icon on the desktop. In the GEL menu, select Check DSK -> Quick test. The message displayed is Switches: 15 Board Revision: 1 CPLD Revision: 2. This assumes the four DIP switches (0, 1, 2, 3) are in the up position. Depress switch 3 and run the quick test again. The message now displayed should be Switches: 7 Board Revision: 1 CPLD Revision: 2. When the system has been set up, it is necessary to load a project from the included materials folder or to write a new program.

Contrast Stretching function: Project -> Open Specify the path from the materials folder and open contrast stretching.pjt A new window is opened asking for the path to img62x.lib", C:\CCStudio_v3.x\c6200\imglib\lib\img62x.lib), specify the path.

(default,

Now, the project is opened and we will explain the different files of the project which are shown in the project manager on the left side of the CCstudio window.

img_histogram.h: this is the header of the img_histogram function included in the image library (img62x.lib). img62x.lib: this is the image library used for the C6713 DSK. rts6700.lib: this is the Run-Time Support library containing functions as printf contrast_stretch.c: this is the C-program implemented to apply a contrast stretching to an image. c6713dsk.cmd: this is the linker command file containing the memory map of the DSK used to specify the different sections (stack, vectors ). (More information on page 48-49 of the book)
Figur2:Projectmanagerwindow

You can now open contrast_stretch.c and have a look to the program code. Every detail is explained in chapter 3 of the book. It is time to build the project: The compiler and the linker are already configured but you can have a look to the build options (Project -> Build Options) by clicking through the different categories and tabs. Click OK Click Project -> Rebuild All 2 warnings appear in the build window due to the default sizes of .stack and .sysmem sections. (Nothing important!) The project is now built, a contrast_stretching.out file can be found in the subfolder Debug. This is the final built program: File -> Load Program Open the subfolder Debug and load contrast_stretching.out
3

To process an image it is necessary to load it into the memory. First the image has been resized (128x128 pixels) and converted to a data file Xray.dat which stores the image in row-major format (C language); explanations are given on pages 51-59 of the book. Please note that for following parts you need to prepare data (converting your image from matrix form to a long array form) and we will do that with help of Matlab (which is explained in page in the lab1-PM). File -> Data -> Load Load xxx.dat in HEX format, Click Open A new window opens : After typing in_img for the address, CCStudio automatically replaces the string with the actual address. The length is 4096. Each word contains four bytes; the data file actually contains 128x128 / 4 = 4096 elements. Click OK, the image is loaded into internal memory Debug -> Run Wait until contrast stretch completed is printed in the stdout window The processed image is still in the memory, you can save it: File -> Data -> Save Savexxx_out.dat in HEX format, Click Save A new window opens : After typing out_img for the address, CCStudio automatically replaces the string with the actual address. The length is 4096. Click OK, the image is saved in the specified folder You have now two possibilities to show both images (original image and processed image) by using MATLAB or CCStudio. By using CCStudio: View -> Graph -> Image Then you should fill in the tabs of the graph property dialog window as shown on the following figure, and press OK.

Lab Experiments
You should show the result of your experiments and be able to comment them to pass the lab.

Experiment 1 Use the ImageGUI material (from the assignments) and create a user interface which has 4 buttons and two windows for displaying images. Experiment 2 Implement the buttons functionalities as following: Load image: reading an image file and display it in one of windows (e.g. titled as original image), Save Image as data: use the function save_css_data_file.m to convert the loaded image to a data array (like as xxx.dat), Read a data as an image: use the function read_css_data_file.m to choose a file ( a data file like as xxx.dat) and convert it to an image. Then displaying the image in one of windows (e.g. titled as contrast stretched image), Contrast stretching: implementing the Matlab version of contrast stretching algorithm on the loaded image. You can use the function contrast_stretch.m. Experiment 3 Use the created GUI in exp 1 &2 to read the image Xray.bmp and convert it to data file as Xray.dat. Compile the contrast stretching project by the code composer, where you can use the lab material (under the directory of contrst_stretching). Run the compiled code and load the Xray.dat on the DSP card. Save the processed data as Xray_out.dat. Use again the GUI to read the processed data and display it in one of windows. Experiment 4 Use GUI and contrast stretching button to get the same result you obtained from the DSP processing. Here you should have a very good understanding in proceeding of the two algorithms.

How the result should look like You should obtain two windows with the original and processed images:

You might also like