Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Abstract-The Matlab program is extensively used in engineering Experiments indicate that computations such as convolution

and scientific circles for numeric intensive computing. There are using the 40 MHz TMS320C25 for filtering occur at over 40
many toolboxes available, the DSP toolbox & others in areas of times the speed of Matlab on a 12 MHz PC-AT with a
optimization, spline, control and estimation, and system
floating-point coprocessor. A 20 minute Matlab computation,
identification. There are some useful functions in the DSP toolbox
for 2-dimensional signal processing: 2-D DFT’s, convolution,
such as convolving or transforming a large image, might
correlation, and graphing. Separable and non separable therefore be done in as little as 30 seconds, depending upon
processing is conveniently described in terms of matrices. Also how much inter-processor communication and other overhead
many topics in image enhancement and restoration are is involved. A 6 function library of useful object-code C25
conveniently described in terms of matrices. PC-Matlab is a very functions will be described in which the functions can be
convenient tool for processing small images or blocks, 64 x 64 invoked entirely from within Matlab. Depending upon the
often being an upper limit for processing, although larger blocks amount of Matlab intervention, e.g., data transfers into and out
can be imported and displayed. In spite of these restrictions, it is of Matlab, accelerations of an appreciable fraction of the
possible to display and process full size 600 x 800 images using maximum are attainable. The acceleration by itself is not the
PC Matlab and a graphics processor. The signal processor adds
the possibility of accelerating numeric intensive operations by a
only or even the main time saver, though, since the ability to
factor of 10 to 40. prepare simple Matlab code for controlling complex
experiments and evaluating the results with numerically
In this paper, some methods of augmenting Matlab with accurate Matlab functions and graphing them, all in an
programmable DSP’s and graphics processors are described interpretive environment, provides acceleration of the
which provide the mentioned capability for fast processing, fixed- algorithm development and test process.
point and binary representation and manipulation, and image
display. These capabilities are attained by using three separate The following 6 functions are quite general and can be used to
processors, the Texas Instruments (TI) TMS320C25 fixed-point
utilize the C25 for both 1- and 2-dimensional algorithms. It is
DSP, the TMS34010 graphics processor, and a PC-AT. In
addition, we are using Super VGA (600 X 800 pixel) monochrome
assumed that a set of useful C25 assembly language programs
monitors. The two T.I. processors are widely available from is available and ready for downloading to the C25. A function
many suppliers for many PC’s and engineering workstations, but for doing this and functions for initialization of the C25 and
we are using TI expansion slot boards for PC-AT compatibles. down and uploading data are described below.
The functions in the two toolboxes are a sufficient starting point
for image processing. They can be used to write Matlab script tms_init (mc)
functions for 2-D filtering, multi resolution processing, etc. These
functions can be further accelerated with additional toolbox This routine determines if the system is AT or XT and
functions which directly link the two processors, an activity in
initializes memory appropriately. Then its resets and holds the
progress.
C25 in readiness for loading a program and input data.
I. INTRODUCTION
tms_load (filename)
Image-processing workstations of the described configuration
This routine loads the assembled code to the C25’s program
have several advantages over conventional workstations based
memory. Either T. I. tagged or COFF object code may be
upon engineering workstations: (1) they are relatively
used. The program name is an argument.
inexpensive (we have a 16 station laboratory at Rutgers of this
tms_wdm (x, dat_addr)
configuration for undergraduate and graduate use obtained at
This routine downloads integer data to the C25 starting at the
relatively small cost), (2) they contain high performance DSP
specified address. Both parameters (size, etc.) and data vectors
and graphics processors (the latter being similar to engineering
may be downloaded with this.
workstation graphics processors), (3) they are flexible,
reconfigurable, and updatable, (4) the hardware and software
load_flt (h, data_addr)
are easily accessed and used by the investigator, (5) the
memory limitations of PC Matlab and DOS are consistent with
This routine downloads floating point data, such as filter
practical hardware systems, encouraging the development of
coefficients, to the C25 after converting them from
practical, block-processing algorithms, (6) the availability of a
MATLAB’s double precision floating point to integer (Q15)
large variety of relevant expansion slot boards, frame
format. Often this data is normalized to be in the range -1 to
grabbers, etc. and software, at low cost, and (7) the relative
+l.
ease of integrating the host PC as well as the boards into real-
time processing experiments.
tms_run
II. THE TMS320C25 TOOLBOX
This routine releases the C25 from hold starting the C25 at the many numerically intensive algorithms, is a particularly
address in the program counter, normally zero, the value appropriate application for the C25.
determined by reset.
III. THE TMS34010 TOOLBOX
tms_rdm (N, data_addr)
The remainder of the interface consists of functions for image
This routine reads N words from the C25 memory starting processing and display which make use of the TMS34010
from data_addr, and converts them to Matlab format and graphics processor for display and as a frame buffer. A typical
uploads them. situation is one in which one or more binary files for large
images say 640 x 480 or 512 x 512 pixels are available. It is
Example desired to display, process, reformat, and/or print these
images. Three functions are available for up and downloading
A sample experiment in which an FIR filter is designed, an complete images between files and the graphics processor.
input is generated, both a Matlab and a C25 result are They are very efficient and, after the processor is initialized,
obtained, the latter is uploaded to Matlab, and they are both require only 6 seconds for display or file writing. A fourth
displayed on the same graph is described below. All of these function writes the displayed image from the graphics
steps can be performed using the preceding 6 basic functions processor to a postscript file for printing. The arguments of
in the interface. They can be invoked from Matlab either these four functions are entered on the command line. Two
interactively (not under control of a program) or from a script remaining functions enable blocks, typically 64 x 64, to be
file, such as that illustrated below. The result of running this moved between Matlab and the graphics processor, thus
script from Matlab is a plot of the two results, as the last two permitting the creation and editing of blocks in Matlab. The
lines indicate. There are slight, but noticeable, differences in functions are described below, and monochrome images are
the two results due to quantization in the C25. assumed:

