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

« back to all changes in this revision

Viewing changes to Code/BasicFilters/itkNarrowBandImageFilterBase.h

  • 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: itkNarrowBandImageFilterBase.h,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2003-09-10 14:28:52 $
7
 
  Version:   $Revision: 1.9 $
 
6
  Date:      $Date: 2008-10-16 19:33:44 $
 
7
  Version:   $Revision: 1.10 $
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.
14
14
     PURPOSE.  See the above copyright notices for more information.
15
15
 
16
16
=========================================================================*/
17
 
#ifndef __itkNarrowBandImageFilterBase_h_
18
 
#define __itkNarrowBandImageFilterBase_h_
 
17
#ifndef __itkNarrowBandImageFilterBase_h
 
18
#define __itkNarrowBandImageFilterBase_h
19
19
 
20
20
#include "itkFiniteDifferenceImageFilter.h"
21
21
#include "itkMultiThreader.h"
68
68
{
69
69
public:
70
70
  /** Standard class typedefs */
71
 
  typedef NarrowBandImageFilterBase Self;
 
71
  typedef NarrowBandImageFilterBase                              Self;
72
72
  typedef FiniteDifferenceImageFilter<TInputImage, TOutputImage> Superclass;
73
 
  typedef SmartPointer<Self>  Pointer;
74
 
  typedef SmartPointer<const Self>  ConstPointer;
 
73
  typedef SmartPointer<Self>                                     Pointer;
 
74
  typedef SmartPointer<const Self>                               ConstPointer;
75
75
 
76
76
  /** Run-time type information (and related methods) */
77
77
  itkTypeMacro(NarrowBandImageFilterBase, ImageToImageFilter );
78
78
  
79
79
  /**Typedefs from the superclass */
80
 
  typedef typename Superclass::InputImageType  InputImageType;
81
 
  typedef typename Superclass::OutputImageType OutputImageType;
 
80
  typedef typename Superclass::InputImageType               InputImageType;
 
81
  typedef typename Superclass::OutputImageType              OutputImageType;
82
82
  typedef typename Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType;
83
83
  
84
84
  /** Dimensionality of input and output data is assumed to be the same.
92
92
  /** The value type of a time step.  Inherited from the superclass. */
93
93
  typedef typename Superclass::TimeStepType TimeStepType;
94
94
 
95
 
  /** The index type for the output image*/
 
95
  /** The index type for the output image. */
96
96
  typedef typename OutputImageType::IndexType IndexType;
97
97
  
98
98
  /** The data type used in numerical computations.  Derived from the output
99
99
   *  image type. */
100
100
  typedef typename OutputImageType::ValueType ValueType;
101
101
 
102
 
  /** This is the storage type for the nodes on the narrow band */
 
102
  /** This is the storage type for the nodes on the narrow band. */
103
103
  typedef BandNode<IndexType,PixelType> BandNodeType;
104
104
 
105
105
  /** The list type for storing the narrow band. */
106
 
  typedef NarrowBand<BandNodeType> NarrowBandType;
107
 
  typedef typename NarrowBandType::Pointer NarrowBandPointer;
 
106
  typedef NarrowBand<BandNodeType>            NarrowBandType;
 
107
  typedef typename NarrowBandType::Pointer    NarrowBandPointer;
108
108
  typedef typename NarrowBandType::RegionType RegionType;
109
109
 
110
110
  /** Set/Get IsoSurfaceValue to use in the input image */
117
117
  /** This function is used to insert a pixel index into the narrow band  The
118
118
   *   entire narrow band can be constructed using this method.  Usually,
119
119
   *   however, the narrow band is initialized and reinitialized automatically
120
 
   *   by the subclass.*/
 
120
   *   by the subclass. */
121
121
  void InsertNarrowBandNode (BandNodeType &node) 
122
 
  {
 
122
    {
123
123
    m_NarrowBand->PushBack(node); // add new node 
124
124
    this->Modified();
125
 
  };
 
125
    }
126
126
  void InsertNarrowBandNode (IndexType &index)
127
 
  {
 
127
    {
128
128
    BandNodeType tmpnode;
129
129
    tmpnode.m_Index = index;
130
130
    m_NarrowBand->PushBack(tmpnode);
131
131
    this->Modified();
132
 
  };
 
132
    }
133
133
  void InsertNarrowBandNode (IndexType &index, PixelType &value, signed char &nodestate)
134
 
  {
 
134
    {
135
135
    BandNodeType tmpnode;
136
136
    tmpnode.m_Data = value;
137
137
    tmpnode.m_Index = index;
139
139
    
140
140
    m_NarrowBand->PushBack(tmpnode);
141
141
    this->Modified();
142
 
  }; 
 
142
    } 
143
143
  
144
 
  /** Set the narrow band total radius. The narrow band width will be twice
145
 
      this value (positive and negative distance to the zero level set).
146
 
      The default value is 3.
147
 
  */
 
144
  /** Set the narrow band total radius. The narrow band width will be
 
145
   * twice this value (positive and negative distance to the zero level
 
146
   * set). The default value is 3. */
148
147
  void SetNarrowBandTotalRadius (float val)
149
 
  {
 
148
    {
150
149
    if (m_NarrowBand->GetTotalRadius() != val)
151
150
      {
152
 
      m_NarrowBand->SetTotalRadius(val);    
 
151
      m_NarrowBand->SetTotalRadius(val);
153
152
      this->Modified();
154
153
      }
155
 
  }
 
154
    }
156
155
  
157
156
  /** Get the narrow band total radius. */
158
157
  float GetNarrowBandTotalRadius()
159
 
  {
 
158
    {
160
159
    return m_NarrowBand->GetTotalRadius();
161
 
  }
 
160
    }
162
161
  
163
 
  /** Set the narrow band inner radius. The inner radius is the safe are
164
 
      where the level set can be computed.
165
 
      The default value is 1.
166
 
  */
 
162
  /** Set the narrow band inner radius. The inner radius is the safe
 
163
   * are where the level set can be computed. The default value is 1. */
167
164
  void SetNarrowBandInnerRadius (float val)
168
 
  {
 
165
    {
169
166
    if (m_NarrowBand->GetInnerRadius() != val)
170
167
      {
171
168
      m_NarrowBand->SetInnerRadius(val);
172
169
      this->Modified();
173
170
      }
174
 
  }
 
171
    }
175
172
 
176
173
  /** Get the narrow band inner radius. */
177
174
  float GetNarrowBandInnerRadius()
178
 
  {
 
175
    {
179
176
    return m_NarrowBand->GetInnerRadius();
180
 
  }
 
177
    }
181
178
  
182
179
  /** This is the virtual method called by Initialize to set the band of operation.
183
180
   *  It is left to the subclasses to define this functionality. 
187
184
  virtual void CreateNarrowBand (){};
188
185
  
189
186
  virtual void SetNarrowBand(NarrowBandType * ptr)
190
 
  {
191
 
    
 
187
    {
192
188
    if ( m_NarrowBand != ptr )
193
189
      {
194
190
      m_NarrowBand = ptr;
195
191
      this->Modified();
196
192
      }   
197
 
  };
 
193
    }
198
194
  
199
195
  virtual void CopyInputToOutput ();
200
196
  
201
197
protected:
202
198
  typename NarrowBandType::Pointer m_NarrowBand;
203
199
  NarrowBandImageFilterBase() 
204
 
  {
 
200
    {
205
201
    m_NarrowBand = NarrowBandType::New();
206
202
    m_NarrowBand->SetTotalRadius(4);
207
203
    m_NarrowBand->SetInnerRadius(2);
210
206
    m_Step    = 0;
211
207
    m_Touched = false;
212
208
    m_Barrier = Barrier::New();
213
 
  }
 
209
    }
214
210
  
215
211
  virtual ~NarrowBandImageFilterBase() {}
216
212
  void PrintSelf(std::ostream& os, Indent indent) const;
218
214
  /** The type of region used in multithreading.  Defines a subregion of the
219
215
      narrowband. */
220
216
  struct ThreadRegionType 
221
 
  {
 
217
    {
222
218
    typename NarrowBandType::Iterator first; // this is the actual first element
223
219
    typename NarrowBandType::Iterator last;  // this is one past the actual last //element
224
 
  };
 
220
    };
225
221
  
226
222
  /** A list of subregions of the narrowband which are passed to each thread
227
223
   * for parallel processing. */
261
257
  /* Variables to control reinitialization */
262
258
  unsigned int m_ReinitializationFrequency;
263
259
  unsigned int m_Step;
264
 
  bool m_Touched;
265
 
  bool * m_TouchedForThread;
266
 
  ValueType m_IsoSurfaceValue;
 
260
  bool         m_Touched;
 
261
  bool *       m_TouchedForThread;
 
262
  ValueType    m_IsoSurfaceValue;
267
263
  
268
264
  typename Barrier::Pointer m_Barrier;
269
265
 
274
270
  /** Structure for passing information into static callback methods.  Used in
275
271
   * the subclasses' threading mechanisms. */
276
272
  struct NarrowBandImageFilterBaseThreadStruct
277
 
  {
 
273
    {
278
274
    NarrowBandImageFilterBase *Filter;
279
275
    TimeStepType TimeStep;
280
276
    TimeStepType *TimeStepList;
281
277
    bool *ValidTimeStepList;
282
 
  };
 
278
    };
283
279
  
284
280
  /* This class does not use AllocateUpdateBuffer to allocate memory for its 
285
281
   * narrow band. This is taken care of in SetNarrowBand, and InsertNarrowBandNode
297
293
   * and ThreadedCalculateChange to update the solution at every iteration. */ 
298
294
  virtual void ThreadedIterate(void *arg, int threadId);
299
295
 
300
 
 /** This method applies changes from the m_NarrowBand to the output using
 
296
  /** This method applies changes from the m_NarrowBand to the output using
301
297
   * the ThreadedApplyUpdate() method and a multithreading mechanism.  "dt" is
302
298
   * the time step to use for the update of each pixel. */  
303
299
  virtual void ThreadedApplyUpdate(TimeStepType dt,