ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLabelShapeKeepNObjectsImageFilter.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 itkLabelShapeKeepNObjectsImageFilter_h
19 #define itkLabelShapeKeepNObjectsImageFilter_h
20 
21 #include "itkShapeLabelObject.h"
23 #include "itkShapeLabelMapFilter.h"
26 
27 namespace itk
28 {
50 template< typename TInputImage >
51 class ITK_TEMPLATE_EXPORT LabelShapeKeepNObjectsImageFilter:
52  public ImageToImageFilter< TInputImage, TInputImage >
53 {
54 public:
55  ITK_DISALLOW_COPY_AND_ASSIGN(LabelShapeKeepNObjectsImageFilter);
56 
62 
64  using InputImageType = TInputImage;
65  using OutputImageType = TInputImage;
66  using InputImagePointer = typename InputImageType::Pointer;
67  using InputImageConstPointer = typename InputImageType::ConstPointer;
69  using InputImagePixelType = typename InputImageType::PixelType;
70  using OutputImagePointer = typename OutputImageType::Pointer;
71  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
73  using OutputImagePixelType = typename OutputImageType::PixelType;
74 
76  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
77  static constexpr unsigned int OutputImageDimension = TInputImage::ImageDimension;
78  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
79 
83  using ShapeLabelFilterOutput = Image< typename OutputImageType::PixelType,
84  Self::OutputImageDimension >;
90 
92  itkNewMacro(Self);
93 
97 
98 #ifdef ITK_USE_CONCEPT_CHECKING
99  // Begin concept checking
100  itkConceptMacro( InputEqualityComparableCheck,
102  itkConceptMacro( IntConvertibleToInputCheck,
104  itkConceptMacro( InputOStreamWritableCheck,
106  // End concept checking
107 #endif
108 
113  itkSetMacro(BackgroundValue, OutputImagePixelType);
114  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
116 
120  itkGetConstMacro(NumberOfObjects, SizeValueType);
121  itkSetMacro(NumberOfObjects, SizeValueType);
123 
129  itkGetConstMacro(ReverseOrdering, bool);
130  itkSetMacro(ReverseOrdering, bool);
131  itkBooleanMacro(ReverseOrdering);
133 
138  itkGetConstMacro(Attribute, AttributeType);
139  itkSetMacro(Attribute, AttributeType);
140  void SetAttribute(const std::string & s)
141  {
142  this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
143  }
145 
146 protected:
148  ~LabelShapeKeepNObjectsImageFilter() override = default;
149  void PrintSelf(std::ostream & os, Indent indent) const override;
150 
154  void GenerateInputRequestedRegion() override;
155 
157  void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ) override;
158 
161  void GenerateData() override;
162 
163 private:
168 }; // end of class
169 } // end namespace itk
170 
171 #ifndef ITK_MANUAL_INSTANTIATION
172 #include "itkLabelShapeKeepNObjectsImageFilter.hxx"
173 #endif
174 
175 #endif
convert a labeled image to a label collection image
Light weight base class for most itk classes.
typename LabelObjectType::AttributeType AttributeType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename OutputImageType::RegionType OutputImageRegionType
typename InputImageType::ConstPointer InputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
A Label object to store the common attributes related to the shape of the object. ...
typename InputImageType::RegionType InputImageRegionType
Keep N objects according to their shape attributes.
keep N objects according to their shape attributes
Base class for filters that take an image as input and produce an image as output.
typename OutputImageType::PixelType OutputImagePixelType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
#define itkConceptMacro(name, concept)
The valuator class for the ShapeLabelObject.
typename Superclass::AttributeType AttributeType
Base class for all data objects in ITK.
Templated n-dimensional image class.
Definition: itkImage.h:75
Converts a LabelMap to a labeled image.