Building Project On C6416 DSK

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

C6416 Report Uday Kiran Thummalapalli

1. BUILDING PROJ ECT ON C6416 DSK



Connect the DSK kit to the PC and open the Code Composer Studio. All the project files are
located under directory C:\ti\my projects\.
1) Click Project >> New to open a build a new project.




Enter the project name as contrast (user specific) as shown in Fig 1(b).

Figure 1.(a) (b) Creating a project
2) Add the required files such as library files, source files, linker files (.cmd), assembly files
(.asm). Click on Project >> Add Files to Project Locate your files as shown in Fig 2.
1




The required libraries are csl6416.lib (C:\ti\C6000\cgtools\lib), dsk6416bsl.lib
(C:\ti\C6000\bios\lib), dsp64x.lib (C:\ti\C6400\dsplib\lib), img64x.lib
(C:\ti\C6400\imglib\lib), rts6400.lib (C:\ti\C6000\rts\lib). A linker is always required to
allocate the memory and define memory address locations.

Figure 2.(a) (b) Adding files to project
3) Click on Project >> Scan All File Dependencies. This step will locate all the required
header files.

2

Figure 3.
4) Configure the Build Options



Figure 4.
5) Follow the below figure for the configurations. As the chip we are using is C6416, select
the target version as C64xx. Under the preprocessor section, add the include paths for the
imglib, dsplib, libraries as the required header files have to be located. Define the
symbols here as CHIP_6416.


3





Figure 5.(a) (b) (c) (d) (e) Steps showing the configurations for a C6416 DSP
6) Build the project. An .out file is created in Debug folder if the compilation is successful
with no errors.
4




Figure 6.
7) Locate and Load the .out file.



Figure 7.(a) (b) Loading the .out files
5


8) Run the program by pushing the button as shown in the Fig 8 or use the hot key F5.


Figure 8. Executing the program
6

C6416 Report Uday Kiran Thummalapalli

2. READING AND VIEWING IMAGE FROM A LINEAR


ARRAY (MATRIX)

Load the project named Blurred located in the my projects folder. Build the project with
all the libraries, source files and linker files included.
I mage. h file initializes the image into a linear array. The intensities can be generated by using
MATLAB. The array in_img is the input image.
/ / I mage. h
#def i ne X_SI ZE 256
#def i ne Y_SI ZE 256
#def i ne N_PI XELS X_SI ZE*Y_SI ZE

/ / def i ne pi xel s i nt ensi t i es i n t he i nput i mage
unsi gned char i n_i mg[ N_PI XELS] = {137, 137, 134, 136, 138, 135, 135, 132,
133, 139, 130, 132, 132, 127, 130, 129, 131, 132, 139, 139, 143, 147, 151, 151, 149, 149, 144, 1
34, 119, 118, 90, 80, 64, 62, 61, 69, 71, 73, 73, 74, 78, 74, 76, 79, 76, 75, 78, 76, 78, 78, 74, 74,
79, 83, 83, 88, 83, 90, 93, 91, 96, 94, 91, 102, 98, 101, 97, 97, 107, 102, 100, 97, 97, 96, 103, 99
, 99, 97, 104, 104, 98, 101, 102, 103, 101, 101, 100, 101, 103, 103, 101, 100, 102, 105, 101, 101
, 105, 103, 105, 105, 105, 103, 104, 103, 107, 104, 102, 101, 100, 101, 101, 99, 99, 106, 105, 10
0, 100, 100, 97, 101, 104, 102, 103, 106, 100, 102, 96, 105, 111, 103, 99, 98, 101, 99, 102, 98, 9
8, 101, 96, 105, 98, 99, 98, , 133, 1
39, 130, 132, 132, 127, 130, 129, 131, 132, 139, 139, 143, 147, 151, 151, 149, 149, 144, 134, 11
9, 118, 90, 80, 64, 62, 61, 69, 71, 73, 73, 74, 78, 74, 76, 79, 76, 75, 78, 76, 78, 78, 74, 74, 79, 83
, 83, 88, 83, 90, 93, 91, 96, 94, 91, 102, 98, 101, 97, 97, 107, 102, 100, 97, 97, 96, 103, 99, 99, 9
7, 104, 104, 98, 101, 102, 103, 101, 101, 100, 101, 103, 103, 101, 100, 102, 105, 101, 101, 105,
103, 105, 105, 105, 103, 104, 103, 107, 104, 102, 101, 100, 101, 101, 99, 99, 106, 105, 100, 100
, 100, 97, 101, 104, 102, 103, 106, 100, 102, 96, 105, 111, 103, 99, 98};

Bl ur r ed. c can take the input image and convolve a mask which can blur the image. H is the
convolving mask with weighted blurring intensities of box size 3. A higher order mask can be
used by redefining the mask H (NH) and also the arguments for IMG_con_3x3 function.

#i ncl ude <dsk6416. h>
#i ncl ude <st di o. h> / * pr i nt f ( ) */
#i ncl ude <st r i ng. h> / * memset ( ) */
#i ncl ude <i mg_cor r _3x3. h>
#i ncl ude <csl _t i mer . h>

#i ncl ude " i mage. h" / * i mage\ ker nel di mensi ons, exampl e pi xel dat a */
#pr agma DATA_ALI GN ( i n_i mg, 8) ;
#pr agma DATA_SECTI ON ( i n_i mg, " SDRAM" ) ;

7

#pr agma DATA_ALI GN ( out _i mg, 8) ;


#pr agma DATA_SECTI ON ( out _i mg, " SDRAM" ) ;
unsi gned char out _i mg[ N_PI XELS] ; / * f i l t er ed i mage */

/ * f i l t er di mensi ons and coef f i ci ent s */
#def i ne NH 3 / * ker nel i s of si ze NHxNH ( needs t o be 3 f or t hi s pr ogr am) */
#def i ne BOUNDARY ( NH/ 2) / * 1st and l ast BOUNDARY r ows/ col s i n out put set t o 0
*/
#pr agma DATA_ALI GN ( H, 8)
char H[ NH*NH] = {
1, 2, 1, / * 1/ 16 2/ 16 1/ 16 */
2, 4, 2, / * 2/ 16 4/ 16 2/ 16 */
1, 2, 1, / * 1/ 16 2/ 16 1/ 16 */
};
#def i ne SHI FT 4 / * r i ght - shi f t by 4 ( di v by 16) */

#def i ne N_COLS_FI LTERED Y_SI ZE- 2*BOUNDARY

/ *
* Fast er t han memset ( ) , count must be a mul t i pl e of
* 8 and gr eat er t han or equal t o 32
*/
voi d memcl ear ( voi d * pt r , i nt count )
{
l ong *l pt r = pt r ;
_nasser t ( ( i nt ) l pt r %8==0) ;
#pr agma MUST_I TERATE ( 32) ;
f or ( count >>=3; count >0; count - - )
*l pt r ++ = 0;
}

voi d f i l t er _i mage( )
{
unsi gned char *p = out _i mg+BOUNDARY*Y_SI ZE;
i nt i i , i r ow;

/ * set 1st BOUNDARY r ows t o zer o */
memcl ear ( out _i mg, BOUNDARY*Y_SI ZE) ;

/ * f i l t er t he i nt er i or r egi on of t he i mage mat r i x */
f or ( i r ow=BOUNDARY; i r ow<X_SI ZE- BOUNDARY; ++i r ow)
{
/ * 1st BOUNDARY col s ar e zer o */
f or ( i i =0; i i <BOUNDARY; ++i i ) *p++ = 0;

/ *
* I MG_conv_3x3 r equi r es 3r d ar g t o be a mul t i pl e of 8,
* t hat ' s why we pass i n Y_SI ZE i nst ead of N_COLS_FI LTERED
* ( l ast f ew f i l t er ed pi xel s ar e i gnor ed)
8

*/
I MG_conv_3x3( &i n_i mg[ ( i r ow- BOUNDARY) *Y_SI ZE] ,
p,
Y_SI ZE,
H,
SHI FT) ;

/ * l ast BOUNDARY col s ar e zer o */
p += N_COLS_FI LTERED;
f or ( i i =0; i i <BOUNDARY; ++i i ) *p++ = 0;
}

/ * l ast BOUNDARY r ows ar e zer o */
memcl ear ( out _i mg+( X_SI ZE- BOUNDARY) *Y_SI ZE, BOUNDARY*Y_SI ZE) ;
}

i nt mai n( voi d)
{
TI MER_Handl e hTi mer ;
unsi gned i nt st ar t , st op, over head, t ot al = 0, t ; / * t i mi ng */
const i nt N = 10; / * how many t i mes t o pr of i l e */
i nt i i = 0;

DSK6416_i ni t ( ) ; / * i ni t i al i ze t he DSK boar d suppor t l i br ar y */

/ * conf i gur e t i mer */
hTi mer = TI MER_open( TI MER_DEVANY, 0) ;
TI MER_conf i gAr gs( hTi mer , 0x000002C0, 0xFFFFFFFF, 0x00000000) ;

/ * comput e over head of cal l i ng t he t i mer . */
st ar t = TI MER_get Count ( hTi mer ) ; / * cal l ed t wi ce t o avoi d L1D mi ss. */
st ar t = TI MER_get Count ( hTi mer ) ;
st op = TI MER_get Count ( hTi mer ) ;
over head = st op - st ar t ;

f or ( ; i i <N; ++i i ) {
st ar t = TI MER_get Count ( hTi mer ) ; / * begi n " pr of i l e ar ea" */
f i l t er _i mage( ) ;
st op = TI MER_get Count ( hTi mer ) ; / * end " pr of i l e ar ea" */
t = ( st op- st ar t - over head) * 8;
t ot al += t ;
pr i nt f ( " # cycl es t o f i l t er i mage: %d\ n" , t ) ;
}

pr i nt f ( " avg t i me i s %. 2f cycl es. \ n" , ( f l oat ) t ot al / ( f l oat ) N) ;
}



9




VIEWING THE IMAGE USING CCS

CCS offers simple ways of viewing the data as a graph, histogram, or even as an image.
Below steps illustrate a walkthrough for displaying an image.

1) Click View >> Graph >> Image



2) Select the RGB color space to select the R,G,B plane. A gray scale image can be viewed
if all the planes, i.e., R,G,B planes have same arrays. Enter the address location of the
image located or a HEX address where the image data have to be read.

10



3) Select the Lines per Display as #rows in the image and Pixels per Line as #columns in the
image. Please Select Image Origin as Top Left, else you have an inverted image.



11

4) Now you can see the image displayed in a new window as shown below. A pointer
(crosswire) is provided to view the pixel intensities and the locations.


12

C6416 Report Uday Kiran Thummalapalli



3. MAKING A CONFIGURATION (.cdb) FILE

Writing a linker (.cmd) file is made much easier using the DSP/BIOS configuration
tool of the CCS Studio. Tutorial below here shows a brief description of configuring a
simple memory mapping, RTDX enabling with buffer sizes.

1. Click File >> New >> DSP/BIOS Configuration
2. Select C64xx.cdb respectively for the C6416 DSP.

3. Expand the System>> Memory trees to view the memory mapping of the chip.
You can insert a new memory segment by right-clicking on the Memory Section
Manager and select Insert MEM
13


4. Rename the new memory segment as SDRAM (for eg.). Explore the properties of
the memory by right-clicking on the memory section.

14

This opens up a new dialog box where you can edit the starting address and length of the
memory location on the physical address map. Sample entries are shown in the figure
below. You can customize the mapping as per your choice.

5. Similarly, under the tree of Input/Output, right click on the section RTDX Real-
Time Data Exchange Settings. You can add an entry for RTDX by selecting the
Properties option.

15

On the safe size, enter the buffer size double than required i.e., if the data is 64K (256 x
256 =65536) have a buffer size of 128K (65536 x 2 =131072).

6. As you have added the required data segments, you can now save the cdb file and
add that to the project. Save the .cdb file by navigating through File >> Save As
Include the file in the project (Project >> Add Files to Project )


16

C6416 Report Uday Kiran Thummalapalli

4. IMAGE CONTRAST STRETCHING
Contrast stretching (also called Normalization) attempts to improve an image by
stretching the range of intensity values it contains to make full use of possible values. The
first step is to determine the limits over which image intensity values will be extended.
These lower and upper limits will be called a and b, respectively (for standard 8-bit
grayscale pictures, these limits are usually 0 and 255). Next, the histogram of the original
image is examined to determine the value limits (lower =c, upper =d) in the unmodified
picture. If the original range covers the full possible set of values, straightforward
contrast stretching will achieve nothing, but even then sometimes most of the image data
is contained within a restricted range; this restricted range can be stretched linearly, with
original values which lie outside the range being set to the appropriate limit of the
extended output range. Then for each pixel, the original value r is mapped to output value
s using the function:




