ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rttree_reduce.c
(Generate patch)

Comparing ray/src/util/rttree_reduce.c (file contents):
Revision 2.2 by greg, Tue May 31 20:50:26 2011 UTC vs.
Revision 2.3 by greg, Wed Jun 1 16:51:03 2011 UTC

# Line 11 | Line 11 | static const char RCSid[] = "$Id$";
11   #include "rterror.h"
12   #include "platform.h"
13   #include <stdlib.h>
14 + #include <math.h>
15  
16   float   *datarr;                /* our loaded BSDF data array */
17   int     ttrank = 4;             /* tensor tree rank */
# Line 18 | Line 19 | int    log2g = 4;              /* log2 of grid resolution */
19   int     infmt = 'a';            /* input format ('a','f','d') */
20   double  pctcull = 99.;          /* target culling percentile */
21  
21 #define HISTLEN         300     /* histogram resolution */
22 #define HISTMAX         10.     /* maximum recorded value in histogram */
23
24 int     histo[HISTLEN];         /* histogram freq. of max-min BSDF */
25
26 double  tthresh;                /* acceptance threshold (TBD) */
27
22   #define dval3(ix,ox,oy)         datarr[((((ix)<<log2g)+(ox))<<log2g)+(oy)]
23   #define dval4(ix,iy,ox,oy)      datarr[((((((ix)<<log2g)+(iy))<<log2g)+(ox))<<log2g)+(oy)]
24  
31 #define above_threshold(tp)     ((tp)->vmax - (tp)->vmin > tthresh)
32
25   /* Tensor tree node */
26   typedef struct ttree_s {
27          float           vmin, vmax;     /* value extrema */
# Line 37 | Line 29 | typedef struct ttree_s {
29          struct ttree_s  *kid;           /* 2^ttrank children */
30   } TNODE;
31  
32 + #define HISTLEN         300     /* histogram resolution */
33 + #define HISTMAX         10.     /* maximum recorded measure in histogram */
34 +
35 + int     histo[HISTLEN];         /* histogram freq. of variance measure */
36 +
37 + double  tthresh;                /* acceptance threshold (TBD) */
38 +
39 + #define var_measure(tp)         ( ((tp)->vmax - (tp)->vmin) / \
40 +                                        (sqrt((tp)->vavg) + .03) )
41 + #define above_threshold(tp)     (var_measure(tp) > tthresh)
42 +
43   /* Allocate a new set of children for the given node (no checks) */
44   static void
45   new_kids(TNODE *pn)
# Line 85 | Line 88 | build_tree(TNODE *tp, const int bmin[], int l2s)
88                  }
89                  tp->vavg /= (float)(1<<ttrank);
90                                          /* record stats */
91 <                i = (HISTLEN/HISTMAX) * (tp->vmax - tp->vmin);
91 >                i = (HISTLEN/HISTMAX) * var_measure(tp);
92                  if (i >= HISTLEN) i = HISTLEN-1;
93                  ++histo[i];
94                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines