Advertisement
lamiastella

calcAreaSum gcov

Jun 22nd, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.76 KB | None | 0 0
  1.         -:    0:Source:calcAreaSum.c
  2.         -:    0:Graph:calcAreaSum.gcno
  3.         -:    0:Data:calcAreaSum.gcda
  4.         -:    0:Runs:1
  5.         -:    0:Programs:1
  6.         -:    1:/********************************
  7.         -:    2:Author: Sravanthi Kota Venkata
  8.         -:    3:********************************/
  9.         -:    4:
  10.         -:    5:#include "tracking.h"
  11.         -:    6:
  12.         -:    7:/** Compute the sum of pixels over pixel neighborhood.
  13.         -:    8:    Neighborhood = winSize*winSize
  14.         -:    9:    This will be useful when we compute the displacement
  15.         -:   10:    of the neighborhood across frames instead of tracking each pixel.
  16.         -:   11:
  17.         -:   12:    Input:  src Image
  18.         -:   13:            # rows, cols, size of window
  19.         -:   14:    Output: windowed-sum image, ret.
  20.         -:   15:
  21.         -:   16:    Example:
  22.         -:   17:    
  23.         -:   18:    winSize = 4, cols = 8, rows = 16
  24.         -:   19:    nave_half = 2, nave = 4
  25.         -:   20:    Say, the first row of the image is:
  26.         -:   21:                3 8 6 2 4 8 9 5
  27.         -:   22:    a1 =    0 0 3 8 6 2 4 8 9 5 0 0 (append nave_half zeros to left and right border)
  28.         -:   23:    asum =  (sum the first nave # pixels - 0 0 3 8 ) = 11
  29.         -:   24:    ret(0,0) =  11
  30.         -:   25:    For ret(0,1), we need to move the window to the right by one pixel and subtract
  31.         -:   26:    from a1sum the leftmost pixel. So, we add value 6 and subtract value at a1(0,0), = 0 here.
  32.         -:   27:    ret(0,1) = 17 = a1sum
  33.         -:   28:    For ret(0,2), a1sum - a1(0,1) + a1(2+nave) = 17 - 0 + 2 = 19 = a1sum
  34.         -:   29:    For ret(0,3), a1sum - a1(0,2) + a1(3+nave) = 19 - 3 + 4 = 20 = a1sum
  35.         -:   30:
  36.         -:   31:    We proceed this way for all the rows and then perform summantion across all cols.
  37.         -:   32:**/
  38.         3:   33:F2D* calcAreaSum(F2D* src, int cols, int rows, int winSize)
  39.         -:   34:{
  40.         -:   35:    int nave, nave_half, i, j, k;
  41.         -:   36:    F2D *ret, *a1;
  42.         -:   37:    float a1sum;
  43.         -:   38:    
  44.         -:   39:    nave = winSize;
  45.         3:   40:    nave_half = floor((nave+1)/2);
  46.         -:   41:
  47.         3:   42:    ret = fMallocHandle(rows, cols);
  48.         3:   43:    a1 = fSetArray(1, cols+nave,0);
  49.         -:   44:
  50.      3243:   45:    for(i=0; i<rows; i++)
  51.         -:   46:    {
  52.   6220800:   47:        for(j=0; j<cols; j++) {
  53.   6220800:   48:            asubsref(a1,j+nave_half) = subsref(src,i,j);
  54.         -:   49:        }
  55.         -:   50:        a1sum = 0;
  56.    155520:   51:        for(k=0; k<nave; k++) {
  57.    155520:   52:            a1sum += asubsref(a1,k);
  58.         -:   53:        }
  59.   6220800:   54:        for(j=0; j<cols; j++)
  60.         -:   55:        {
  61.   6220800:   56:            subsref(ret,i,j) = a1sum;
  62.   6220800:   57:            a1sum += asubsref(a1,j+nave) - asubsref(a1,j);
  63.         -:   58:        }
  64.         -:   59:    }
  65.         3:   60:    fFreeHandle(a1);
  66.         -:   61:
  67.         3:   62:    a1 = fSetArray(1, rows+nave,0);
  68.      5763:   63:    for(i=0; i<cols; i++)
  69.         -:   64:    {
  70.   6220800:   65:        for(j=0; j<rows; j++) {
  71.   6220800:   66:            asubsref(a1,j+nave_half) = subsref(ret,j,i);
  72.         -:   67:        }
  73.         -:   68:        a1sum = 0;
  74.    276480:   69:        for(k=0; k<nave; k++) {
  75.    276480:   70:            a1sum += asubsref(a1,k);
  76.         -:   71:        }
  77.   6220800:   72:        for(j=0; j<rows; j++)
  78.         -:   73:        {
  79.   6220800:   74:            subsref(ret,j,i) = a1sum;
  80.   6220800:   75:            a1sum += asubsref(a1,j+nave) - asubsref(a1,j);
  81.         -:   76:        }
  82.         -:   77:    }
  83.         3:   78:    fFreeHandle(a1);
  84.         -:   79:
  85.         3:   80:    return ret;
  86.         -:   81:}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement