summaryrefslogtreecommitdiffstats
path: root/funtools/doc/regbounds.html
blob: 4fef30f08df99bdb00c127fb275fd079fa5cd27b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!-- =defdoc regbounds regbounds n -->
<HTML>
<HEAD>
<TITLE>Spatial Region Boundaries</TITLE>
</HEAD>
<BODY>

<!-- =section regbounds NAME -->
<H2><A NAME="regbounds">RegBounds: Region Boundaries</A></H2>

<!-- =section regbounds SYNOPSIS -->
<H2>Summary</H2>
Describes how spatial region boundaries are handled.

<!-- =section regbounds DESCRIPTION -->
<H2>Description</H2>
<P>
The golden rule for spatial region filtering was first enunciated by
Leon VanSpeybroeck in 1986:

<P>
<B>Each photon will be counted once, and no photon will be counted
more than once</B>.

<P>
This means that we must be careful about boundary
conditions.  For example, if a circle is contained in an annulus such
that the inner radius of the annulus is the same as the radius of the
circle, then photons on that boundary must always be assigned to one
or the other region. That is, the number of photons in both regions
must equal the sum of the number of photons in each region taken
separately.

With this in mind, the rules for determining whether a boundary image
pixel or table row are assigned to a region are defined below.

<H2>Image boundaries : radially-symmetric shapes (circle, annuli, ellipse)</H2>

For image filtering, pixels whose center is inside the boundary are
included.  This also applies non-radially-symmetric shapes.  When a
pixel center is exactly on the boundary, the pixel assignment rule is:

<UL>
<LI> the outer boundary of a symmetric shape does not include such pixels
<LI> the inner boundary of a symmetric shape (annulus) includes such pixels
</UL>

In this way, an annulus with radius from 0 to 1, centered exactly on a
pixel, includes the pixel on which it is centered, but none of its
neighbors.

These rules ensure that when defining concentric shapes, no pixels are
omitted between concentric regions and no pixels are claimed by two
regions.  When applied to small symmetric shapes, the shape is less
likely to be skewed, as would happen with non-radially-symmetric
rules.  These rules differ from the rules for box-like shapes, which
are more likely to be positioned adjacent to one another.

<H2>Image Boundaries: non-radially symmetric shapes (polygons, boxes)</H2>

For image filtering, pixels whose center is inside the boundary are
included. This also applies radially-symmetric shapes.  When a pixel
center is exactly on the boundary of a non-radially symmetric region,
the pixel is included in the right or upper region, but not the left
or lower region.  This ensures that geometrically adjoining regions
touch but don't overlap.

<H2>Row Boundaries are Analytic</H2>

When filtering table rows, the boundary rules are the same as for
images, except that the calculation is not done on the center of a
pixel, (since table rows, especially X-ray events rows, often have
discrete, floating point positions) but are calculated exactly. That
is, an row is inside the boundary without regard to its integerized
pixel value.  For rows that are exactly on a region boundary, the
above rules are applied to ensure that all rows are counted once and
no row is counted more than once.

<P>
Because row boundaries are calculated differently from image boundaries,
certain programs will give different results when filtering the same
region file. In particular, fundisp/funtable (which utilize analytic
row filtering) perform differently from funcnts (which performs image
filtering, even on tables).

<H2>Image Boundaries vs. Row Boundaries: Practical Considerations</H2>

<P>
You will sometimes notice a discrepancy between running funcnts on an
binary table file and running fundisp on the same file with the same filter.
For example, consider the following:
<PRE>
  fundisp test1.fits"[box(4219,3887,6,6,0)]" | wc
  8893  320148 3752846
</PRE>
Since fundisp has a 2-line header, there are actually 8891 photons
that pass the filter.  But then run funtable and select only the
rows that pass this filter, placing them in a new file:
<PRE>
  ./funtable test1.fits"[box(4219,3887,6,6,0)]" test2.fits
</PRE>
Now run funcnts using the original filter on the derived file:
<PRE>
  ./funcnts test2.fits "physical; box(4219,3887,6,6,0)"

  [... lot of processed output ...]

  # the following source and background components were used:
  source region(s)
  ----------------
  physical; box(4219,3887,6,6,0)
 
   reg       counts    pixels
  ---- ------------ ---------
     1     7847.000        36
</PRE>
There are 1044 rows (events) that pass the row filter in fundisp (or
funtable) but fail to make it through funcnts. Why?

<P>
The reason can be traced to how analytic row filtering (fundisp, funtable)
differs from integerized pixel filtering(funcnts, funimage). Consider the
region:
<PRE>
  box(4219,3887,6,6,0)
</PRE>
Analytically (i.e., using row filtering), positions will pass this
filter successfully if:
<PRE>
  4216 <= x <= 4222
  3884 <= y <= 3890
</PRE>
For example, photons with position values of x=4216.4 or y=3884.08 will pass.

<P>
Integerized image filtering is different in that the pixels that will
pass this filter have centers at:
<PRE>
  x = 4217, 4218, 4219, 4220, 4221, 4222
  y = 3885, 3886, 3887, 3888, 3889, 3890
</PRE>
Note that there are 6 pixels in each direction, as specified by the region.
That means that positions will pass the filter successfully if:
<PRE>
  4217 <= (int)x <= 4222
  3885 <= (int)y <= 3890
</PRE>
Photons with position values of x=4216.4 or y=3884.08 will NOT pass.

<P>
Note that the position values are integerized, in effect, binned into
image values.  This means that x=4222.4 will pass this filter, but not
the analytic filter above. We do this to maintain the design goal that
either all counts in a pixel are included in an integerized filter, or
else none are included.

<P>
[It could be argued that the correct photon limits for floating point
row data really should be:
<PRE>
  4216.5 <= x <= 4222.5
  3884.5 <= y <= 3890.5
</PRE>
since each pixel extends for .5 on either side of the center. We chose
to the maintain integerized algorithm for all image-style filtering so
that funcnts would give the exact same results regardless of whether
a table or a derived non-blocked binned image is used.]

<!-- =section regbounds SEE ALSO -->
<!-- =text See funtools(n) for a list of Funtools help pages -->
<!-- =stop -->

<P>
<A HREF="./help.html">Go to Funtools Help Index</A>

<H5>Last updated: November 16, 2005</H5>

</BODY>
</HTML>