ITK  5.2.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  * 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 "itkObjectStore.h"
26 
27 
28 namespace itk
29 {
68 template <typename TInputImage, typename TOutputImage>
69 class ITK_TEMPLATE_EXPORT NarrowBandImageFilterBase : public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
70 {
71 public:
72  ITK_DISALLOW_COPY_AND_MOVE(NarrowBandImageFilterBase);
73 
79 
82 
84  using InputImageType = typename Superclass::InputImageType;
85  using OutputImageType = typename Superclass::OutputImageType;
86  using FiniteDifferenceFunctionType = typename Superclass::FiniteDifferenceFunctionType;
87 
90  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
91 
94  using PixelType = typename Superclass::PixelType;
95 
97  using TimeStepType = typename Superclass::TimeStepType;
98 
101 
105 
108 
114 
116  itkSetMacro(IsoSurfaceValue, ValueType);
117  itkGetConstMacro(IsoSurfaceValue, ValueType);
119 
121  // itkGetConstMacro( RMSChange, ValueType);
122 
127  void
129  {
130  m_NarrowBand->PushBack(node); // add new node
131  this->Modified();
132  }
134 
135  void
137  {
138  BandNodeType tmpnode;
139 
140  tmpnode.m_Index = index;
141  m_NarrowBand->PushBack(tmpnode);
142  this->Modified();
143  }
144 
145  void
146  InsertNarrowBandNode(const IndexType & index, const PixelType & value, const signed char & nodestate)
147  {
148  BandNodeType tmpnode;
149 
150  tmpnode.m_Data = value;
151  tmpnode.m_Index = index;
152  tmpnode.m_NodeState = nodestate;
153 
154  m_NarrowBand->PushBack(tmpnode);
155  this->Modified();
156  }
157 
161  void
162  SetNarrowBandTotalRadius(const float & val)
163  {
164  if (m_NarrowBand->GetTotalRadius() != val)
165  {
166  m_NarrowBand->SetTotalRadius(val);
167  this->Modified();
168  }
169  }
171 
173  float
175  {
176  return m_NarrowBand->GetTotalRadius();
177  }
178 
181  void
182  SetNarrowBandInnerRadius(const float & val)
183  {
184  if (m_NarrowBand->GetInnerRadius() != val)
185  {
186  m_NarrowBand->SetInnerRadius(val);
187  this->Modified();
188  }
189  }
191 
193  float
195  {
196  return m_NarrowBand->GetInnerRadius();
197  }
198 
204  virtual void
206  {}
207 
208  virtual void
210  {
211  if (m_NarrowBand != ptr)
212  {
213  m_NarrowBand = ptr;
214  this->Modified();
215  }
216  }
217 
218  void
219  CopyInputToOutput() override;
220 
221 protected:
223  {
224  m_NarrowBand = NarrowBandType::New();
225  m_NarrowBand->SetTotalRadius(4);
226  m_NarrowBand->SetInnerRadius(2);
227  m_ReinitializationFrequency = 6;
228  m_IsoSurfaceValue = 0.0;
229  m_Step = 0;
230  m_Touched = false;
231  }
232 
233  ~NarrowBandImageFilterBase() override = default;
234  void
235  PrintSelf(std::ostream & os, Indent indent) const override;
236 
238 
243  {
244 
247 
250  };
251 
254  std::vector<RegionType> m_RegionList;
255 
258  void
259  GetSplitRegion(const size_t & i, ThreadRegionType & splitRegion);
260 
265  void
266  Initialize() override;
267 
272  void
273  InitializeIteration() override;
274 
277  void
278  PostProcessOutput() override;
279 
280  /* This function clears all pixels from the narrow band */
281  void
282  ClearNarrowBand();
283 
291  void
292  GenerateData() override;
293 
294  /* Variables to control reinitialization */
297 
298  bool m_Touched;
299 
300  std::vector<bool> m_TouchedForThread;
301 
303 
304 private:
305  /* This class does not use AllocateUpdateBuffer to allocate memory for its
306  * narrow band. This is taken care of in SetNarrowBand, and InsertNarrowBandNode
307  * functions. This function is here for compatibility with the
308  * FiniteDifferenceSolver framework.
309  */
310  void
312  {}
313 
317  virtual void
318  ThreadedApplyUpdate(const TimeStepType & dt, const ThreadRegionType & regionToProcess, ThreadIdType threadId);
319 
320  void
321  ApplyUpdate(const TimeStepType &) override
322  {}
323 
327  virtual TimeStepType
328  ThreadedCalculateChange(const ThreadRegionType & regionToProcess);
329 
330  TimeStepType
331  CalculateChange() override
332  {
333  return 0;
334  }
335 };
336 } // end namespace itk
337 
338 #ifndef ITK_MANUAL_INSTANTIATION
339 # include "itkNarrowBandImageFilterBase.hxx"
340 #endif
341 
342 #endif
itkFiniteDifferenceImageFilter.h
itk::NarrowBandImageFilterBase
This class implements a multi-threaded finite difference image to image solver that can be applied to...
Definition: itkNarrowBandImageFilterBase.h:69
itkObjectStore.h
itk::NarrowBandImageFilterBase::SetNarrowBandTotalRadius
void SetNarrowBandTotalRadius(const float &val)
Definition: itkNarrowBandImageFilterBase.h:162
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::NarrowBandPointer
typename NarrowBandType::Pointer NarrowBandPointer
Definition: itkNarrowBandImageFilterBase.h:111
itk::FiniteDifferenceImageFilter< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::TimeStepType
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
Definition: itkFiniteDifferenceImageFilter.h:166
itk::NarrowBandImageFilterBase::ThreadRegionType::first
NarrowBandIterator first
Definition: itkNarrowBandImageFilterBase.h:246
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkNarrowBandImageFilterBase.h:100
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:311
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::NarrowBandImageFilterBase::SetNarrowBandInnerRadius
void SetNarrowBandInnerRadius(const float &val)
Definition: itkNarrowBandImageFilterBase.h:182
itk::NarrowBandImageFilterBase::m_NarrowBand
NarrowBandPointer m_NarrowBand
Definition: itkNarrowBandImageFilterBase.h:237
itk::NarrowBandImageFilterBase::InsertNarrowBandNode
void InsertNarrowBandNode(const IndexType &index)
Definition: itkNarrowBandImageFilterBase.h:136
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::NarrowBandImageFilterBase::GetNarrowBandTotalRadius
float GetNarrowBandTotalRadius() const
Definition: itkNarrowBandImageFilterBase.h:174
itk::Image::ValueType
TPixel ValueType
Definition: itkImage.h:109
itk::NarrowBandImageFilterBase::m_ReinitializationFrequency
IdentifierType m_ReinitializationFrequency
Definition: itkNarrowBandImageFilterBase.h:295
itk::NarrowBandImageFilterBase::NarrowBandImageFilterBase
NarrowBandImageFilterBase()
Definition: itkNarrowBandImageFilterBase.h:222
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::NarrowBandImageFilterBase::GetNarrowBandInnerRadius
float GetNarrowBandInnerRadius() const
Definition: itkNarrowBandImageFilterBase.h:194
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::NarrowBandIterator
typename NarrowBandType::Iterator NarrowBandIterator
Definition: itkNarrowBandImageFilterBase.h:113
itk::NarrowBandImageFilterBase::m_Touched
bool m_Touched
Definition: itkNarrowBandImageFilterBase.h:298
itk::NarrowBandImageFilterBase::InsertNarrowBandNode
void InsertNarrowBandNode(const BandNodeType &node)
Definition: itkNarrowBandImageFilterBase.h:128
itk::BandNode::m_NodeState
signed char m_NodeState
Definition: itkNarrowBand.h:40
itk::ImageToImageFilter< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::FiniteDifferenceImageFilter
Definition: itkFiniteDifferenceImageFilter.h:132
itk::NarrowBandImageFilterBase::m_IsoSurfaceValue
ValueType m_IsoSurfaceValue
Definition: itkNarrowBandImageFilterBase.h:302
itk::FiniteDifferenceImageFilter< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::PixelType
OutputPixelType PixelType
Definition: itkFiniteDifferenceImageFilter.h:156
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkMultiThreaderBase.h
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::RegionType
typename NarrowBandType::RegionType RegionType
Definition: itkNarrowBandImageFilterBase.h:112
itk::NarrowBandImageFilterBase::m_TouchedForThread
std::vector< bool > m_TouchedForThread
Definition: itkNarrowBandImageFilterBase.h:300
itk::NarrowBandImageFilterBase::ThreadRegionType
Definition: itkNarrowBandImageFilterBase.h:242
itk::NarrowBandImageFilterBase::CalculateChange
TimeStepType CalculateChange() override
Definition: itkNarrowBandImageFilterBase.h:331
itk::NarrowBandImageFilterBase::m_RegionList
std::vector< RegionType > m_RegionList
Definition: itkNarrowBandImageFilterBase.h:254
itk::BandNode::m_Data
TDataType m_Data
Definition: itkNarrowBand.h:38
itk::NarrowBandImageFilterBase::m_Step
IdentifierType m_Step
Definition: itkNarrowBandImageFilterBase.h:296
itk::NarrowBandImageFilterBase::ApplyUpdate
void ApplyUpdate(const TimeStepType &) override
Definition: itkNarrowBandImageFilterBase.h:321
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itkPlatformMultiThreader.h
itk::FiniteDifferenceFunction
Definition: itkFiniteDifferenceFunction.h:66
itk::NarrowBandImageFilterBase::CreateNarrowBand
virtual void CreateNarrowBand()
Definition: itkNarrowBandImageFilterBase.h:205
itk::BandNode
Definition: itkNarrowBand.h:35
itk::NarrowBandImageFilterBase::ThreadRegionType::last
NarrowBandIterator last
Definition: itkNarrowBandImageFilterBase.h:249
itk::NarrowBandImageFilterBase< TInputImage, Image< TOutputPixelType, TInputImage::ImageDimension > >::ValueType
typename OutputImageType::ValueType ValueType
Definition: itkNarrowBandImageFilterBase.h:104
itk::NarrowBand::Iterator
typename NodeContainerType::iterator Iterator
Definition: itkNarrowBand.h:71
itk::NarrowBandImageFilterBase::InsertNarrowBandNode
void InsertNarrowBandNode(const IndexType &index, const PixelType &value, const signed char &nodestate)
Definition: itkNarrowBandImageFilterBase.h:146
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
itkNarrowBand.h
itk::NarrowBandImageFilterBase::SetNarrowBand
virtual void SetNarrowBand(NarrowBandType *ptr)
Definition: itkNarrowBandImageFilterBase.h:209