ITK  5.0.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 "itkMultiThreaderBase.h"
23 #include "itkNarrowBand.h"
24 #include "itkBarrier.h"
25 #include "itkObjectStore.h"
27 
28 
29 namespace itk
30 {
69 template< typename TInputImage, typename TOutputImage >
70 class ITK_TEMPLATE_EXPORT NarrowBandImageFilterBase:
71  public FiniteDifferenceImageFilter< TInputImage, TOutputImage >
72 {
73 public:
74  ITK_DISALLOW_COPY_AND_ASSIGN(NarrowBandImageFilterBase);
75 
81 
84 
86  using InputImageType = typename Superclass::InputImageType;
87  using OutputImageType = typename Superclass::OutputImageType;
88  using FiniteDifferenceFunctionType = typename Superclass::FiniteDifferenceFunctionType;
89 
92  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
93 
96  using PixelType = typename Superclass::PixelType;
97 
99  using TimeStepType = typename Superclass::TimeStepType;
100 
103 
107 
110 
116 
118  itkSetMacro(IsoSurfaceValue, ValueType);
119  itkGetConstMacro(IsoSurfaceValue, ValueType);
121 
123  // itkGetConstMacro( RMSChange, ValueType);
124 
130  {
131  m_NarrowBand->PushBack(node); // add new node
132  this->Modified();
133  }
135 
136  void InsertNarrowBandNode(const IndexType & index)
137  {
138  BandNodeType tmpnode;
139 
140  tmpnode.m_Index = index;
141  m_NarrowBand->PushBack(tmpnode);
142  this->Modified();
143  }
144 
145  void InsertNarrowBandNode(const IndexType & index,
146  const PixelType & value,
147  const signed char & nodestate)
148  {
149  BandNodeType tmpnode;
150 
151  tmpnode.m_Data = value;
152  tmpnode.m_Index = index;
153  tmpnode.m_NodeState = nodestate;
154 
155  m_NarrowBand->PushBack(tmpnode);
156  this->Modified();
157  }
158 
162  void SetNarrowBandTotalRadius(const float& val)
163  {
164  if ( m_NarrowBand->GetTotalRadius() != val )
165  {
166  m_NarrowBand->SetTotalRadius(val);
167  this->Modified();
168  }
169  }
171 
174  {
175  return m_NarrowBand->GetTotalRadius();
176  }
177 
180  void SetNarrowBandInnerRadius(const float& val)
181  {
182  if ( m_NarrowBand->GetInnerRadius() != val )
183  {
184  m_NarrowBand->SetInnerRadius(val);
185  this->Modified();
186  }
187  }
189 
192  {
193  return m_NarrowBand->GetInnerRadius();
194  }
195 
201  virtual void CreateNarrowBand(){}
202 
203  virtual void SetNarrowBand(NarrowBandType *ptr)
204  {
205  if ( m_NarrowBand != ptr )
206  {
207  m_NarrowBand = ptr;
208  this->Modified();
209  }
210  }
211 
212  void CopyInputToOutput() override;
213 
214 protected:
216  {
217  m_NarrowBand = NarrowBandType::New();
218  m_NarrowBand->SetTotalRadius(4);
219  m_NarrowBand->SetInnerRadius(2);
220  m_ReinitializationFrequency = 6;
221  m_IsoSurfaceValue = 0.0;
222  m_Step = 0;
223  m_Touched = false;
224  }
225 
226  ~NarrowBandImageFilterBase() override = default;
227  void PrintSelf(std::ostream & os, Indent indent) const override;
228 
230 
235 
238 
241  };
242 
245  std::vector< RegionType > m_RegionList;
246 
249  void GetSplitRegion(const size_t& i, ThreadRegionType & splitRegion);
250 
255  void Initialize() override;
256 
261  void InitializeIteration() override;
262 
265  void PostProcessOutput() override;
266 
267  /* This function clears all pixels from the narrow band */
268  void ClearNarrowBand();
269 
277  void GenerateData() override;
278 
279  /* Variables to control reinitialization */
282 
283  bool m_Touched;
284 
285  std::vector< bool > m_TouchedForThread;
286 
288 
289 private:
290 
291  /* This class does not use AllocateUpdateBuffer to allocate memory for its
292  * narrow band. This is taken care of in SetNarrowBand, and InsertNarrowBandNode
293  * functions. This function is here for compatibility with the
294  * FiniteDifferenceSolver framework.
295  */
296  void AllocateUpdateBuffer() override {}
297 
301  virtual void ThreadedApplyUpdate(const TimeStepType& dt,
302  const ThreadRegionType & regionToProcess,
303  ThreadIdType threadId);
304 
305  void ApplyUpdate(const TimeStepType&) override {}
306 
310  virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType & regionToProcess);
311 
312  TimeStepType CalculateChange() override { return 0; }
313 };
314 } // end namespace itk
315 
316 #ifndef ITK_MANUAL_INSTANTIATION
317 #include "itkNarrowBandImageFilterBase.hxx"
318 #endif
319 
320 #endif
Light weight base class for most itk classes.
void ApplyUpdate(const TimeStepType &) override
virtual void SetNarrowBand(NarrowBandType *ptr)
TDataType m_Data
Definition: itkNarrowBand.h:38
TPixel ValueType
Definition: itkImage.h:98
void InsertNarrowBandNode(const BandNodeType &node)
void InsertNarrowBandNode(const IndexType &index, const PixelType &value, const signed char &nodestate)
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
void InsertNarrowBandNode(const IndexType &index)
signed char m_NodeState
Definition: itkNarrowBand.h:40
Narrow Band class.
Definition: itkNarrowBand.h:51
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
TIndexType m_Index
Definition: itkNarrowBand.h:39
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.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Templated n-dimensional image class.
Definition: itkImage.h:75
typename NodeContainerType::iterator Iterator
Definition: itkNarrowBand.h:71