~ubuntu-branches/ubuntu/precise/insighttoolkit/precise

« back to all changes in this revision

Viewing changes to Code/BasicFilters/itkBSplineCenteredResampleImageFilterBase.txx

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-12-19 20:16:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081219201649-drt97guwl2ryt0cn

* New upstream version.
  - patches/nifti-versioning.patch: Remove.  Applied upstream.
  - control:
  - rules: Update version numbers, package names.

* control: Build-depend on uuid-dev (gdcm uses it).

* copyright: Update download URL.

* rules: Adhere to parallel=N in DEB_BUILD_OPTIONS by setting MAKEFLAGS.

* compat: Set to 7.
* control: Update build-dep on debhelper to version >= 7.

* CMakeCache.txt.debian: Set CMAKE_BUILD_TYPE to "RELEASE" so that we
  build with -O3 (not -O2), necessary to optimize the templated code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  Program:   Insight Segmentation & Registration Toolkit
4
4
  Module:    $RCSfile: itkBSplineCenteredResampleImageFilterBase.txx,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2006-03-19 04:36:55 $
7
 
  Version:   $Revision: 1.11 $
 
6
  Date:      $Date: 2008-10-09 20:43:42 $
 
7
  Version:   $Revision: 1.12 $
8
8
 
9
9
  Copyright (c) Insight Software Consortium. All rights reserved.
10
10
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
17
17
     PURPOSE.  See the above copyright notices for more information.
18
18
 
19
19
=========================================================================*/
20
 
#ifndef _itkBSplineCenteredResampleImageFilterBase_txx
21
 
#define _itkBSplineCenteredResampleImageFilterBase_txx
 
20
#ifndef __itkBSplineCenteredResampleImageFilterBase_txx
 
21
#define __itkBSplineCenteredResampleImageFilterBase_txx
22
22
#include "itkBSplineCenteredResampleImageFilterBase.h"
23
23
#include "itkImageLinearIteratorWithIndex.h"
24
24
#include "itkProgressReporter.h"
55
55
  switch (SplineOrder) 
