build lookup table a[] s.t. a[x*n]~=acos(x) for x in [-1,1]
| 62 | |
| 63 | // build lookup table a[] s.t. a[x*n]~=acos(x) for x in [-1,1] |
| 64 | float* acosTable() { |
| 65 | const int n=10000, b=10; int i; |
| 66 | static float a[n*2+b*2]; static bool init=false; |
| 67 | float *a1=a+n+b; if( init ) return a1; |
| 68 | for( i=-n-b; i<-n; i++ ) a1[i]=PI; |
| 69 | for( i=-n; i<n; i++ ) a1[i]=float(acos(i/float(n))); |
| 70 | for( i=n; i<n+b; i++ ) a1[i]=0; |
| 71 | for( i=-n-b; i<n/10; i++ ) if( a1[i] > PI-1e-6f ) a1[i]=PI-1e-6f; |
| 72 | init=true; return a1; |
| 73 | } |
| 74 | |
| 75 | // compute gradient magnitude and orientation at each location (uses sse) |
| 76 | void gradMag( float *I, float *M, float *O, int h, int w, int d, bool full ) { |