17 #ifndef __itkFiniteDifferenceSparseImageFilter_txx
18 #define __itkFiniteDifferenceSparseImageFilter_txx
24 template <
class TInputImageType,
class TSparseOutputImageType>
25 FiniteDifferenceSparseImageFilter <TInputImageType, TSparseOutputImageType>
29 m_PrecomputeFlag =
false;
32 template <
class TInputImageType,
class TSparseOutputImageType>
35 ::PrintSelf(std::ostream& os,
Indent indent)
const
37 Superclass::PrintSelf(os, indent);
38 os << indent <<
"PrecomputeFlag: " << m_PrecomputeFlag << std::endl;
41 template <
class TInputImageType,
class TSparseOutputImageType>
46 m_SparseFunction = sf;
47 Superclass::SetDifferenceFunction (sf);
50 template <
class TInputImageType,
class TSparseOutputImageType>
55 m_RegionList=(this->GetOutput()->GetNodeList())
56 ->SplitRegions(this->GetNumberOfThreads());
65 template <
class TInputImageType,
class TSparseOutputImageType>
70 splitRegion.
first = m_RegionList[i].first;
71 splitRegion.
last = m_RegionList[i].last;
77 template<
class TInputImageType,
class TSparseOutputImageType>
86 this->GetMultiThreader()->SetNumberOfThreads(this->GetNumberOfThreads());
87 this->GetMultiThreader()->SetSingleMethod(this->ApplyUpdateThreaderCallback,
90 this->GetMultiThreader()->SingleMethodExecute();
93 template<
class TInputImageType,
class TSparseOutputImageType>
99 int total, threadId, threadCount;
113 if (threadId < total)
121 template <
class TInputImageType,
class TSparseOutputImageType>
127 typename NodeListType::Iterator it;
129 for (it=regionToProcess.
first; it != regionToProcess.
last; ++it)
133 it->m_Data = this->DataConstraint (it->m_Data +
138 template <
class TInputImageType,
class TSparseOutputImageType>
148 this->GetMultiThreader()->SetSingleMethod
149 (this->PrecalculateChangeThreaderCallback,&str);
152 this->GetMultiThreader()->SingleMethodExecute();
155 template <
class TInputImageType,
class TSparseOutputImageType>
157 TSparseOutputImageType>::TimeStepType
161 if (m_PrecomputeFlag ==
true)
163 this->PrecalculateChange();
171 str.
TimeStep = NumericTraits<TimeStepType>::Zero;
174 this->GetMultiThreader()->SetNumberOfThreads(this->GetNumberOfThreads());
175 this->GetMultiThreader()->SetSingleMethod
176 (this->CalculateChangeThreaderCallback,&str);
182 threadCount = this->GetMultiThreader()->GetNumberOfThreads();
185 for (
int i =0; i < threadCount; ++i)
191 this->GetMultiThreader()->SingleMethodExecute();
205 template <
class TInputImageType,
class TSparseOutputImageType>
211 int total, threadId, threadCount;
226 if( threadId < total )
236 template <
class TInputImageType,
class TSparseOutputImageType>
242 int total, threadId, threadCount;
257 if (threadId < total)
265 template <
class TInputImageType,
class TSparseOutputImageType>
267 TSparseOutputImageType>::TimeStepType
272 NeighborhoodIteratorType;
274 typename SparseOutputImageType::Pointer output = this->GetOutput();
279 const SizeType radius = m_SparseFunction->GetRadius();
285 globalData = m_SparseFunction->GetGlobalDataPointer();
287 typename NodeListType::Iterator bandIt;
288 NeighborhoodIteratorType outputIt(radius, output,
289 output->GetRequestedRegion());
292 for (bandIt = regionToProcess.
first; bandIt != regionToProcess.
last; ++bandIt)
294 outputIt.SetLocation (bandIt->m_Index);
295 outputIt.GetCenterPixel()->m_Update =
296 m_SparseFunction->ComputeSparseUpdate(outputIt, globalData);
302 timeStep = m_SparseFunction->ComputeGlobalTimeStep(globalData);
303 m_SparseFunction->ReleaseGlobalDataPointer(globalData);
308 template <
class TInputImageType,
class TSparseOutputImageType>
314 NeighborhoodIteratorType;
316 typename SparseOutputImageType::Pointer output = this->GetOutput();
318 const SizeType radius = m_SparseFunction->GetRadius();
320 typename NodeListType::Iterator bandIt;
321 NeighborhoodIteratorType outputIt(radius, output,
322 output->GetRequestedRegion());
327 for (bandIt = regionToProcess.
first; bandIt != regionToProcess.
last; ++bandIt)
329 outputIt.SetLocation(bandIt->m_Index);
330 m_SparseFunction->PrecomputeSparseUpdate(outputIt);