ITK  5.4.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"
24#include "itkNarrowBand.h"
25#include "itkObjectStore.h"
27
28
29namespace itk
30{
69template <typename TInputImage, typename TOutputImage>
70class ITK_TEMPLATE_EXPORT NarrowBandImageFilterBase : public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
71{
72public:
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
105 using ValueType = typename OutputImageType::ValueType;
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
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
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
221
222protected:
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
275
278 void
280
281 /* This function clears all pixels from the narrow band */
282 void
284
292 void
293 GenerateData() override;
294
295 /* Variables to control reinitialization */
296 IdentifierType m_ReinitializationFrequency{};
298
299 bool m_Touched{};
300
301 BooleanStdVectorType m_TouchedForThread{};
302
303 ValueType m_IsoSurfaceValue{};
304
305private:
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
330
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
TDataType m_Data
Definition: itkNarrowBand.h:38
signed char m_NodeState
Definition: itkNarrowBand.h:40
TIndexType m_Index
Definition: itkNarrowBand.h:39
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
Base class for all process objects that output image data.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
This class implements a multi-threaded finite difference image to image solver that can be applied to...
typename NarrowBandType::Pointer NarrowBandPointer
void CopyInputToOutput() override
typename NarrowBandType::Iterator NarrowBandIterator
typename OutputImageType::IndexType IndexType
~NarrowBandImageFilterBase() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
void InsertNarrowBandNode(const IndexType &index, const PixelType &value, const signed char nodestate)
typename OutputImageType::ValueType ValueType
virtual void SetNarrowBand(NarrowBandType *ptr)
void PostProcessOutput() override
void InsertNarrowBandNode(const BandNodeType &node)
virtual void ThreadedApplyUpdate(const TimeStepType &dt, const ThreadRegionType &regionToProcess, ThreadIdType threadId)
void ApplyUpdate(const TimeStepType &) override
void InsertNarrowBandNode(const IndexType &index)
typename NarrowBandType::RegionType RegionType
void InitializeIteration() override
void GetSplitRegion(const vcl_size_t &i, ThreadRegionType &splitRegion)
virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType &regionToProcess)
Narrow Band class.
Definition: itkNarrowBand.h:52
typename NodeContainerType::iterator Iterator
Definition: itkNarrowBand.h:71
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
static Pointer New()
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
std::vector< Boolean > BooleanStdVectorType