Matlab Script (.m) File initsho filename

% tms_fir. m This function initializes the graphics processor and displays an


echo on image stored line-by-line in 8 bit bytes, each describing the
Nx = 50; gray level of a pixel, if filename is given.
Nh = 11;
Ny= Nx +Nh-1; gp2file filename pd qd M N R S
x = rand (1, Nx);
x = x * 64; This function stores the displayed image starting at pixel (pd,
h = fir l (l0, 0.5); qd) in rectangular M X N blocks, R blocks deep and S blocks
y l = conv(x, h); wide. The file stores the data sequentially, line-by-line within
x = [x, zeros (1, Ny-Nx)]; each block and the blocks themselves occur sequentially line-
tms_init (0) by-line. For Matlab purposes, a choice might be M = N = 64,
tms_load (‘tmsfir.mpo’) and R = S = 8, for a 512 x 512 image. These parameters are
tms_wdm (Ny, hex2dec (’401’)) stored with the file in a header and can be read by the
tms_wdm (Nh - l, hex2dec (’402’)) following function and others.
tms_wdm(x, hex2dec (’700’))
load_flt (h, hex2dec (’500’)) file2gp filename pd qd bv bh
tms_run
y = tms_rdm (Ny, hex2dec (’700’)); The file with block structure defined by M, N, R, and S (in the
plot (y1); header) overwrites the displayed image with RS M x N blocks
hold; starting at (pd, qd). Optional borders between blocks are
pause specified by the optional parameters, bv and bh.
plot (y,’…..‘);
title (’Fi1ter Output’) gp2ps filename pd qd M N sv sh
xlabel (’Samples’)
text (20, 5,’- - result of TMS320’) An M x N block in the displayed image starting at (pd, qd) is
text (20, 0,’- MATLAB result’) written to a postscript file for printing with optional scaling by
sv and sh.
These functions and a few other closely related functions,
fully control the C25 expansion slot board, and therefore ml2gp(x, start)
constitute a set of functions sufficient for utilizing the C25 in
any appropriate Matlab application. Image processing, with its
A matrix x in Matlab is converted from floating point to 8-bit Figure 1 A 192 x 192 Block of the Lena Image (a) From the Original, Line-
by-Line File, (b) From a 64 x 64 Block Reformatted ~ iwitlh O~n-Screen
pixels and displayed with upper left hand corner at start = [pd,
Borders Added.
qp].

gp2ml(x, start)

A sub image, the size of matrix x, starting at [pd,qd]


overwrites the specified matrix, x.

Examples

The Lena image, in standard, 8-bit/pixel, binary format was


loaded with function initsho , and a 192 X 192 block written to
a file with gp2ps and printed as Fig. la. The function gp2file
was used to reformat Lena into 64 x 64 block format, and this
was displayed with 10 bit pixel borders using file2gp. A block
is shown in Fig. lb.

An artificial image was created in Matlab and then displayed


and printed in two different scales in Figure 2 using ml2gp and
gp2ps, respectively. The image overwriting capability of
ml2gp, fundamental to Matlab image processing, produced
Figure 3.

Discussion

The functions in the two toolboxes described above are a Figure 2 An Artificial 64 x 64 Image Created in Matlab, Printed in Two
sufficient starting point for image processing. They can be Postscript-Prescribed Scales.
used to write Matlab script functions for 2-D filtering, multi
resolution processing, etc. These functions can be further
accelerated with additional toolbox functions which directly
link the two processors, an activity in progress.

Figure 3 Overwriting a Displayed Image from Matlab, a Fundamental


Toolbox Function

REFERENCES

[1] Digital Signal Processing using Matlab by Vinay K. Ingle & John G.
Proakis, 2007 Thomson Learning
[2] Fundamentals of Digital Signal Processing using Matlab by Robert J.
Schilling & Sandra L. Harris,2007, Thomson Learning
[3] Proakis, J.G. & Manolakis, D.G.,” Digital Signal Processing: Principles
Algorithms and Applications”, Prentice Hall of India.
[4] Digital Signal processing a practical approach by Emmanuel C. Ifeachor &
Barrie W. Jervis, 2004, Pearson Education
[5] Digital Image Processing Second Edition by Rafael C. Gonzalez &
Richard E. Woods , 2002, Pearson Education
[6] Fundamentals of Digital Image Processing by Anil Kumar Jain, 2001, PHI
[7] Oppenheim A.V., Schafer, Ronald W. & Buck, John R.,”Discrete Time
Signal processing”, Pearson Education ,2nd Edition
[8] Oppenheim, Alan V. & Willsky, Alan S., “Signals and Systems”, Prentice
Hall of India, 2nd Edition
[9]T. G. Marshall, Jr. and H.-Y Kim, "A MATLAB/SWDS environment for
TMS320C25 algorithm development, Proc. TMS320 Educators Conf,"
Houston TX, July, 1991

You might also like