IMG_perimeter_8


Detailed Description


Functions

int IMG_perimeter_8 (const unsigned char *restrict in, int cols, unsigned char *restrict out)


Function Documentation

int IMG_perimeter_8 ( const unsigned char *restrict  in,
int  cols,
unsigned char *restrict  out 
)

Description:
This function returns the boundary pixels of a binary image. Each call to this function calculates one new line of output from a three line window of input.
The input pointer "in" points to the middle line of a three-line window of the image. The perimeter function scans this window looking for pixels in the middle row which are on the perimeter of the image. The routine echoes the periemter pixels with a value of 0xFF and sets the other pixels to zero.
Parameters:
in Pointer to middle row of three-row input image data
cols Width of the input image data
out Output data pointer
Algorithm:
Detection of this boundary within a binary image is a segmentation problem that may be estimated by examining the spatial locality of neighboring pixels. We accomplish this via the four connectivity algorithm:

            _____________________________
           |         |         |         |         
           |         | px_up   |         |         
           |_________|_________|_________|         
           |         |         |         |         
           | px_lft  | px_cent | px_rgt  |
           |_________|_________|_________|         
           |         |         |         |         
           |         | pix_dn  |         |
           |_________|_________|_________|         

  
The output pixel at location "px_cent" is echoed as a boundary pixel if px_cent is non-zero and any one of its four neighbors is zero. The four neighbors used in this algorithm are shown above where:

  
            px_up:  top pixel                                     
            px_lft: left pixel                                    
            px_rgt: right pixel                                   
            px_dn:  bottom pixel                                  
   
   
The natural C implementation has no restrictions. The optimized intrinsic C code has restrictions as noted in Assumptions below.
Assumptions:
  • The input and output arrays should not overlap
  • The input and output images must be 64-bit aligned.
  • The cols parameter must be a non-zero multiple of 16
Implementation Notes:
  • The loop is unrolled 16 times
  • Split-compares are used to find boundary pixels, with comparison results reused between adjacent comparisons
  • Multiplies replace some of the conditional operations to reduce the bottleneck on the predication registers
  • This code is fully interruptible
  • No bank conflicts are expected for this kernel
  • This code is compatible with C66x processors
Benchmarks:
See IMGLIB_Test_Report.html for cycle and memory information.


Copyright 2012, Texas Instruments Incorporated