The code below shows the logic for image contrast stretching:
#i ncl ude <l i mi t s. h>
MATH_H 1
MGLI B */
I ZE*Y_SI ZE
l not f i t i n
#i ncl ude <st di o. h>
D_ #def i ne _TI _ENHANCE
#i ncl ude <mat h. h>
ogr am. h> / * I #i ncl ude <i mg_hi st

i mage di mensi ons */ / *
#def i ne X_SI ZE 128
#def i ne Y_SI ZE 128
#def i ne N_PI XELS X_S

si gned char i n_i mg[ N_PI XELS] ; un

I nput & out put buf f er bot h wi l / *
i nt er nal chi p RAM, t hi s pr agma pl aces t he
out put buf f er i n of f - chi p RAM */
AM" ) ; #pr agma DATA_SECTI ON ( out _i mg, " SBSR
17

unsi gned char out _i mg[ N_PI XELS] ;

/ * i mage hi st ogr amgoes her e, t he pr agma
scr at ch buf f er needed by I MGLI B */
i d comput e_r ange( unsi gned char *pi n, i nt N,
cent i l e2,
unsi gned shor t cumsum= 0, / * r unni ng t al l y of t he cumul at i ve sum
T1 = r ound( ( f l oat ) N * per cent i l e1) , / * t hr eshol d
;
i mage hi st ogr am*/
24) ;
l ocat i on f or 1st ( l ower bound) per cent i l e i n hi st ogr am*/
l ocat i on f or 2nd ( upper bound) per cent i l e i n hi st ogr am*/
i d cont r ast _st r et ch( unsi gned char *pi n,

al i gns t he buf f er on a 4- byt e boundar y
whi ch i s r equi r ed by I MGLI B */
#pr agma DATA_ALI GN ( hi st , 4)
unsi gned shor t hi st [ 256] ;

/ *
unsi gned shor t t _hi st [ 1024] ;

vo
f l oat per cent i l e1, f l oat per
unsi gned char *pbi n1, unsi gned char *pbi n2)
{

*/

f or 1st bi n */
T2 = r ound( ( f l oat ) N * per cent i l e2) ; / * t hr eshol d
f or 2nd bi n */
i nt i i , j j

/ * cal c

/ * buf f er s must be i ni t i al i zed t o zer o */
memset ( t _hi st , 0, si zeof ( unsi gned shor t ) *10
memset ( hi st , 0, si zeof ( unsi gned shor t ) *256) ;
I MG_hi st ogr am( pi n, N, 1, t _hi st , hi st ) ;

/ * f i nd
f or ( i i =0; i i <256; ++i i ) {
cumsum+= hi st [ i i ] ;
i f ( cumsum>= T1) {
*pbi n1 = i i ;
br eak;
}
}

/ * f i nd
f or ( j j =i i +1; j j <256; ++j j ) {
cumsum+= hi st [ j j ] ;
i f ( cumsum>= T2) {
*pbi n2 = j j ;
br eak;
}
}
}

vo
unsi gned char *pout ,
i nt N)
{
unsi gned char a, b; / * l ower & upper bounds f or scal i ng f unct i on
*/
f l oat scal e, pi xel ;
i nt i i ;
18


/ * est i mat e dynami c r ange of t he i nput */
comput e_r ange( pi n, N, . 05, 0. 95, &a, &b) ;

/ * appl y l i near scal i ng f unct i on t o i nput pi xel s,
t aki ng car e t o handl e over f l ow & under f l ow */
scal e = 255. 0/ ( f l oat ) ( b- a) ;
19

i i ] - a) * scal e ) ;
t mai n( voi d)
g, out _i mg, N_PI XELS) ;
Load the image via File >>Data >>Load and input the file Xrays.dat for the
file size 16384. (128 X 128 =16384). Next, run the program and observe the output.
View the images arrays using the View >>Graph >>Image utility from the CCS.
Below images shows the result of the operation.

