ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkScalarImageKmeansImageFilter.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 itkScalarImageKmeansImageFilter_h
19 #define itkScalarImageKmeansImageFilter_h
20 
21 
22 #include "itkKdTree.h"
25 
28 #include "itkMinimumDecisionRule.h"
29 
31 
32 #include <vector>
33 
34 namespace itk
35 {
62 template< typename TInputImage,
63  typename TOutputImage = Image< unsigned char, TInputImage::ImageDimension > >
64 class ITK_TEMPLATE_EXPORT ScalarImageKmeansImageFilter:
65  public ImageToImageFilter< TInputImage, TOutputImage >
66 {
67 public:
69  itkStaticConstMacro(ImageDimension, unsigned int,
70  TInputImage::ImageDimension);
71 
73  typedef TInputImage InputImageType;
74  typedef TOutputImage OutputImageType;
75 
81 
83  itkNewMacro(Self);
84 
87 
89  typedef typename InputImageType::PixelType InputPixelType;
90  typedef typename OutputImageType::PixelType OutputPixelType;
91 
94 
97 
100 
104 
106 
109 
111 
116 
118 
119  typedef typename InputImageType::RegionType ImageRegionType;
120 
124 
126  void AddClassWithInitialMean(RealPixelType mean);
127 
129  itkGetConstReferenceMacro(FinalMeans, ParametersType);
130 
136  itkSetMacro(UseNonContiguousLabels, bool);
137  itkGetConstReferenceMacro(UseNonContiguousLabels, bool);
138  itkBooleanMacro(UseNonContiguousLabels);
140 
142  void SetImageRegion(const ImageRegionType & region);
143 
145  itkGetConstReferenceMacro(ImageRegion, ImageRegionType);
146 
147 #ifdef ITK_USE_CONCEPT_CHECKING
148  // Begin concept checking
149  itkConceptMacro( InputHasNumericTraitsCheck,
151  // End concept checking
152 #endif
153 
154 protected:
156  virtual ~ScalarImageKmeansImageFilter() ITK_OVERRIDE {}
157  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
158 
164  void GenerateData() ITK_OVERRIDE;
165 
166  /* See superclass for doxygen. This methods additionally checks that
167  * the number of means is not 0. */
168  virtual void VerifyPreconditions() ITK_OVERRIDE;
169 
170 private:
171  ITK_DISALLOW_COPY_AND_ASSIGN(ScalarImageKmeansImageFilter);
172 
173  typedef std::vector< RealPixelType > MeansContainer;
174 
175  MeansContainer m_InitialMeans;
176 
177  ParametersType m_FinalMeans;
178 
179  bool m_UseNonContiguousLabels;
180 
181  ImageRegionType m_ImageRegion;
182 
183  bool m_ImageRegionDefined;
184 };
185 } // end namespace itk
186 
187 #ifndef ITK_MANUAL_INSTANTIATION
188 #include "itkScalarImageKmeansImageFilter.hxx"
189 #endif
190 
191 #endif
itk::Statistics::MinimumDecisionRule DecisionRuleType
fast k-means algorithm implementation using k-d tree structure
NumericTraits< InputPixelType >::RealType RealPixelType
itk::Statistics::ImageToListSampleAdaptor< InputImageType > AdaptorType
An image region represents a structured region of data.
Base class for all process objects that output image data.
A decision rule that returns the class label with the smallest discriminant score.
ClassifierType::MembershipFunctionVectorType MembershipFunctionVectorType
itk::Statistics::KdTreeBasedKmeansEstimator< TreeType > EstimatorType
This class generates a KdTree object with centroid information.
itk::Statistics::DistanceToCentroidMembershipFunction< MeasurementVectorType > MembershipFunctionType
MeasurementPixelTraitsType::MeasurementVectorType MeasurementVectorType
std::vector< MembershipFunctionPointer > MembershipFunctionVectorType
itk::Statistics::SampleClassifierFilter< AdaptorType > ClassifierType
Classifies the intensity values of a scalar image using the K-Means algorithm.
ClassifierType::ClassLabelVectorType ClassLabelVectorType
Extract a region of interest from the input image.
RegionOfInterestImageFilter< InputImageType, InputImageType > RegionOfInterestFilterType
DistanceToCentroidMembershipFunction models class membership using a distance metric.
std::vector< ClassLabelType > ClassLabelVectorType
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ImageToImageFilter< InputImageType, OutputImageType > Superclass
Define additional traits for native types such as int or float.
This class provides ListSample interface to ITK Image.
#define itkConceptMacro(name, concept)
AdaptorType::MeasurementVectorType MeasurementVectorType
MembershipFunctionType::CentroidType MembershipFunctionOriginType
itk::Statistics::WeightedCentroidKdTreeGenerator< AdaptorType > TreeGeneratorType
MembershipFunctionType::Pointer MembershipFunctionPointer