ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkConstrainedRegionBasedLevelSetFunctionSharedData.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 itkConstrainedRegionBasedLevelSetFunctionSharedData_h
19 #define itkConstrainedRegionBasedLevelSetFunctionSharedData_h
20 
22 
23 namespace itk
24 {
60 template< typename TInputImage, typename TFeatureImage, typename TSingleData >
62  public RegionBasedLevelSetFunctionSharedData< TInputImage, TFeatureImage, TSingleData >
63 {
64 public:
65 
71 
72  itkStaticConstMacro(ImageDimension, unsigned int, TFeatureImage::ImageDimension);
73 
75  itkNewMacro(Self);
76 
78 
79  typedef TInputImage InputImageType;
90 
91  typedef TFeatureImage FeatureImageType;
101 
114 
119  typedef typename Superclass::TreeType TreeType;
121 
122  typedef TSingleData LevelSetDataType;
126 
127  void PopulateListImage() ITK_OVERRIDE
128  {
129  ListSpacingType spacing = this->m_NearestNeighborListImage->GetSpacing();
130 
131  ListRegionType region = this->m_NearestNeighborListImage->GetLargestPossibleRegion();
132 
133  ListIteratorType lIt(this->m_NearestNeighborListImage, region);
134 
135  if ( this->m_KdTree.IsNotNull() )
136  {
137  for ( lIt.GoToBegin(); !lIt.IsAtEnd(); ++lIt )
138  {
139  ListIndexType ind = lIt.GetIndex();
140 
141  float queryPoint[ImageDimension];
142  for ( unsigned int i = 0; i < ImageDimension; i++ )
143  {
144  queryPoint[i] = ind[i] * spacing[i];
145  }
146 
147  typename TreeType::InstanceIdentifierVectorType neighbors;
148  this->m_KdTree->Search(queryPoint, this->m_NumberOfNeighbors, neighbors);
149 
150  ListPixelType L;
151  for ( unsigned int i = 0; i < this->m_NumberOfNeighbors; i++ )
152  {
153  if ( this->m_LevelSetDataPointerVector[i]->VerifyInsideRegion(ind) )
154  {
155  L.push_back(neighbors[i]);
156  }
157  }
158  lIt.Set(L);
159  }
160  }
161  else
162  {
163  for ( lIt.GoToBegin(); !lIt.IsAtEnd(); ++lIt )
164  {
165  ListIndexType ind = lIt.GetIndex();
166  ListPixelType L;
167  for ( unsigned int i = 0; i < this->m_FunctionCount; i++ )
168  {
169  if ( this->m_LevelSetDataPointerVector[i]->VerifyInsideRegion(ind) )
170  {
171  L.push_back(i);
172  }
173  }
174  lIt.Set(L);
175  }
176  }
177  }
178 
179 protected:
182 
183 private:
185  // not
186  // implemented
187  void operator=(const Self &); //purposely
188  // not
189  // implemented
190 };
191 } //end namespace itk
192 
193 #endif
Light weight base class for most itk classes.
Helper class used to share data in the ScalarChanAndVeseLevelSetFunction.
Helper class used to share data in the ScalarChanAndVeseLevelSetFunction.
void Set(const PixelType &value) const
bool IsNotNull() const
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
This class generates a KdTree object without centroid information.
std::vector< InstanceIdentifier > InstanceIdentifierVectorType
Definition: itkKdTree.h:522
This class is the native implementation of the a Sample with an STL container.
Definition: itkListSample.h:51
RegionBasedLevelSetFunctionSharedData< TInputImage, TFeatureImage, TSingleData > Superclass
This class provides methods for k-nearest neighbor search and related data structures for a k-d tree...
Definition: itkKdTree.h:483
Templated n-dimensional image class.
Definition: itkImage.h:75