📄 skeleton.asm
字号:
/*******************************************************************************
Copyright(c) 2000 - 2002 Analog Devices. All Rights Reserved.
Developed by Joint Development Software Application Team, IPDC, Bangalore, India
for Blackfin DSPs ( Micro Signal Architecture 1.0 specification).
By using this module you agree to the terms of the Analog Devices License
Agreement for DSP Software.
********************************************************************************
Module name : skeleton.asm
Label name : __skeleton
Version : 1.3
Change History :
Version Date Author Comments
1.3 11/18/2002 Swarnalatha Tested with VDSP++ 3.0
compiler 6.2.2 on
ADSP-21535 Rev.0.2
1.2 11/13/2002 Swarnalatha Tested with VDSP++ 3.0
on ADSP-21535 Rev. 0.2
1.1 01/28/2002 Raghavendra Modified to match
silicon cycle count
1.0 07/04/2001 Raghavendra Original
Description : This function performs skeleton operation on input binary
image. Skeleton is the way to decompose an object into a set
of unique characteristics or features that can be used to
identify the object. Skeleton is achieved repetitive erosion
and opening operation and finding the difference.
The nth order difference between the eroded image and the
opening of the eroded image is defined by
Kn(A)=En(A)-open(En(A),B).
The skeleton of object A becomes the union of all N terms of
Kn(A), implemented until the nth erosion of A by nB yields
the NULL set.
The structured elements are used is as below
| 0 1 0 |
| 1 1 1 |
| 0 1 0 |
Only basic operation is implemented in this routine. i.e
In this implementation erosion and opening operation on object
A is done and difference between these two is calculated which
is a partial result.
The Union of these partial result is the final result.
User has to call this routine such that eroded result becomes
the input for next iteration.
The user has to pass the previous partial output as output
array because, OR operation is done on present result and
previous results. The result of opening operation is stored in
stack before calculating the difference.
Assumption : 1. Number of columns of input image is even AND aligned to
word or half word boundary
2. Output buffer is cleared for the first time calling and
contains previous results also aligned to word or half word
boundary
Prototype : void _skeleton(unsigned char* in, int row, int col, unsigned
char * erode_res, unsigned char *out );
in -> It is pointer to the input image.
row -> It is number of rows of input image.
col -> It is number of columns of input image.
erode_res -> It is pointer to temp where output of erosion is
stored.
out -> It is pointer the output buffer.
Registers used : A0, A1, R0-R7, I0, I2, I3, M0-M2, P0-P5, LC0, LC1.
Performance :
Code size : 720 bytes
Cycle count : 1287 for 8x8 image
Erosion :
first and last row: 1* (col)
Middle rows : Inner loop : 8.5*(Col -2)
outer loop : 5*(Row-2)
Dilation :
four corner elements: 32 cycles
first and last row : 7* (Col -2)
Middle rows : Inner Loop :8.5* (Col-2)
Outer Loop :21 * (Row-2)
Difference calculation and
Union with previous result : 5* row*col
*******************************************************************************/
.section L1_code;
.global __skeleton;
.align 8;
__skeleton:
[--SP]=(R7:4,P5:3);
// Push R7-4 and P5-3
R5=R1-R1(NS) ||P4=[SP+40];
// Clear R5, Address of erode_res
P5=R0; // Address of input array
I0=R0;
P1=R2; // Number of columns
M2=P4;
I2=R2; // Number of columns
P3=R2; // Number of columns
P2=R1; // Number of rows
R6=5; // Threshold to compare the result for erosion
P0=R2; // Number of columns (N)
R0=R1.L*R2.L(IS)||R3=[SP+44];
// Address of output array and fetch h00;
M0=R0;
I3=R3; // Address of output buffer
NOP; // To remove IAU empty STALL
/////////// EROSION First Row ///////////////////////////////////////////////
LSETUP(FIRST_ROW_ST,FIRST_ROW_ST)LC0=P1;
FIRST_ROW_ST:
B[P4++]=R5;
// Clear first row
P5+=1;
R3=R2<<1 ||R0=B[P5++](Z);
// R3= 2*Col,fetch first input
P0+=-3; // Columns -3
P1+=-2; // Col-2
P2+=-2; // ROW-2;
R7=1;
M1=P2; // Col-2
///////////// EROSION Middle Rows ////////////////////////////////////////
LSETUP(EROSION_ST,EROSION_END)LC0=P2;
// loop counter == ROW-2 (M-2)
P2=R3; // 2*col
EROSION_ST:
B[P4++]=R5;
LSETUP(E_COL_ST,E_COL_END)LC1=P1>>1;
// loop counter ==(COL-2)/2
E_COL_ST:
A0=R0.L*R7.L(IS) ||R0=B[P5](z);
// fetch x(0,1)
R4=R1-R1(NS)||R3=W[P5++P1](Z);
// clear R4, move P5 to starting of next row
A1=R0.L * R7.L(IS)||R0=B[P5++](z);
// fetch x(1,0)
A0+=R0.L *R7.L(IS)|| R0=B[P5++](z);
// fetch x(1,1)
A1+=R0.L * R7.L,A0+=R0.L *R7.L(IS) ||R0=B[P5++](z);
// fetch x(1,2)
A1+= R0.L *R7.L ,A0+=R0.L *R7.L(IS)||R0=B[P5++](z);
// fetch x(1,3)
P5=P5+P0; // move P5 to x(2,1)
A1+= R0.L *R7.L(IS)||R0=B[P5++](z);
// fetch x(2,21)
R2=(A0+=R0.L*R7.L)(IS) ||R0=B[P5++](z);
// fetch x(2,2)
P5-=P2; // modify P5 to process next set of data
R3=(A1+=R0.L *R7.L)(IS)||R0=B[P5++](Z);
CC=R2==R6; // compare r2 with threshold
IF CC R4=R7; // if true r4==1
R2=R1-R1(NS)||B[P4++]=R4;
// store first output
CC=R3==R6; // compare r3 with threshold
IF CC R2=R7; // if true r2==1
E_COL_END: B[P4++]=R2;
// store next output
P5+=1; // Increment P5 to starting of next row
R0=B[P5++](Z) ; // fetch first element
EROSION_END:
B[P4++]=R5;
// store last element as zero
////////////////// EROSION LAST ROW ////////////////////////////////////////
LSETUP(LAST_ROW_ST,LAST_ROW_ST)LC0=P3;
LAST_ROW_ST:
B[P4++]=R5 ;
// store last row as zero
///////////// DILATION /////////////////////////////////////////////////////
P5=M0; // ROW*COL
SP-=P5; // modify stack pointer to store temp result
P4=SP;
P5=M2; // Address where eroded result is stored
R2=I2; // Number of column
R3=R2<<1||R0=B[P5++](z);// 2*col
// First row and last row is computed separately.
//In each row first and last elements are computed separately.
A0=R0.L*R7.L(IS)||R0=B[P5++](Z);
// fetch x(0,1)
P5=P5+P1; // dummy fetches to increment P5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -