IMG_sobel_3x3_8


Detailed Description


Functions

void IMG_sobel_3x3_8 (const unsigned char *restrict in, unsigned char *restrict out, short cols, short rows)


Function Documentation

void IMG_sobel_3x3_8 ( const unsigned char *restrict  in,
unsigned char *restrict  out,
short  cols,
short  rows 
)

Description:
This function applies 3-by-3 horizontal and vertical Sobel edge detection masks to the input image and produces an output image which is two rows shorter than the input image. Within each row of the output, the first and last pixels will not contain meaningful results.
Parameters:
in Input image pointer
out Output image pointer
cols Number of columns in the image
rows Number of rows in the image
Algorithm:
The Sobel edge-detection masks shown below are applied to the input image independently. The absolute value of each mask result are summed together and saturated to 8-bits.
                                                                      
          Horizontal Mask:                                                     
              -1 -2 -1                                                  
               0  0  0                                                  
               1  2  1                                                  
                                                                          
          Vertical Mask:                                                       
               -1  0  1                                                  
               -2  0  2                                                  
               -1  0  1                                                  
   

The example below illustrates how the implementation would operate on a given input image. Imagine the following 16-by-6 pixel input image:

              yyyyyyyyyyyyyyyy                                          
              yxxxxxxxxxxxxxxy                                          
              yxxxxxxxxxxxxxxy                                          
              yxxxxxxxxxxxxxxy                                          
              yxxxxxxxxxxxxxxy                                          
              yyyyyyyyyyyyyyyy                                          
   
Where the output is only defined for the inner pixels, x, due to the edge effect of the 3-by-3 pixel mask.
The output image would have the form:
                                                                          
              tXXXXXXXXXXXXXXz                                          
              zXXXXXXXXXXXXXXz                                          
              zXXXXXXXXXXXXXXz                                          
              zXXXXXXXXXXXXXXt                                          

  Where:   X = sobel(x)   The algorithm is applied to that pixel. The correct 
                          output is obtained, the data surrounding the pixel 
                          is used            
                                                                      
           t              Data in the output buffer in that position is unaltered
                                                                         
           z = sobel(y)   The algorithm is applied to that pixel. The output is 
                          not meaningful since the data necessary to process the 
                          pixel is not available.                         
  
This means that (rows-2) lines of pixels will be processed. Though all pixels within each line are processed, the results for the first and last pixels are not valid. This makes the control code simpler and saves cycles. Note that The first pixel in the first processed row and the last pixel in the last processed row are not generated.
The natural C implementation has no restrictions. The optimized intrinsic C code has restrictions as noted in Assumptions below.
Assumptions:
  • The input array and output array should not overlap
  • Both input and output arrays have no alignment requirements
  • The "cols" input value must be even
  • The total number of pixels (cols*rows) must be a multiple of 8
Implementation Notes:
  • This code is fully interruptible
  • This code is compatible with C66x processors
  • The values of the left-most and right-most pixel on each output line are not defined
Benchmarks:
See IMGLIB_Test_Report.html for cycle and memory information.


Copyright 2012, Texas Instruments Incorporated