ITK  6.0.0
Insight Toolkit
itkNarrowBandImageFilterBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 
21 #include "itkBooleanStdVector.h"
23 #include "itkMultiThreaderBase.h"
24 #include "itkNarrowBand.h"
25 #include "itkObjectStore.h"
27 
28 
29 namespace itk
30 {
69 template <typename TInputImage, typename TOutputImage>
70 class ITK_TEMPLATE_EXPORT NarrowBandImageFilterBase : public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
71 {
72 public:
73  ITK_DISALLOW_COPY_AND_MOVE(NarrowBandImageFilterBase);
74 
80 
82  itkOverrideGetNameOfClassMacro(NarrowBandImageFilterBase);
83 
85  using typename Superclass::InputImageType;
86  using typename Superclass::OutputImageType;
87  using typename Superclass::FiniteDifferenceFunctionType;
88 
91  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
92 
95  using typename Superclass::PixelType;
96 
98  using typename Superclass::TimeStepType;
99 
102 
106 
109 
115 
117  itkSetMacro(IsoSurfaceValue, ValueType);
118  itkGetConstMacro(IsoSurfaceValue, ValueType);
122  // itkGetConstMacro( RMSChange, ValueType);
123 
128  void
130  {
131  m_NarrowBand->PushBack(node); // add new node
132  this->Modified();
133  }
136  void
138  {
139  BandNodeType tmpnode;
140 
141  tmpnode.m_Index = index;
142  m_NarrowBand->PushBack(tmpnode);
143  this->Modified();
144  }
145 
146  void
147  InsertNarrowBandNode(const IndexType & index, const PixelType & value, 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
163  SetNarrowBandTotalRadius(const float val)
164  {
165  if (m_NarrowBand->GetTotalRadius() != val)
166  {
167  m_NarrowBand->SetTotalRadius(val);
168  this->Modified();
169  }
170  }
174  float
176  {
177  return m_NarrowBand->GetTotalRadius();
178  }
179 
182  void
183  SetNarrowBandInnerRadius(const float val)
184  {
185  if (m_NarrowBand->GetInnerRadius() != val)
186  {
187  m_NarrowBand->SetInnerRadius(val);
188  this->Modified();
189  }
190  }
194  float
196  {
197  return m_NarrowBand->GetInnerRadius();
198  }
199 
205  virtual void
207  {}
208 
209  virtual void
211  {
212  if (m_NarrowBand != ptr)
213  {
214  m_NarrowBand = ptr;
215  this->Modified();
216  }
217  }
218 
219  void
220  CopyInputToOutput() override;
221 
222 protected:
224  {
225  m_NarrowBand = NarrowBandType::New();
226  m_NarrowBand->SetTotalRadius(4);
227  m_NarrowBand->SetInnerRadius(2);
228  m_ReinitializationFrequency = 6;
229  m_IsoSurfaceValue = 0.0;
230  m_Step = 0;
231  m_Touched = false;
232  }
233 
234  ~NarrowBandImageFilterBase() override = default;
235  void
236  PrintSelf(std::ostream & os, Indent indent) const override;
237 
238  NarrowBandPointer m_NarrowBand{};
239 
244  {
245 
248 
251  };
252 
255  std::vector<RegionType> m_RegionList{};
256 
259  void
260  GetSplitRegion(const size_t & i, ThreadRegionType & splitRegion);
261 
266  void
267  Initialize() override;
268 
273  void
274  InitializeIteration() override;
275 
278  void
279  PostProcessOutput() override;
280 
281  /* This function clears all pixels from the narrow band */
282  void
283  ClearNarrowBand();
284 
292  void
293  GenerateData() override;
294 
295  /* Variables to control reinitialization */
296  IdentifierType m_ReinitializationFrequency{};
297  IdentifierType m_Step{};
298 
299  bool m_Touched{};
300 
301  BooleanStdVectorType m_TouchedForThread{};
302 
303  ValueType m_IsoSurfaceValue{};
304 
305 private:
306  /* This class does not use AllocateUpdateBuffer to allocate memory for its
307  * narrow band. This is taken care of in SetNarrowBand, and InsertNarrowBandNode
308  * functions. This function is here for compatibility with the
309  * FiniteDifferenceSolver framework.
310  */
311  void
313  {}
314 
318  virtual void
319  ThreadedApplyUpdate(const TimeStepType & dt, const ThreadRegionType & regionToProcess, ThreadIdType threadId);
320 
321  void
322  ApplyUpdate(const TimeStepType &) override
323  {}
324 
328  virtual TimeStepType
329  ThreadedCalculateChange(const ThreadRegionType & regionToProcess);
330 
331  TimeStepType
332  CalculateChange() override
333  {
334  return 0;
335  }
336 };
337 } // end namespace itk
338 
339 #ifndef ITK_MANUAL_INSTANTIATION
340 # include "itkNarrowBandImageFilterBase.hxx"
341 #endif
342 
343 #endif
itk::NarrowBandImageFilterBase::SetNarrowBandTotalRadius
void SetNarrowBandTotalRadius(const float val)
Definition: itkNarrowBandImageFilterBase.h:163
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkFiniteDifferenceImageFilter.h
itk::NarrowBandImageFilterBase
This class implements a multi-threaded finite difference image to image solver that can be applied to...
Definition: itkNarrowBandImageFilterBase.h:70
itkBooleanStdVector.h
itkObjectStore.h
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::NarrowBandPointer
typename NarrowBandType::Pointer NarrowBandPointer
Definition: itkNarrowBandImageFilterBase.h:112
itk::BooleanStdVectorType
std::vector< Boolean > BooleanStdVectorType
Definition: itkBooleanStdVector.h:34
itk::FiniteDifferenceImageFilter< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::TimeStepType
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
Definition: itkFiniteDifferenceImageFilter.h:167
itk::NarrowBandImageFilterBase::ThreadRegionType::first
NarrowBandIterator first
Definition: itkNarrowBandImageFilterBase.h:247
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkNarrowBandImageFilterBase.h:101
itk::BandNode::m_Index
TIndexType m_Index
Definition: itkNarrowBand.h:39
itk::NarrowBand
Narrow Band class.
Definition: itkNarrowBand.h:51
itk::NarrowBandImageFilterBase::AllocateUpdateBuffer
void AllocateUpdateBuffer() override
Definition: itkNarrowBandImageFilterBase.h:312
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::NarrowBandImageFilterBase::InsertNarrowBandNode
void InsertNarrowBandNode(const IndexType &index, const PixelType &value, const signed char nodestate)
Definition: itkNarrowBandImageFilterBase.h:147
itk::NarrowBandImageFilterBase::InsertNarrowBandNode
void InsertNarrowBandNode(const IndexType &index)
Definition: itkNarrowBandImageFilterBase.h:137
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::NarrowBandImageFilterBase::GetNarrowBandTotalRadius
float GetNarrowBandTotalRadius() const
Definition: itkNarrowBandImageFilterBase.h:175
itk::Image::ValueType
TPixel ValueType
Definition: itkImage.h:111
itk::NarrowBandImageFilterBase::NarrowBandImageFilterBase
NarrowBandImageFilterBase()
Definition: itkNarrowBandImageFilterBase.h:223
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::NarrowBandImageFilterBase::GetNarrowBandInnerRadius
float GetNarrowBandInnerRadius() const
Definition: itkNarrowBandImageFilterBase.h:195
itk::NarrowBandImageFilterBase::SetNarrowBandInnerRadius
void SetNarrowBandInnerRadius(const float val)
Definition: itkNarrowBandImageFilterBase.h:183
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::NarrowBandIterator
typename NarrowBandType::Iterator NarrowBandIterator
Definition: itkNarrowBandImageFilterBase.h:114
itk::NarrowBandImageFilterBase::InsertNarrowBandNode
void InsertNarrowBandNode(const BandNodeType &node)
Definition: itkNarrowBandImageFilterBase.h:129
itk::BandNode::m_NodeState
signed char m_NodeState
Definition: itkNarrowBand.h:40
itk::FiniteDifferenceImageFilter
Definition: itkFiniteDifferenceImageFilter.h:133
itk::FiniteDifferenceImageFilter< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::PixelType
OutputPixelType PixelType
Definition: itkFiniteDifferenceImageFilter.h:157
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkMultiThreaderBase.h
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::RegionType
typename NarrowBandType::RegionType RegionType
Definition: itkNarrowBandImageFilterBase.h:113
itk::NarrowBandImageFilterBase::ThreadRegionType
Definition: itkNarrowBandImageFilterBase.h:243
itk::NarrowBandImageFilterBase::CalculateChange
TimeStepType CalculateChange() override
Definition: itkNarrowBandImageFilterBase.h:332
itk::BandNode::m_Data
TDataType m_Data
Definition: itkNarrowBand.h:38
itk::NarrowBandImageFilterBase::ApplyUpdate
void ApplyUpdate(const TimeStepType &) override
Definition: itkNarrowBandImageFilterBase.h:322
itkPlatformMultiThreader.h
itk::NarrowBandImageFilterBase::CreateNarrowBand
virtual void CreateNarrowBand()
Definition: itkNarrowBandImageFilterBase.h:206
New
static Pointer New()
itk::BandNode
Definition: itkNarrowBand.h:35
itk::NarrowBandImageFilterBase::ThreadRegionType::last
NarrowBandIterator last
Definition: itkNarrowBandImageFilterBase.h:250
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::ValueType
typename OutputImageType::ValueType ValueType
Definition: itkNarrowBandImageFilterBase.h:105
itk::NarrowBand::Iterator
typename NodeContainerType::iterator Iterator
Definition: itkNarrowBand.h:71
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
itkNarrowBand.h
itk::NarrowBandImageFilterBase::SetNarrowBand
virtual void SetNarrowBand(NarrowBandType *ptr)
Definition: itkNarrowBandImageFilterBase.h:210