56
56
    {   
57
57
    case 1 :
58
 
      this->m_gSize = 21;
59
 
      this->m_hSize = 2;
60
 
      this->m_g.resize(this->m_gSize);
61
 
      this->m_h.resize(this->m_hSize);
62
 
      this->m_g[0]  =  1.; 
63
 
      this->m_g[1]  =  0.333333; 
64
 
      this->m_g[2]  = -0.333333; 
65
 
      this->m_g[3]  = -0.111111; 
66
 
      this->m_g[4]  =  0.111111;
67
 
      this->m_g[5]  =  0.037037; 
68
 
      this->m_g[6]  = -0.037037; 
69
 
      this->m_g[7]  = -0.0123457; 
70
 
      this->m_g[8]  =  0.0123457;
71
 
      this->m_g[9]  =  0.00411523; 
72
 
      this->m_g[10] = -0.00411523; 
73
 
      this->m_g[11] = -0.00137174; 
74
 
      this->m_g[12] =  0.00137174;
75
 
      this->m_g[13] =  0.000457247; 
76
 
      this->m_g[14] = -0.000457247; 
77
 
      this->m_g[15] = -0.000152416;
78
 
      this->m_g[16] =  0.000152416; 
79
 
      this->m_g[17] =  0.0000508053; 
80
 
      this->m_g[18] = -0.0000508053;
81
 
      this->m_g[19] = -0.0000169351; 
82
 
      this->m_g[20] =  0.0000169351;
83
 
      this->m_h[0] =  1; 
84
 
      this->m_h[1] =  0.5;
 
58
      this->m_GSize = 21;
 
59
      this->m_HSize = 2;
 
60
      this->m_G.resize(this->m_GSize);
 
61
      this->m_H.resize(this->m_HSize);
 
62
      this->m_G[0]  =  1.; 
 
63
      this->m_G[1]  =  0.333333; 
 
64
      this->m_G[2]  = -0.333333; 
 
65
      this->m_G[3]  = -0.111111; 
 
66
      this->m_G[4]  =  0.111111;
 
67
      this->m_G[5]  =  0.037037; 
 
68
      this->m_G[6]  = -0.037037; 
 
69
      this->m_G[7]  = -0.0123457; 
 
70
      this->m_G[8]  =  0.0123457;
 
71
      this->m_G[9]  =  0.00411523; 
 
72
      this->m_G[10] = -0.00411523; 
 
73
      this->m_G[11] = -0.00137174; 
 
74
      this->m_G[12] =  0.00137174;
 
75
      this->m_G[13] =  0.000457247; 
 
76
      this->m_G[14] = -0.000457247; 
 
77
      this->m_G[15] = -0.000152416;
 
78
      this->m_G[16] =  0.000152416; 
 
79
      this->m_G[17] =  0.0000508053; 
 
80
      this->m_G[18] = -0.0000508053;
 
81
      this->m_G[19] = -0.0000169351; 
 
82
      this->m_G[20] =  0.0000169351;
 
83
      this->m_H[0] =  1; 
 
84
      this->m_H[1] =  0.5;
85
85
      break;
86
86
    
87
87
    case 2 :
88
 
      this->m_gSize = 21;
89
 
      this->m_hSize = 11;
90
 
      this->m_g.resize(this->m_gSize);
91
 
      this->m_h.resize(this->m_hSize);
92
 
      this->m_g[0]  =  0.738417; 
93
 
      this->m_g[1]  =  0.307916; 
94
 
      this->m_g[2]  = -0.171064; 
95
 
      this->m_g[3]  = -0.0799199; 
96
 
      this->m_g[4]  =  0.0735791;
97
 
      this->m_g[5]  =  0.03108; 
98
 
      this->m_g[6]  = -0.0307862; 
99
 
      this->m_g[7]  = -0.0128561; 
100
 
      this->m_g[8]  =  0.0128425;
101
 
      this->m_g[9]  =  0.00535611; 
102
 
      this->m_g[10] = -0.00535548; 
103
 
      this->m_g[11] = -0.00223325; 
104
 
      this->m_g[12] =  0.00223322;
105
 
      this->m_g[13] =  0.000931242; 
106
 
      this->m_g[14] = -0.00093124; 
107
 
      this->m_g[15] = -0.000388322; 
108
 
      this->m_g[16] =  0.000388322;
109
 
      this->m_g[17] =  0.000161928; 
110
 
      this->m_g[18] = -0.000161928; 
111
 
      this->m_g[19] = -0.0000675233;
112
 
      this->m_g[20] =  0.0000675233;
113
 
      this->m_h[0]  =  1.20711; 
114
 
      this->m_h[1]  =  0.585786; 
115
 
      this->m_h[2]  = -0.12132; 
116
 
      this->m_h[3]  = -0.100505; 
117
 
      this->m_h[4]  =  0.0208153;
118
 
      this->m_h[5]  =  0.0172439; 
119
 
      this->m_h[6]  = -0.00357134; 
120
 
      this->m_h[7]  = -0.00295859; 
121
 
      this->m_h[8]  =  0.000612745;
122
 
      this->m_h[9]  =  0.000507614; 
123
 
      this->m_h[10] = -0.00010513;
 
88
      this->m_GSize = 21;
 
89
      this->m_HSize = 11;
 
90
      this->m_G.resize(this->m_GSize);
 
91
      this->m_H.resize(this->m_HSize);
 
92
      this->m_G[0]  =  0.738417; 
 
93
      this->m_G[1]  =  0.307916; 
 
94
      this->m_G[2]  = -0.171064; 
 
95
      this->m_G[3]  = -0.0799199; 
 
96
      this->m_G[4]  =  0.0735791;
 
97
      this->m_G[5]  =  0.03108; 
 
98
      this->m_G[6]  = -0.0307862; 
 
99
      this->m_G[7]  = -0.0128561; 
 
100
      this->m_G[8]  =  0.0128425;
 
101
      this->m_G[9]  =  0.00535611; 
 
102
      this->m_G[10] = -0.00535548; 
 
103
      this->m_G[11] = -0.00223325; 
 
104
      this->m_G[12] =  0.00223322;
 
105
      this->m_G[13] =  0.000931242; 
 
106
      this->m_G[14] = -0.00093124; 
 
107
      this->m_G[15] = -0.000388322; 
 
108
      this->m_G[16] =  0.000388322;
 
109
      this->m_G[17] =  0.000161928; 
 
110
      this->m_G[18] = -0.000161928; 
 
111
      this->m_G[19] = -0.0000675233;
 
112
      this->m_G[20] =  0.0000675233;
 
113
      this->m_H[0]  =  1.20711; 
 
114
      this->m_H[1]  =  0.585786; 
 
115
      this->m_H[2]  = -0.12132; 
 
116
      this->m_H[3]  = -0.100505; 
 
117
      this->m_H[4]  =  0.0208153;
 
118
      this->m_H[5]  =  0.0172439; 
 
119
      this->m_H[6]  = -0.00357134; 
 
120
      this->m_H[7]  = -0.00295859; 
 
121
      this->m_H[8]  =  0.000612745;
 
122
      this->m_H[9]  =  0.000507614; 
 
123
      this->m_H[10] = -0.00010513;
124
124
      break;
125
125
      
126
126
    case 3 :
127
 
      this->m_gSize = 21;
128
 
      this->m_hSize = 16;
129
 
      this->m_g.resize(this->m_gSize);
130
 
      this->m_h.resize(this->m_hSize);
131
 
      this->m_g[0]  =  0.708792; 
132
 
      this->m_g[1]  =  0.328616; 
133
 
      this->m_g[2]  = -0.165157; 
134
 
      this->m_g[3]  = -0.114448; 
135
 
      this->m_g[4]  =  0.0944036;
136
 
      this->m_g[5]  =  0.0543881; 
137
 
      this->m_g[6]  = -0.05193; 
138
 
      this->m_g[7]  = -0.0284868; 
139
 
      this->m_g[8]  =  0.0281854;
140
 
      this->m_g[9]  =  0.0152877; 
141
 
      this->m_g[10] = -0.0152508; 
142
 
      this->m_g[11] = -0.00825077; 
143
 
      this->m_g[12] =  0.00824629;
144
 
      this->m_g[13] =  0.00445865; 
145
 
      this->m_g[14] = -0.0044582; 
146
 
      this->m_g[15] = -0.00241009; 
147
 
      this->m_g[16] =  0.00241022;
148
 
      this->m_g[17] =  0.00130278; 
149
 
      this->m_g[18] = -0.00130313; 
150
 
      this->m_g[19] = -0.000704109; 
151
 
      this->m_g[20] =  0.000704784;
152
 
      this->m_h[0]  =  1.13726; 
153
 
      this->m_h[1]  =  0.625601; 
154
 
      this->m_h[2]  = -0.0870191; 
155
 
      this->m_h[3]  = -0.159256; 
156
 
      this->m_h[4]  =  0.0233167;
157
 
      this->m_h[5]  =  0.0426725; 
158
 
      this->m_h[6]  = -0.00624769; 
159
 
      this->m_h[7]  = -0.0114341; 
160
 
      this->m_h[8]  =  0.00167406;
161
 
      this->m_h[9]  =  0.00306375; 
162
 
      this->m_h[10] = -0.000448564; 
163
 
      this->m_h[11] = -0.000820929; 
164
 
      this->m_h[12] =  0.000120192;
165
 
      this->m_h[13] =  0.000219967; 
166
 
      this->m_h[14] = -0.0000322054; 
167
 
      this->m_h[15] = -0.00005894; 
 
127
      this->m_GSize = 21;
 
128
      this->m_HSize = 16;
 
129
      this->m_G.resize(this->m_GSize);
 
130
      this->m_H.resize(this->m_HSize);
 
131
      this->m_G[0]  =  0.708792; 
 
132
      this->m_G[1]  =  0.328616; 
 
133
      this->m_G[2]  = -0.165157; 
 
134
      this->m_G[3]  = -0.114448; 
 
135
      this->m_G[4]  =  0.0944036;
 
136
      this->m_G[5]  =  0.0543881; 
 
137
      this->m_G[6]  = -0.05193; 
 
138
      this->m_G[7]  = -0.0284868; 
 
139
      this->m_G[8]  =  0.0281854;
 
140
      this->m_G[9]  =  0.0152877; 
 
141
      this->m_G[10] = -0.0152508; 
 
142
      this->m_G[11] = -0.00825077; 
 
143
      this->m_G[12] =  0.00824629;
 
144
      this->m_G[13] =  0.00445865; 
 
145
      this->m_G[14] = -0.0044582; 
 
146
      this->m_G[15] = -0.00241009; 
 
147
      this->m_G[16] =  0.00241022;
 
148
      this->m_G[17] =  0.00130278; 
 
149
      this->m_G[18] = -0.00130313; 
 
150
      this->m_G[19] = -0.000704109; 
 
151
      this->m_G[20] =  0.000704784;
 
152
      this->m_H[0]  =  1.13726; 
 
153
      this->m_H[1]  =  0.625601; 
 
154
      this->m_H[2]  = -0.0870191; 
 
155
      this->m_H[3]  = -0.159256; 
 
156
      this->m_H[4]  =  0.0233167;
 
157
      this->m_H[5]  =  0.0426725; 
 
158
      this->m_H[6]  = -0.00624769; 
 
159
      this->m_H[7]  = -0.0114341; 
 
160
      this->m_H[8]  =  0.00167406;
 
161
      this->m_H[9]  =  0.00306375; 
 
162
      this->m_H[10] = -0.000448564; 
 
163
      this->m_H[11] = -0.000820929; 
 
164
      this->m_H[12] =  0.000120192;
 
165
      this->m_H[13] =  0.000219967; 
 
166
      this->m_H[14] = -0.0000322054; 
 
167
      this->m_H[15] = -0.00005894; 
168
168
      break;
169
169
    
170
170
    case 4 :
171
 
      this->m_gSize = 21;
172
 
      this->m_hSize = 20;
173
 
      this->m_g.resize(this->m_gSize);
174
 
      this->m_h.resize(this->m_hSize);
175
 
      this->m_g[0]  =  0.673072; 
176
 
      this->m_g[1]  =  0.331218; 
177
 
      this->m_g[2]  = -0.139359; 
178
 
      this->m_g[3]  = -0.12051; 
179
 
      this->m_g[4]  =  0.086389;
180
 
      this->m_g[5]  =  0.0611801; 
181
 
      this->m_g[6]  = -0.0542989; 
182
 
      this->m_g[7]  = -0.034777; 
183
 
      this->m_g[8]  =  0.033388;
184
 
      this->m_g[9]  =  0.0206275; 
185
 
      this->m_g[10] = -0.0203475; 
186
 
      this->m_g[11] = -0.0124183; 
187
 
      this->m_g[12] =  0.0123625;
188
 
      this->m_g[13] =  0.00751369; 
189
 
      this->m_g[14] = -0.00750374; 
190
 
      this->m_g[15] = -0.00455348; 
191
 
      this->m_g[16] =  0.00455363;
192
 
      this->m_g[17] =  0.00276047; 
193
 
      this->m_g[18] = -0.00276406; 
194
 
      this->m_g[19] = -0.00167279; 
195
 
      this->m_g[20] =  0.00167938;
196
 
      this->m_h[0]  =  1.14324; 
197
 
      this->m_h[1]  =  0.643609; 
198
 
      this->m_h[2]  = -0.0937888; 
199
 
      this->m_h[3]  = -0.194993; 
200
 
      this->m_h[4]  =  0.030127;
201
 
      this->m_h[5]  =  0.0699433; 
202
 
      this->m_h[6]  = -0.0108345; 
203
 
      this->m_h[7]  = -0.0252663; 
204
 
      this->m_h[8]  =  0.00391424;
205
 
      this->m_h[9]  =  0.00912967; 
206
 
      this->m_h[10] = -0.00141437; 
207
 
      this->m_h[11] = -0.00329892; 
208
 
      this->m_h[12] =  0.000511068;
209
 
      this->m_h[13] =  0.00119204; 
210
 
      this->m_h[14] = -0.00018467; 
211
 
      this->m_h[15] = -0.000430732; 
212
 
      this->m_h[16] =  0.0000667289;
213
 
      this->m_h[17] =  0.000155641; 
214
 
      this->m_h[18] = -0.0000241119; 
215
 
      this->m_h[19] = -0.0000562395;
 
171
      this->m_GSize = 21;
 
172
      this->m_HSize = 20;
 
173
      this->m_G.resize(this->m_GSize);
 
174
      this->m_H.resize(this->m_HSize);
 
175
      this->m_G[0]  =  0.673072; 
 
176
      this->m_G[1]  =  0.331218; 
 
177
      this->m_G[2]  = -0.139359; 
 
178
      this->m_G[3]  = -0.12051; 
 
179
      this->m_G[4]  =  0.086389;
 
180
      this->m_G[5]  =  0.0611801; 
 
181
      this->m_G[6]  = -0.0542989; 
 
182
      this->m_G[7]  = -0.034777; 
 
183
      this->m_G[8]  =  0.033388;
 
184
      this->m_G[9]  =  0.0206275; 
 
185
      this->m_G[10] = -0.0203475; 
 
186
      this->m_G[11] = -0.0124183; 
 
187
      this->m_G[12] =  0.0123625;
 
188
      this->m_G[13] =  0.00751369; 
 
189
      this->m_G[14] = -0.00750374; 
 
190
      this->m_G[15] = -0.00455348; 
 
191
      this->m_G[16] =  0.00455363;
 
192
      this->m_G[17] =  0.00276047; 
 
193
      this->m_G[18] = -0.00276406; 
 
194
      this->m_G[19] = -0.00167279; 
 
195
      this->m_G[20] =  0.00167938;
 
196
      this->m_H[0]  =  1.14324; 
 
197
      this->m_H[1]  =  0.643609; 
 
198
      this->m_H[2]  = -0.0937888; 
 
199
      this->m_H[3]  = -0.194993; 
 
200
      this->m_H[4]  =  0.030127;
 
201
      this->m_H[5]  =  0.0699433; 
 
202
      this->m_H[6]  = -0.0108345; 
 
203
      this->m_H[7]  = -0.0252663; 
 
204
      this->m_H[8]  =  0.00391424;
 
205
      this->m_H[9]  =  0.00912967; 
 
206
      this->m_H[10] = -0.00141437; 
 
207
      this->m_H[11] = -0.00329892; 
 
208
      this->m_H[12] =  0.000511068;
 
209
      this->m_H[13] =  0.00119204; 
 
210
      this->m_H[14] = -0.00018467; 
 
211
      this->m_H[15] = -0.000430732; 
 
212
      this->m_H[16] =  0.0000667289;
 
213
      this->m_H[17] =  0.000155641; 
 
214
      this->m_H[18] = -0.0000241119; 
 
215
      this->m_H[19] = -0.0000562395;
216
216
      break;
217
217
    default :
218
218
      // Throw an execption for unsupported splines.
248
248
  
249
249
  for (inK = 0; inK < inTraverseSize; inK++) 
250
250
    {
251
 
    temp[inK] = in[inK] * this->m_g[0];
 
251
    temp[inK] = in[inK] * this->m_G[0];
252
252
  
253
 
    for (int i = 1; i < this->m_gSize; i++) 
 
253
    for (int i = 1; i < this->m_GSize; i++) 
254
254
      {
255
255
      // Calculate indicies for left and right of symmetrical filter.
256
256
      i1 = inK - i;
272
272
          i2 = inModK - i2 - 1L;
273
273
          }
274
274
        }
275
 
      temp[inK] += this->m_g[i]*(in[i1] + in[i2]);
 
275
      temp[inK] += this->m_G[i]*(in[i1] + in[i2]);
276
276
      }
277
277
    }
278
278
 
304
304
  //inTraverseSize = outTraverseSize/2;  // ensures that an even number is used.
305
305
  long inModK; // number for modulus math of in
306
306
  inModK = outTraverseSize;
307
 
  long k0 = (this->m_hSize/2) * 2 - 1L;
 
307
  long k0 = (this->m_HSize/2) * 2 - 1L;
308
308
 
309
309
 
310
310
  double outVal, outVal2;
313
313
  for (inK = 0; inK < (long) inTraverseSize; inK++) 
314
314
    {
315
315
    //outK = inK * 2L;
316
 
    outVal = in[inK] * this->m_h[0];
317
 
    for (int k = 2; k < this->m_hSize; k += 2)
 
316
    outVal = in[inK] * this->m_H[0];
 
317
    for (int k = 2; k < this->m_HSize; k += 2)
318
318
      {
319
319
      i1 = inK - k / 2L;
320
320
      i2 = inK + k / 2L;
334
334
          i2 = outTraverseSize- i2 - 1L;
335
335
          }
336
336
        }
337
 
      outVal += this->m_h[k] * (in[i1] + in[i2]);
 
337
      outVal += this->m_H[k] * (in[i1] + in[i2]);
338
338
      }
339
339
    out.Set( static_cast<OutputImagePixelType> (outVal) );
340
340
    ++out;
341
341
    outVal2 = 0;
342
 
    for (long k = -k0; k < this->m_hSize; k += 2L )
 
342
    for (long k = -k0; k < this->m_HSize; k += 2L )
343
343
      {
344
344
      long kk = vcl_abs(static_cast<int>(k));
345
345
      i1 = inK + ( k + 1L )/2L;
359
359
          i1 = outTraverseSize - i1 - 1;
360
360
          }
361
361
        }
362
 
      outVal2 += this->m_h[kk] * in[i1];
 
362
      outVal2 += this->m_H[kk] * in[i1];
363
363
      }
364
364
    out.Set( static_cast<OutputImagePixelType> (outVal2) );
365
365
    ++out;
367
367
 
368
368
  // Now apply the Haar[-x] 
369
369
  --out;
370
 
  for (long j = outTraverseSize - 1; j > 0L ; j-- )
 
370
  for (long j = outTraverseSize - 1; j > 0L; j-- )
371
371
    {
372
372
    // out[j] = (out[j] + out[j-1]/2.0;
373
373
    outVal = out.Get();