ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkNarrowBandImageFilterBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkNarrowBandImageFilterBase_h
19 #define itkNarrowBandImageFilterBase_h
20 
22 #include "itkMultiThreader.h"
23 #include "itkNarrowBand.h"
24 #include "itkBarrier.h"
25 #include "itkObjectStore.h"
26 
27 namespace itk
28 {
67 template< typename TInputImage, typename TOutputImage >
69  public FiniteDifferenceImageFilter< TInputImage, TOutputImage >
70 {
71 public:
72 
78 
81 
86 
89  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
90 
93  typedef typename Superclass::PixelType PixelType;
94 
97 
100 
104 
107 
113 
115  itkSetMacro(IsoSurfaceValue, ValueType);
116  itkGetConstMacro(IsoSurfaceValue, ValueType);
118 
120  // itkGetConstMacro( RMSChange, ValueType);
121 
127  {
128  m_NarrowBand->PushBack(node); // add new node
129  this->Modified();
130  }
132 
133  void InsertNarrowBandNode(const IndexType & index)
134  {
135  BandNodeType tmpnode;
136 
137  tmpnode.m_Index = index;
138  m_NarrowBand->PushBack(tmpnode);
139  this->Modified();
140  }
141 
142  void InsertNarrowBandNode(const IndexType & index,
143  const PixelType & value,
144  const signed char & nodestate)
145  {
146  BandNodeType tmpnode;
147 
148  tmpnode.m_Data = value;
149  tmpnode.m_Index = index;
150  tmpnode.m_NodeState = nodestate;
151 
152  m_NarrowBand->PushBack(tmpnode);
153  this->Modified();
154  }
155 
159  void SetNarrowBandTotalRadius(const float& val)
160  {
161  if ( m_NarrowBand->GetTotalRadius() != val )
162  {
163  m_NarrowBand->SetTotalRadius(val);
164  this->Modified();
165  }
166  }
168 
171  {
172  return m_NarrowBand->GetTotalRadius();
173  }
174 
177  void SetNarrowBandInnerRadius(const float& val)
178  {
179  if ( m_NarrowBand->GetInnerRadius() != val )
180  {
181  m_NarrowBand->SetInnerRadius(val);
182  this->Modified();
183  }
184  }
186 
189  {
190  return m_NarrowBand->GetInnerRadius();
191  }
192 
198  virtual void CreateNarrowBand(){}
199 
200  virtual void SetNarrowBand(NarrowBandType *ptr)
201  {
202  if ( m_NarrowBand != ptr )
203  {
204  m_NarrowBand = ptr;
205  this->Modified();
206  }
207  }
208 
209  virtual void CopyInputToOutput() ITK_OVERRIDE;
210 
211 protected:
213  {
215  m_NarrowBand->SetTotalRadius(4);
216  m_NarrowBand->SetInnerRadius(2);
218  m_IsoSurfaceValue = 0.0;
219  m_Step = 0;
220  m_Touched = false;
222  }
223 
225  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
226 
228 
233 
236 
239  };
240 
243  std::vector< RegionType > m_RegionList;
244 
247  void GetSplitRegion(const size_t& i, ThreadRegionType & splitRegion);
248 
253  virtual void Initialize() ITK_OVERRIDE;
254 
259  virtual void InitializeIteration() ITK_OVERRIDE;
260 
263  virtual void PostProcessOutput() ITK_OVERRIDE;
264 
265  /* This function clears all pixels from the narrow band */
266  void ClearNarrowBand();
267 
269  void WaitForAll();
270 
274  virtual void GenerateData() ITK_OVERRIDE;
275 
276  /* Variables to control reinitialization */
279 
280  bool m_Touched;
281 
282  std::vector< bool > m_TouchedForThread;
283 
285 
287 
288 private:
289  NarrowBandImageFilterBase(const Self &); //purposely not implemented
290  void operator=(const Self &); //purposely not implemented
291 
297  std::vector< TimeStepType > TimeStepList;
298  std::vector< bool > ValidTimeStepList;
299  };
300 
301  /* This class does not use AllocateUpdateBuffer to allocate memory for its
302  * narrow band. This is taken care of in SetNarrowBand, and InsertNarrowBandNode
303  * functions. This function is here for compatibility with the
304  * FiniteDifferenceSolver framework.
305  */
306  virtual void AllocateUpdateBuffer() ITK_OVERRIDE {}
307 
310 
314  virtual void ThreadedIterate(void *arg, ThreadIdType threadId);
315 
319  virtual void ThreadedApplyUpdate(const TimeStepType& dt,
320  const ThreadRegionType & regionToProcess,
321  ThreadIdType threadId);
322 
323  virtual void ApplyUpdate(const TimeStepType&) ITK_OVERRIDE {}
324 
328  virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType & regionToProcess,
329  ThreadIdType threadId);
330 
331  virtual TimeStepType CalculateChange() ITK_OVERRIDE { return 0; }
332 };
333 } // end namespace itk
334 
335 #ifndef ITK_MANUAL_INSTANTIATION
336 #include "itkNarrowBandImageFilterBase.hxx"
337 #endif
338 
339 #endif
Light weight base class for most itk classes.
virtual void ApplyUpdate(const TimeStepType &) override
virtual void SetNarrowBand(NarrowBandType *ptr)
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void ThreadedIterate(void *arg, ThreadIdType threadId)
virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType &regionToProcess, ThreadIdType threadId)
Superclass::InputImageType InputImageType
TDataType m_Data
Definition: itkNarrowBand.h:38
TPixel ValueType
Definition: itkImage.h:96
static Pointer New()
#define ITK_THREAD_RETURN_TYPE
Superclass::FiniteDifferenceFunctionType FiniteDifferenceFunctionType
void InsertNarrowBandNode(const BandNodeType &node)
SizeValueType IdentifierType
Definition: itkIntTypes.h:147
virtual void PostProcessOutput() override
FiniteDifferenceImageFilter< TInputImage, TOutputImage > Superclass
void InsertNarrowBandNode(const IndexType &index, const PixelType &value, const signed char &nodestate)
NodeContainerType::iterator Iterator
Definition: itkNarrowBand.h:69
virtual void Initialize() override
void InsertNarrowBandNode(const IndexType &index)
signed char m_NodeState
Definition: itkNarrowBand.h:40
Superclass::IndexType IndexType
Definition: itkImage.h:122
void GetSplitRegion(const vcl_size_t &i, ThreadRegionType &splitRegion)
virtual void Modified() const
Narrow Band class.
Definition: itkNarrowBand.h:51
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
TIndexType m_Index
Definition: itkNarrowBand.h:39
FiniteDifferenceFunctionType::TimeStepType TimeStepType
virtual void CopyInputToOutput() override
This class implements a multi-threaded finite difference image to image solver that can be applied to...
Base class for filters that take an image as input and produce an image as output.
virtual void InitializeIteration() override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
FiniteDifferenceFunction< TOutputImage > FiniteDifferenceFunctionType
static Pointer New()
virtual TimeStepType CalculateChange() override
virtual void GenerateData() override
Superclass::OutputImageType OutputImageType
virtual void ThreadedApplyUpdate(const TimeStepType &dt, const ThreadRegionType &regionToProcess, ThreadIdType threadId)
BandNode< IndexType, PixelType > BandNodeType
static ITK_THREAD_RETURN_TYPE IterateThreaderCallback(void *arg)
Standard barrier class implementation for synchronizing the execution of threads. ...
Definition: itkBarrier.h:41