f or ( i i =0; i i <N_PI XELS; ++i i ) {
pi xel = r ound( ( f l oat ) ( pi n[
/ * cl amp t o 8 bi t r ange */
pout [ i i ] = ( pi xel <0. f ) ? 0 : ( ( pi xel >255. 0) ? 255 : pi xel ) ;
}
}

i n
{
/ / evm_i ni t ( ) ; / * i ni t i al i ze t he boar d */
DSK6416_i ni t ( ) ;
cont r ast _st r et ch( i n_i m
pr i nt f ( " cont r ast st r et ch compl et ed" ) ;
}


C6416 Report Uday Kiran Thummalapalli
5. LAPLACE TRANSFORMATION USING IMGLIB LIBRARY

The Laplacian is a 2-D isotropic measure of the 2nd spatial derivative of an
image. The Laplacian of an image highlights regions of rapid intensity change and is
therefore often used for edge detection also referred as zero crossing edge detectors. The
Laplacian is often applied to an image that has first been smoothed with something
approximating a Gaussian smoothing filter in order to reduce its sensitivity to noise, and
hence the two variants will be described together here. The operator normally takes a
single gray level image as input and produces another gray level image as output. A
digital Laplacian mask is convoluted on the image using the convolution function from
the IMGLIB.
I(x, y) =
o
2
I
ox
2
+
o
2
I
oy
2

The file in the Laplace folder, calculates the Laplacian image depending on values of the
box filter H. Below shows Laplace.c
#i ncl ude <dsk6416. h>
pr i nt f ( ) */
mage\ ker nel di mensi ons, exampl e pi xel dat a */
RAM" ) ;
d i mage */
eeds t o be 3 f or t hi s
put
#i ncl ude <st di o. h> / *
#i ncl ude <st r i ng. h> / * memset ( ) */
#i ncl ude <i mg_cor r _3x3. h>
#i ncl ude <csl _t i mer . h>

ncl ude " i mage. h" / * i #i
#pr agma DATA_ALI GN ( i n_i mg, 8) ;
DRAM" ) ; #pr agma DATA_SECTI ON ( i n_i mg, " S

r agma DATA_ALI GN ( out _i mg, 8) ; #p
#pr agma DATA_SECTI ON ( out _i mg, " SD
unsi gned char out _i mg[ N_PI XELS] ; / * f i l t er e

f i l t er di mensi ons and coef f i ci ent s */ / *
#def i ne NH 3 / * ker nel i s of si ze NHxNH ( n
pr ogr am) */
#def i ne BOUNDARY ( NH/ 2) / * 1st and l ast BOUNDARY r ows/ col s i n out
set t o 0 */
#pr agma DATA_ALI GN ( H, 8)
20

char H[ NH*NH] = {
0, 1, 0, / * 0 1 0 */
1, - 4, 1, / * 1 - 4 1 */
i ne SHI FT 0 / * r i ght - shi f t by 0 ( di v by 1) */

ong *l pt r = pt r ;
nt - - )
nsi gned char *p = out _i mg+BOUNDARY*Y_SI ZE;
set 1st BOUNDARY r ows t o zer o */
f i l t er t he i nt er i or r egi on of t he i mage mat r i x */
* 1st BOUNDARY col s ar e zer o */
= 0;

G_conv_3x3 r equi r es 3r d ar g t o be a mul t i pl e of 8,
D
v_3x3( &i n_i mg[ ( i r ow- BOUNDARY) *Y_SI ZE] ,
) ;

l ast BOUNDARY col s ar e zer o */
= 0;
l ast BOUNDARY r ows ar e zer o */
t mai n( voi d)
0, 1, 0, / * 0 1 0 */
};
#def

#def i ne N_COLS_FI LTERED Y_SI ZE- 2*BOUNDARY

/ *
* Fast er t han memset ( ) , count must be a mul t i pl e of
* 8 and gr eat er t han or equal t o 32
*/
voi d memcl ear ( voi d * pt r , i nt count )
{
l
_nasser t ( ( i nt ) l pt r %8==0) ;
#pr agma MUST_I TERATE ( 32) ;
f or ( count >>=3; count >0; cou
*l pt r ++ = 0;
}

voi d f i l t er _i mage( )
{
u
i nt i i , i r ow;

/ *
memcl ear ( out _i mg, BOUNDARY*Y_SI ZE) ;

/ *
f or ( i r ow=BOUNDARY; i r ow<X_SI ZE- BOUNDARY; ++i r ow)
{
/
f or ( i i =0; i i <BOUNDARY; ++i i ) *p++

/ *
* I M
* t hat ' s why we pass i n Y_SI ZE i nst ead of N_COLS_FI LTERE
* ( l ast f ew f i l t er ed pi xel s ar e i gnor ed)
*/
I MG_con
p,
E, Y_SI Z
H,
SHI FT

/ *
p += N_COLS_FI LTERED;
++i i ) *p++ f or ( i i =0; i i <BOUNDARY;
}

/ *
memcl ear ( out _i mg+( X_SI ZE- BOUNDARY) *Y_SI ZE, BOUNDARY*Y_SI ZE) ;
}

i n
21

{
22

op, over head, t ot al = 0, t ; / * t i mi ng */
6_i ni t ( ) ; / * i ni t i al i ze t he DSK boar d suppor t l i br ar y */
conf i gur e t i mer */
ER_DEVANY, 0) ;
/ * comput e over head of cal l i ng t he t i mer . */
= TI MER_get Count ( hTi mer ) ;
nt ( hTi mer ) ; / * begi n " pr of i l e ar ea" */
i nt f ( " avg t i me i s %. 2f cycl es. \ n" , ( f l oat ) t ot al / ( f l oat ) N) ;
View the images arrays using the View >> Graph >> Image utility from CCS. Below
images shows in_img and out_img.

TI MER_Handl e hTi mer ;
unsi gned i nt st ar t , st
const i nt N = 10; / * how many t i mes t o pr of i l e */
i nt i i = 0;

DSK641

/ *
hTi mer = TI MER_open( TI M
TI MER_conf i gAr gs( hTi mer , 0x000002C0, 0xFFFFFFFF, 0x00000000) ;


st ar t = TI MER_get Count ( hTi mer ) ; / * cal l ed t wi ce t o avoi d L1D
mi ss. */
st ar t
st op = TI MER_get Count ( hTi mer ) ;
over head = st op - st ar t ;

f or ( ; i i <N; ++i i ) {
st ar t = TI MER_get Cou
f i l t er _i mage( ) ;
st op = TI MER_get Count ( hTi mer ) ; / * end " pr of i l e ar ea" */
t = ( st op- st ar t - over head) * 8;
t ot al += t ;
pr i nt f ( " # cycl es t o f i l t er i mage: %d\ n" , t ) ;
}

pr
}

C6416 Report Uday Kiran Thummalapalli
6. MEDIAN FILTERING USING A 3 X 3 KERNEL
Image noise is the random variation of brightness or color information in images
produced by the sensor and circuitry of a scanner or digital camera. Image noise can also
originate in film grain and in the unavoidable shot noise of an ideal photon detector. It is
generally regarded as an undesirable by-product of image capture. Salt and pepper noise
is a form of noise typically seen on images. It represents itself as randomly occurring
white and black pixels. An effective noise reduction method for this type of noise
involves the usage of a median filter. It has been reported that modified median filters are
capable of removing speckle noise from the ultrasound images to an extent.
Considering a 3 X 3 kernel in the image matrix, median is the middle value when
all the numbers in the kernel are arranged in ascending order (i.e., 5
th
pixel, in case of a 3
X 3 kernel). During this process, the random white pixel (salt) or the black pixel (pepper)
are removed as they go the extremities in the ascending or the descending order.
The file median_filter3X3.c performs the above mentioned operation.
#def i ne CHI P_6416
#i ncl ude <dsk6416. h>
#i ncl ude <st di o. h> / * pr i nt f ( ) */
#i ncl ude <st r i ng. h> / * memset ( ) */
#i ncl ude <i mg_medi an_3x3. h>
#i ncl ude <csl _t i mer . h>
#i ncl ude <csl _dat . h> / * DMA */

/ / #i ncl ude " i mage. h" / * i mage\ ker nel di mensi ons, exampl e pi xel dat a */
#i ncl ude " t anks2. h"
#pr agma DATA_ALI GN ( i n_i mg, 8) ;
#pr agma DATA_SECTI ON ( i n_i mg, " SDRAM" ) ;

#pr agma DATA_ALI GN ( out _i mg, 8) ;
#pr agma DATA_SECTI ON ( out _i mg, " SDRAM" ) ;
unsi gned char out _i mg[ N_PI XELS] ; / * f i l t er ed i mage */

/ * f i l t er di mensi ons and coef f i ci ent s */
#def i ne NH 3 / * ker nel i s of si ze NHxNH ( needs t o be 3 f or t hi s
pr ogr am) */
#def i ne BOUNDARY 1

/ *
* For bl ock pr ocessi ng, segment i mage i nt o i ndi vi dual chunks
* t hat ar e t hen paged i n and out of i nt er nal memor y.
23

*/
#def i ne NUM_SCAN_LI NES 16 / * # r ows const i t ut i ng a bl ock, must di vi de
evenl y i nt o X_SI ZE */
#def i ne NUM_BLOCKS ( X_SI ZE/ NUM_SCAN_LI NES) / * # bl ocks i n
par t i t i oned i mage */
#def i ne BLOCK_X_SI ZE ( NUM_SCAN_LI NES+2*BOUNDARY) / * how many r ows
each bl ock i s */

/ *
* These ar e scr at ch buf f er s, st r at egi cal l y pl aced i n on- chi p RAM:
*
* i nput _buf = i nput pi xel s, passed t o I MG_medi an_3x3
* out put _buf = f i l t er ed pi xel s
*/
#pr agma DATA_ALI GN ( i nput _buf , 8) ;
unsi gned char i nput _buf [ BLOCK_X_SI ZE*Y_SI ZE] ;
#pr agma DATA_ALI GN ( out put _buf , 8) ;
unsi gned char out put _buf [ NUM_SCAN_LI NES*Y_SI ZE] ;

/ *
* Fast er t han memset ( ) , count must be a mul t i pl e of
* 8 and gr eat er t han or equal t o 32
*/
voi d memcl ear ( voi d * pt r , i nt count )
{
l ong * l pt r = pt r ;
_nasser t ( ( i nt ) l pt r %8==0) ;
#pr agma MUST_I TERATE ( 32) ;
f or ( count >>=3; count >0; count - - )
*l pt r ++ = 0;
}

/ * Fi l t er one bl ock of an i mage, r et ur ns r ow i ndex f or next bl ock */
i nt f i l t er _bl ock( i nt i r ow, i nt nr ows,
const unsi gned char *r est r i ct pi n,
unsi gned char *r est r i ct pout )
{
i nt j j = i r ow;
f or ( ; j j <i r ow+nr ows; ++j j ) {
I MG_medi an_3x3( pi n, Y_SI ZE, pout ) ;
pi n += Y_SI ZE; / * i ncr scan- l i ne i n pr epar at i on f or next i t er at i on
*/
pout += Y_SI ZE;
}

r et ur n j j - 1;
}

/ * Mar ch down t he i mage bl ock- by- bl ock, f i l t er i ng al ong t he way */
voi d f i l t er _i mage( )
{
Ui nt 32 i d_EDMAi n = DAT_XFRI D_WAI TNONE,
i d_EDMAout = DAT_XFRI D_WAI TNONE;
i nt i r ow = BOUNDARY;
unsi gned char *pout _i mg = out _i mg,
*pi n_i mg = &i n_i mg[ ( NUM_SCAN_LI NES+BOUNDARY) *Y_SI ZE] ,
/ *
24

* We r euse t he bot t om- most por t i on of i nput _buf
* by shi f t i ng i t t o t he t op, pr i or t o t he begi nni ng
* of t he subsequent bl ock f i l t er i ng. The 1st t i me
* t hr ough t he " i nt er i or of t he i mage" l oop, t he
* t he poi nt er t o bot t om- most por t i on
( pi nput _buf _r ow2move_1)
* i s di f f er ent f r omt he subsequent i t er at i ons
* ( pi nput _buf _r ow2move_n) .
*/
*pi nput _buf _r ow2move_1 = i nput _buf +
( BLOCK_X_SI ZE- 3*BOUNDARY) *Y_SI ZE,
*pi nput _buf _r ow2move_n = i nput _buf +
NUM_SCAN_LI NES*Y_SI ZE,
*pi nput _buf _r ow2move = pi nput _buf _r ow2move_1,
*pi nput _buf _r ow2copy_i nt o =
i nput _buf +2*BOUNDARY*Y_SI ZE;

/ **************************************************************
* Al gor i t hm' pr ol ogue' : f i l t er t he 1st bl ock
**************************************************************/
i d_EDMAi n = DAT_copy( i n_i mg, i nput _buf , ( BLOCK_X_SI ZE-
BOUNDARY) *Y_SI ZE) ;
memcl ear ( out put _buf , BOUNDARY*Y_SI ZE) ; / * 1st f ew r ows ar e 0 */
DAT_wai t ( i d_EDMAi n) ;

i r ow = f i l t er _bl ock( i r ow,
NUM_SCAN_LI NES,
i nput _buf ,
out put _buf + BOUNDARY*Y_SI ZE) ;

/ **************************************************************
* Fi l t er t he i nt er i or of t he i mage
**************************************************************/

f or ( ; i r ow<X_SI ZE- NUM_SCAN_LI NES; ++i r ow) {

/ * page out t he most r ecent l y pr ocessed bl ock */
i d_EDMAout = DAT_copy( out put _buf , pout _i mg, NUM_SCAN_LI NES*Y_SI ZE) ;
pout _i mg += NUM_SCAN_LI NES*Y_SI ZE;

/ * page i n t he next bl ock of pi xel dat a */

/ *
* 1st shi f t t he scan- l i nes we can r euse f r omt he bot t om
* t o t he t op of t he scr act ch buf f er .
*/
memcpy( i nput _buf , pi nput _buf _r ow2move, 2*BOUNDARY*Y_SI ZE) ;
pi nput _buf _r ow2move = pi nput _buf _r ow2move_n;

/ * DMA i n next set of scan- l i nes */
i d_EDMAi n = DAT_copy( pi n_i mg, pi nput _buf _r ow2copy_i nt o,
NUM_SCAN_LI NES*Y_SI ZE) ;
pi n_i mg += NUM_SCAN_LI NES*Y_SI ZE;

/ * got t a wai t now f or bot h xf er s t o compl et e bef or e pr oceedi ng */
DAT_wai t ( i d_EDMAout ) ;
DAT_wai t ( i d_EDMAi n) ;
25

i r ow = f i l t er _bl ock( i r ow, NUM_SCAN_LI NES, i nput _buf , out put _buf ) ;
}

/ **************************************************************
* Al gor i t hm' epi l ogue' : f i l t er t he l ast bl ock
**************************************************************/

/ * page out t he most r ecent l y pr ocessed bl ock of i mage dat a */
i d_EDMAout = DAT_copy( out put _buf , pout _i mg, NUM_SCAN_LI NES*Y_SI ZE) ;
pout _i mg += ( NUM_SCAN_LI NES) *Y_SI ZE;

/ * page i n t he l ast bl ock of dat a */
memcpy( i nput _buf , pi nput _buf _r ow2move, 2*BOUNDARY*Y_SI ZE) ; / * shi f t
scan- l i nes */
i d_EDMAi n = DAT_copy( pi n_i mg, pi nput _buf _r ow2copy_i nt o,
( NUM_SCAN_LI NES- BOUNDARY) *Y_SI ZE) ;

/ * got t a wai t now f or bot h xf er s t o compl et e bef or e pr oceedi ng */
DAT_wai t ( i d_EDMAout ) ;
DAT_wai t ( i d_EDMAi n) ;
f i l t er _bl ock( i r ow, NUM_SCAN_LI NES- BOUNDARY, i nput _buf , out put _buf ) ;

/ * l ast f ew r ows ar e zer o */
memcl ear ( out put _buf + ( NUM_SCAN_LI NES- BOUNDARY) *Y_SI ZE,
BOUNDARY*Y_SI ZE) ;

/ * we' r e done, page out t hi s f i nal bl ock of pi xel dat a */
i d_EDMAout = DAT_copy( out put _buf , pout _i mg, NUM_SCAN_LI NES*Y_SI ZE) ;
DAT_wai t ( i d_EDMAout ) ;
}

i nt mai n( voi d)
{
TI MER_Handl e hTi mer ;
unsi gned i nt st ar t , st op, over head, t ot al = 0, t ; / * t i mi ng */
const i nt N = 10; / * how many t i mes t o pr of i l e */
i nt i i = 0;

DSK6416_i ni t ( ) ; / * i ni t i al i ze t he DSK boar d suppor t l i br ar y */

/ * conf i gur e t i mer */
hTi mer = TI MER_open( TI MER_DEVANY, 0) ;
TI MER_conf i gAr gs( hTi mer , 0x000002C0, 0xFFFFFFFF, 0x00000000) ;

/ * i ni t i al i ze EDMA ( 1st ar g i gnor ed w/ EDMA) */
DAT_open( DAT_CHAANY, DAT_PRI _HI GH, 0) ;

/ * comput e over head of cal l i ng t he t i mer . */
st ar t = TI MER_get Count ( hTi mer ) ; / * cal l ed t wi ce t o avoi d L1D
mi ss. */
st ar t = TI MER_get Count ( hTi mer ) ;
st op = TI MER_get Count ( hTi mer ) ;
over head = st op - st ar t ;

f or ( ; i i <N; ++i i ) {
st ar t = cl ock( ) ; / * begi n " pr of i l e ar ea" */
f i l t er _i mage( ) ;
26

st op = cl ock( ) ; / * end " pr of i l e ar ea" */
t = ( st op- st ar t - over head) * 8;
t ot al += t ;
pr i nt f ( " # cycl es t o f i l t er i mage: %d\ n" , t ) ;
}

pr i nt f ( " avg t i me i s %. 2f cycl es. \ n" , ( f l oat ) t ot al / ( f l oat ) N) ;
}

Generate the image header file using generate_header_file.mfile. View the image
arrays using View >>Graph >>Image utility from CCS. Below images shows median
filtered images for different outputs.



27

C6416 Report Uday Kiran Thummalapalli
7. SOBEL EDGE DETECTION USING RTDX
PROTOCOL AND VISUAL STUDIO COM OBJ ECT

These are the essential steps in designing a RTDX communication setup:
1. Design a module which handles the image processing on the DSP chip.
2. Program a target program which runs on the C6416 chip. This program includes
all the required data, flags, parameters reception from the host. Later, these
parameters are used as arguments for the designed modules. Create a COFF file
(.out) and load on the chip.
3. Design a host program using Visual Studio (or MATLAB) to transmit images,
options for the target console on the chip. Make a GUI with the required
parameters to e passed to the kit using the MFC configuration tool.

TARGET MODULE:
- Files to be included: (Files located on Sobel_RTDX\Target)
Sobel_edge_detect.cdb
Sobel_edge_detect.c
Img64x.lib
sobel_edge_detectcfg.cmd
- Include the imglib include folder path in the Preprocessor option of the compiler.
28


- Build the project.
- Enable the RTDX Module.


- Load the COFF (.out) file and Run it.
29

Code below shows sobel_edge_detect.c
#i ncl ude <r t dx. h> / * t ar get API */
#i ncl ude <st di o. h>
#i ncl ude <I MG_sobel . h>
#i ncl ude <I MG_t hr _l e2mi n. h>
#i ncl ude " t ar get . h" / * def i nes TARGET_I NI TI ALI ZE( ) */
#i ncl ude " i mage. h" / * di mensi ons */

RTDX_Cr eat eI nput Channel ( i chan) ; / * i nput i mage & T come down t hi s pi pe
*/
RTDX_Cr eat eOut put Channel ( ochan) ; / * pr ocessed i mage back t hr ough t hi s
pi pe */

#pr agma DATA_SECTI ON( i mg_buf 1, " SDRAM" ) ;
#pr agma DATA_ALI GN ( i mg_buf 1, 8) ;
unsi gned char i mg_buf 1[ N_PI XELS] ;

#pr agma DATA_SECTI ON( i mg_buf 2, " SDRAM" ) ;
#pr agma DATA_ALI GN ( i mg_buf 2, 8) ;
unsi gned char i mg_buf 2[ N_PI XELS] ;


voi d memcl ear ( voi d * pt r , i nt count )
{
l ong *l pt r = pt r ;
_nasser t ( ( i nt ) l pt r %8==0) ;
#pr agma MUST_I TERATE ( 32) ;
f or ( count >>=3; count >0; count - - )
*l pt r ++ = 0;
}

unsi gned char *sobel _edge_det ect ( )
{
/ *
* i nput & out put buf f er s f or I MG_t hr _l e2mi n may NOT
* al i as ( see I MG_t hr _l e2mi n docs) , t hus oper at i on
* cannot be done " i n- pl ace" .
*/

i nt NH=3; / * ker nel i s of si ze NHxNH ( needs t o be 3 f or t hi s pr ogr am)
*/
i nt BOUNDARY = ( NH/ 2) ; / * 1st and l ast BOUNDARY r ows/ col s i n out put set
t o 0 */
char H[ 9] = {
- 1, - 2, - 1, / * - 1 - 2 - 1 */
0, 0, 0, / * 0 0 0 */
1, 2, 1, / * 1 2 1 */
};

i nt N_COLS_FI LTERED = Y_SI ZE- 2*BOUNDARY, SHI FT = 0;

unsi gned char *p = i mg_buf 2+BOUNDARY*Y_SI ZE;
i nt i i , i r ow;

/ * set 1st BOUNDARY r ows t o zer o */
30

memcl ear ( i mg_buf 2, BOUNDARY*Y_SI ZE) ;

/ * f i l t er t he i nt er i or r egi on of t he i mage mat r i x */
f or ( i r ow=BOUNDARY; i r ow<X_SI ZE- BOUNDARY; ++i r ow)
{
/ * 1st BOUNDARY col s ar e zer o */
f or ( i i =0; i i <BOUNDARY; ++i i ) *p++ = 0;

/ *
* I MG_conv_3x3 r equi r es 3r d ar g t o be a mul t i pl e of 8,
* t hat ' s why we pass i n Y_SI ZE i nst ead of N_COLS_FI LTERED
* ( l ast f ew f i l t er ed pi xel s ar e i gnor ed)
*/
I MG_conv_3x3( &i mg_buf 1[ ( i r ow- BOUNDARY) *Y_SI ZE] ,
p,
Y_SI ZE,
H,
SHI FT) ;

/ * l ast BOUNDARY col s ar e zer o */
p += N_COLS_FI LTERED;
f or ( i i =0; i i <BOUNDARY; ++i i ) *p++ = 0;
}

/ * l ast BOUNDARY r ows ar e zer o */
memcl ear ( i mg_buf 2+( X_SI ZE- BOUNDARY) *Y_SI ZE, BOUNDARY*Y_SI ZE) ;
r et ur n i mg_buf 2;

}

voi d mai n( )
{
i nt st at us, r un_edge_det ect or , i i ;
unsi gned char *pi mg = NULL;

TARGET_I NI TI ALI ZE( ) ;
RTDX_enabl eOut put ( &ochan) ; / * enabl e out put channel */
RTDX_enabl eI nput ( &i chan) ; / * enabl e i nput channel */
pr i nt f ( " I nput & Out put channel s enabl ed . . . \ n" ) ;
whi l e ( 1) {
/ * wai t f or t he host t o send us a t hr eshol d */
i f ( si zeof ( r un_edge_det ect or ) ! = ( st at us = RTDX_r ead( &i chan,
&r un_edge_det ect or , si zeof ( r un_edge_det ect or ) ) ) )
pr i nt f ( " ERROR: RTDX_r ead of edge det ect i on f l ag f ai l ed! \ n" ) ;
el se
pr i nt f ( " Edge det ect i on = %s\ n" , ( r un_edge_det ect or ) ?" yes" : " no" ) ;

/ * now we' r e expect i ng X_SI ZE x Y_SI ZE wor t h of i mage dat a */
i f ( N_PI XELS ! = ( st at us = RTDX_r ead( &i chan, i mg_buf 1, N_PI XELS) ) ) {
pr i nt f ( " ERROR: RTDX_r ead of i mage f ai l ed ( %d) ! \ n" , st at us) ;
exi t ( - 1) ;
}
pr i nt f ( " Recei ved %dx%d i mage\ n" , X_SI ZE, Y_SI ZE) ;

/ * pr ocess t he i mage */
pi mg = sobel _edge_det ect ( ) ;

31

/ * send i t back t o host */
pr i nt f ( " Sendi ng pr ocessed i mage dat a back t o host . . . \ n" ) ;
f or ( i i =0; i i <X_SI ZE; ++i i ) {
/ * wr i t e one r ow' s wor t h of dat a */
i f ( ! RTDX_wr i t e( &ochan, pi mg+i i *Y_SI ZE, Y_SI ZE) ) {
pr i nt f ( " ERROR: RTDX_wr i t e of r ow %d f ai l ed! \ n" , i i ) ;
exi t ( - 1) ;
}
} / * end ( f or each r ow) */
pr i nt f ( " I mage segment at i on compl et ed. \ n" ) ;
}
}

HOST MODULE:
Intel Integrated Performance Primitives (IPP) and Graphics Device Interface (GDI+)
libraries are required to run the following program. The installation files (.exe) are
located in the Sobel_RTDX\Resources folder.
A sample project for the Host application is already constructed for the RTDX transfer.
Please refer to the folder Sobel_RTDX\Host for the Visual Studio project file,
SegmentationHost.vcproj. Add the IPP library include directory to compiler path, IPP
linker library folder path for linker path and additional static library files to the project.

32

Add the Include path for the IPP library include files are located.

Add the Include path for the Additional libraries required from the IPP Stublib folder.

33

Add the required static libraries: gdiplus.lib, ipps.lib, ippi.lib

The line in stdafx.h
#i mpor t " C: \ t i \ cc\ bi n\ r t dxi nt . dl l "
imports the RTDX COM object required for the data transfer. The class Image8bpp
handles the image object read by the GUI and has different functions (Ref. Image8bpp
class members).
This code snippet below can communicate with target module:
From Callbcak function of the Segment button:
voi d CSegment at i onDl g: : OnSegment But t on( )
{
i f ( m_apOr i gBi t map. get ( ) ) {

/ / 1st t el l t he t ar get t o edge det ect or j ust segment
t heApp. r t dx( ) - >sendI nt eger ( t hi s-
>m_edgeDet ect Check. Get Check( ) ?1: 0 ) ;

/ / next send t he i mage t o be pr ocessed
t heApp. r t dx( ) - >sendI mage( m_apOr i gBi t map. get ( ) ) ;

/ / l ast l y, r ead t he segment ed i mage
m_apPr ocessedBi t map = aut o_pt r <I mage8bpp>( t heApp. r t dx( ) -
>r eadI mage( ) ) ;
m_apPr ocessedBi t map- >bi nar i ze( ) ;

34

t hi s- >OnPai nt ( ) ;
}
}

Methods of the RTDX class has the capable to transfer the data to and from the DSP chip.
Run the project and check the folder Sobel_RTDX\Host\Debug\ for the executable file
(SegmentationHost.exe). This application can transer images. Figure below shows the
GUI of the application.

Load the image and hit the Segment button, while the COFF file (.out) file is running on
the CCS with RTDX enabled.

35

C6416 Report Uday Kiran Thummalapalli
8. REGION GROWING USING RTDX PROTOCOL
This project is capable of making an RTDX transfer with the target chip, process the
image and resend to the host. Region growing is a method to view objects in an image whose
intensities are below a threshold. The remaining pixels are blacked out or whiten out depending
on the criterion. The main goal of segmentation is to partition an image into regions. We have to
achieve the goal by looking for the boundaries between regions based on discontinuities in gray
levels or color properties. The GUI here has a splitter control which can read a threshold value.
Below here are the codes for the target and the host. The user interface and the GUI elements can
be added/ removed/ modified from the RegiongrowHost.rc.
TARGET:
- Files to be include (Files located on Regiongrow_RTDX_Net/Target)
Regiongrow.cdb
Regiongrow.c
Img64x.lib
Regiongrow.cmd
Code below shows Regiongrow.c
#i ncl ude <r t dx. h> / * t ar get API */
#i ncl ude <st di o. h>
#i ncl ude <I MG_sobel . h>
#i ncl ude <I MG_t hr _l e2mi n. h>
#i ncl ude " t ar get . h" / * def i nes TARGET_I NI TI ALI ZE( ) */
#i ncl ude " i mage. h" / * di mensi ons */

RTDX_Cr eat eI nput Channel ( i chan) ; / * i nput i mage & T come down t hi s pi pe */
RTDX_Cr eat eOut put Channel ( ochan) ; / * pr ocessed i mage back t hr ough t hi s pi pe */

#pr agma DATA_SECTI ON( i mg_buf 1, " SDRAM" ) ;
#pr agma DATA_ALI GN ( i mg_buf 1, 8) ;
unsi gned char i mg_buf 1[ N_PI XELS] ;

#pr agma DATA_SECTI ON( i mg_buf 2, " SDRAM" ) ;
#pr agma DATA_ALI GN ( i mg_buf 2, 8) ;
36

unsi gned char i mg_buf 2[ N_PI XELS] ;




voi d memcl ear ( voi d * pt r , i nt count )
{
l ong *l pt r = pt r ;
_nasser t ( ( i nt ) l pt r %8==0) ;
#pr agma MUST_I TERATE ( 32) ;
f or ( count >>=3; count >0; count - - )
*l pt r ++ = 0;
}

r egi on_f i l l ( unsi gned char f i l l _per cent )
{
/ *
* i nput & out put buf f er s f or I MG_t hr _l e2mi n may NOT
* al i as ( see I MG_t hr _l e2mi n docs) , t hus oper at i on
* cannot be done " i n- pl ace" .
*/

I MG_t hr _l e2mi n( i mg_buf 1, i mg_buf 2, Y_SI ZE, X_SI ZE, f i l l _per cent ) ;
}

voi d mai n( )
{
i nt st at us, f i l l _per cent , r un_edge_det ect or , i i ;
/ / unsi gned char *pi mg = i mg_buf 2;

TARGET_I NI TI ALI ZE( ) ;
RTDX_enabl eOut put ( &ochan) ; / * enabl e out put channel */
RTDX_enabl eI nput ( &i chan) ; / * enabl e i nput channel */
pr i nt f ( " I nput & Out put channel s enabl ed . . . \ n" ) ;
whi l e ( 1) {
/ * wai t f or t he host t o send us a t hr eshol d */
i f ( si zeof ( f i l l _per cent ) ! = ( st at us = RTDX_r ead( &i chan, &f i l l _per cent ,
si zeof ( f i l l _per cent ) ) ) )
pr i nt f ( " ERROR: RTDX_r ead of Fi l l Per cent f ai l ed! \ n" ) ;
el se
pr i nt f ( " Fi l l i ng Scal e = %d\ n" , f i l l _per cent ) ;


/ * wai t f or t he host t o send us a t hr eshol d */
/ *i f ( si zeof ( r un_edge_det ect or ) ! = ( st at us = RTDX_r ead( &i chan,
&r un_edge_det ect or , si zeof ( r un_edge_det ect or ) ) ) )
pr i nt f ( " ERROR: RTDX_r ead of edge det ect i on f l ag f ai l ed! \ n" ) ;
el se
pr i nt f ( " Rever si ng Fi l l = %s\ n" , ( r un_edge_det ect or ) ?" yes" : " no" ) ; */

/ * now we' r e expect i ng X_SI ZE x Y_SI ZE wor t h of i mage dat a */
37

i f ( N_PI XELS ! = ( st at us = RTDX_r ead( &i chan, i mg_buf 1, N_PI XELS) ) ) {


pr i nt f ( " ERROR: RTDX_r ead of i mage f ai l ed ( %d) ! \ n" , st at us) ;
exi t ( - 1) ;
}
pr i nt f ( " Recei ved %dx%d i mage\ n" , X_SI ZE, Y_SI ZE) ;

/ * pr ocess t he i mage */
r egi on_f i l l ( ( unsi gned char ) f i l l _per cent ) ;

/ * send i t back t o host */
pr i nt f ( " Sendi ng pr ocessed i mage dat a back t o host . . . \ n" ) ;
f or ( i i =0; i i <X_SI ZE; ++i i ) {
/ * wr i t e one r ow' s wor t h of dat a */
i f ( ! RTDX_wr i t e( &ochan, i mg_buf 2+i i *Y_SI ZE, Y_SI ZE) ) {
pr i nt f ( " ERROR: RTDX_wr i t e of r ow %d f ai l ed! \ n" , i i ) ;
exi t ( - 1) ;
}
} / * end ( f or each r ow) */
pr i nt f ( " Regi on Fi l l i ng compl et ed. \ n" ) ;
}
}

HOST MODULE:
Compose the vcproject for RegiongrowHost and compile for the code for no errors.
Code snippet from RegiongrowDlg.c, written here below, shows the code for which sends the
information through RTDX and receives the image.
voi d CSegment at i onDl g: : OnSegment But t on( )
{
i f ( m_apOr i gBi t map. get ( ) ) {

/ / Set t he mi n and max f or t he scal e t o r egi on f i l l
m_f i l l per cent . Set Range( 0, 256) ;
/ / 1st t el l t he t ar get t he per cent age t o f i l l
t heApp. r t dx( ) - >sendI nt eger ( t hi s- >m_f i l l per cent . Get Pos( ) ) ;

/ / 2nd t el l t he t ar get t he way i t has t o f i l l , f r om bl ack/
whi t e??
/ / t heApp. r t dx( ) - >sendI nt eger ( t hi s-
>m_edgeDet ect Check. Get Check( ) ?1: 0 ) ;

/ / next send t he i mage t o be pr ocessed
t heApp. r t dx( ) - >sendI mage( m_apOr i gBi t map. get ( ) ) ;

/ / l ast l y, r ead t he segment ed i mage
38

m_apPr ocessedBi t map = aut o_pt r <I mage8bpp>( t heApp. r t dx( ) -


>r eadI mage( ) ) ;
m_apPr ocessedBi t map- >bi nar i ze( ) ;

t hi s- >OnPai nt ( ) ;
}
}

The call back function of the button Fill reads the value of the splitter element reads the image
and sends to the DSP. Upon, reception from the RTDX, it reads back the image and repaints the
figure window.
Images below show the result for different values of the threshold.



39

40

You might also like