~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/covira/smask.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2 *
  3 * smask.c
  4 *
  5 * 1d symmetric mask mask utilities:
  6 * mask[s], ... , mask[0], ..., mask[s]
  7 *
  8 */
  9  
 10 #include <tina/all_tina.h>
 11 #include <tina/brain.h>
 12 #include <tina/brainfuncs.h>
 13 
 14 /*
 15 1-2-1 mask smoothing of symmetric array mask1, result in mask2
 16 */
 17 void smask_smooth(int s, double *mask2, double *mask1)
 18 {
 19     int x;
 20     mask2[-s] = (2.0 * mask1[-s] + mask1[-s + 1]) / 3.0;
 21     for (x = -s + 1; x <= s - 1; x++)
 22         mask2[x] = (mask1[x - 1] + 2.0 * mask1[x] + mask1[x + 1]) / 4.0;
 23     mask2[s] = (mask1[s - 1] + 2.0 * mask1[s]) / 3.0;
 24 }
 25 
 26 /*
 27 differentiate symmetric array mask1, result in mask2
 28 */
 29 void smask_diff(int s, double *mask2, double *mask1)
 30 {
 31     int x;
 32     for (x = -s + 1; x <= s - 1; x++)
 33         mask2[x] = (mask1[x + 1] - mask1[x - 1]) / 2.0;
 34     mask2[-s] = mask2[s] = 0.0;
 35 }
 36 
 37 /*
 38 second derivative of symmetric array mask1, result in mask2
 39 */
 40 void smask_diff2(int s, double *mask2, double *mask1)
 41 {
 42     int x;
 43     mask2[-s] = mask2[-s+1];
 44     for (x = -s + 1; x <= s - 1; x++)
 45         mask2[x] = (mask1[x + 1] - 2.0 * mask1[x] + mask1[x - 1]) / 4.0;
 46     mask2[-s] = 2*mask2[-s+1]-mask2[-s+2];
 47     mask2[s] = 2*mask2[s-1]-mask2[s-2];
 48 }
 49 
 50 /*
 51 return side of symmetric array (- or +) on which maximum gradient lies
 52 */
 53 double smask_maxgradedge(int s, double *mask)
 54 {
 55     int x, xmax = -s;
 56     double l, lmax = fabs(mask[-s]);
 57 
 58     for (x = -s; x <= s; x++)
 59         if (lmax < (l = fabs(mask[x])))
 60         {
 61             lmax = l;
 62             xmax = x;
 63         }
 64     return (SGN(xmax));
 65 }
 66 
 67 /*
 68 return zero crossing of symmetric array closest to zero 
 69 */
 70 double smask_nearzeroedge(double *mask, int s)
 71 {
 72     int x, sgn;
 73 
 74     sgn = SGN(mask[0]);
 75     for (x = 1; x <= s - 1; x++)
 76     {
 77         int sgn1 = SGN(mask[x]);
 78         int sgn2 = SGN(mask[-x]);
 79         if (sgn != sgn1)
 80             return (x);
 81         if (sgn != sgn2)
 82             return (-x);
 83     }
 84     return (0.0);
 85 }
 86 
 87 /*
 88 normalise symmetric array to set max entry = +/-m
 89 */
 90 void smask_normalise(int s, double *mask, double m)
 91 {
 92     int x;
 93     double mmax = fabs(mask[-s]);
 94     for (x = -s + 1; x <= s; x++)
 95         mmax = MAX(mmax, fabs(mask[x]));
 96     if (mmax == 0.0)
 97         mmax = 1.0;
 98     for (x = -s; x <= s; x++)
 99         mask[x] *= m / mmax;
100 }
101 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.