3
3
Program: Insight Segmentation & Registration Toolkit
4
4
Module: $RCSfile: itkNarrowBandImageFilterBase.h,v $
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 $
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.
16
16
=========================================================================*/
17
#ifndef __itkNarrowBandImageFilterBase_h_
18
#define __itkNarrowBandImageFilterBase_h_
17
#ifndef __itkNarrowBandImageFilterBase_h
18
#define __itkNarrowBandImageFilterBase_h
20
20
#include "itkFiniteDifferenceImageFilter.h"
21
21
#include "itkMultiThreader.h"
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;
76
76
/** Run-time type information (and related methods) */
77
77
itkTypeMacro(NarrowBandImageFilterBase, ImageToImageFilter );
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;
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;
95
/** The index type for the output image*/
95
/** The index type for the output image. */
96
96
typedef typename OutputImageType::IndexType IndexType;
98
98
/** The data type used in numerical computations. Derived from the output
100
100
typedef typename OutputImageType::ValueType ValueType;
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;
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;
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. */
121
121
void InsertNarrowBandNode (BandNodeType &node)
123
123
m_NarrowBand->PushBack(node); // add new node
124
124
this->Modified();
126
126
void InsertNarrowBandNode (IndexType &index)
128
128
BandNodeType tmpnode;
129
129
tmpnode.m_Index = index;
130
130
m_NarrowBand->PushBack(tmpnode);
131
131
this->Modified();
133
133
void InsertNarrowBandNode (IndexType &index, PixelType &value, signed char &nodestate)
135
135
BandNodeType tmpnode;
136
136
tmpnode.m_Data = value;
137
137
tmpnode.m_Index = index;
140
140
m_NarrowBand->PushBack(tmpnode);
141
141
this->Modified();
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.
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)
150
149
if (m_NarrowBand->GetTotalRadius() != val)
152
m_NarrowBand->SetTotalRadius(val);
151
m_NarrowBand->SetTotalRadius(val);
153
152
this->Modified();
157
156
/** Get the narrow band total radius. */
158
157
float GetNarrowBandTotalRadius()
160
159
return m_NarrowBand->GetTotalRadius();
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.
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)
169
166
if (m_NarrowBand->GetInnerRadius() != val)
171
168
m_NarrowBand->SetInnerRadius(val);
172
169
this->Modified();
176
173
/** Get the narrow band inner radius. */
177
174
float GetNarrowBandInnerRadius()
179
176
return m_NarrowBand->GetInnerRadius();
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 (){};
189
186
virtual void SetNarrowBand(NarrowBandType * ptr)
192
188
if ( m_NarrowBand != ptr )
194
190
m_NarrowBand = ptr;
195
191
this->Modified();
199
195
virtual void CopyInputToOutput ();
202
198
typename NarrowBandType::Pointer m_NarrowBand;
203
199
NarrowBandImageFilterBase()
205
201
m_NarrowBand = NarrowBandType::New();
206
202
m_NarrowBand->SetTotalRadius(4);
207
203
m_NarrowBand->SetInnerRadius(2);
218
214
/** The type of region used in multithreading. Defines a subregion of the
220
216
struct ThreadRegionType
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
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;
265
bool * m_TouchedForThread;
266
ValueType m_IsoSurfaceValue;
261
bool * m_TouchedForThread;
262
ValueType m_IsoSurfaceValue;
268
264
typename Barrier::Pointer m_Barrier;
274
270
/** Structure for passing information into static callback methods. Used in
275
271
* the subclasses' threading mechanisms. */
276
272
struct NarrowBandImageFilterBaseThreadStruct
278
274
NarrowBandImageFilterBase *Filter;
279
275
TimeStepType TimeStep;
280
276
TimeStepType *TimeStepList;
281
277
bool *ValidTimeStepList;
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);
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,