IMG_sobel_7x7_16s


Detailed Description


Functions

void IMG_sobel_7x7_16s (const short *restrict in, short *restrict out, short cols, short rows)


Function Documentation

void IMG_sobel_7x7_16s ( const short *restrict  in,
short *restrict  out,
short  cols,
short  rows 
)

Description:
This function applies 7-by-7 horizontal and vertical Sobel edge detection masks to the input image and produces an output image which is six rows shorter than the input image. Within each row of the output, the first three and the last three 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 16-bits.

          Horizontal Mask:                                                     
              -1 -1 -1 -2 -1 -1 -1
              -1 -1 -1 -2 -1 -1 -1
              -1 -1 -1 -2 -1 -1 -1
               0  0  0  0  0  0  0
               1  1  1  2  1  1  1
               1  1  1  2  1  1  1
               1  1  1  2  1  1  1

          Vertical Mask:                                                       
              -1 -1 -1  0  1  1  1
              -1 -1 -1  0  1  1  1
              -1 -1 -1  0  1  1  1
              -2 -2 -2  0  2  2  2
              -1 -1 -1  0  1  1  1
              -1 -1 -1  0  1  1  1
              -1 -1 -1  0  1  1  1
   

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

              yyyyyyyyyyyyyyyy
              yyyyyyyyyyyyyyyy
              yyyyyyyyyyyyyyyy
              yyyxxxxxxxxxxyyy
              yyyxxxxxxxxxxyyy
              yyyxxxxxxxxxxyyy
              yyyxxxxxxxxxxyyy
              yyyyyyyyyyyyyyyy
              yyyyyyyyyyyyyyyy
              yyyyyyyyyyyyyyyy
   
Where the output is only defined for the inner pixels, x, due to the edge effect of the 7-by-7 pixel mask.
The output image would have the form:
                                                                          
              tttXXXXXXXXXXzzz
              zzzXXXXXXXXXXzzz
              zzzXXXXXXXXXXzzz
              zzzXXXXXXXXXXttt

  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-6) lines of pixels will be processed. Though all pixels within each line are processed, the results for the first three and last three pixels are not valid, yet still provided. This makes the control code simpler and saves cycles. Note that The first three pixels in the first processed row and the last three pixels 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 must be 16-bit aligned
  • The "cols" input value must be greater than 7 and a multiple of 2
  • The "rows" input value must be greater than or equal to 7
  • The value (cols * (rows - 6) - 6) must be at least 2
Implementation Notes:
  • This code is fully interruptible
  • This code is compatible with C66x processors
  • The values of the three left-most and three right-most pixels on each output line are not defined
Benchmarks:
See IMGLIB_Test_Report.html for cycle and memory information.


Copyright 2012, Texas Instruments Incorporated