Shapeworks Studio  2.1
Shape analysis software suite
itkPSMTrimLabelMapImageFilter.h
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 __itkPSMTrimLabelMapImageFilter_h
19 #define __itkPSMTrimLabelMapImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 
23 namespace itk
24 {
60 template< class TImage>
61 class ITK_EXPORT PSMTrimLabelMapImageFilter:
62  public ImageToImageFilter<TImage, TImage>
63 {
64 public:
67  typedef ImageToImageFilter< TImage, TImage > Superclass;
68  typedef SmartPointer< Self > Pointer;
69  typedef SmartPointer< const Self > ConstPointer;
70 
72  typedef TImage ImageType;
73  typedef typename ImageType::PixelType PixelType;
74  typedef typename ImageType::PointType PointType;
75  typedef typename ImageType::RegionType RegionType;
76  typedef typename RegionType::SizeType SizeType;
77  typedef typename RegionType::IndexType IndexType;
78 
80  itkNewMacro(Self);
81 
83  itkTypeMacro(PSMTrimLabelMapImageFilter, ImageToImageFilter);
84 
86  itkStaticConstMacro(Dimension, unsigned int, TImage::ImageDimension);
87 
89  void GenerateData();
90 
95  itkSetMacro(ForegroundValue,PixelType);
96  itkGetMacro(ForegroundValue,PixelType);
97 
101  itkSetMacro(BackgroundValue,PixelType);
102  itkGetMacro(BackgroundValue,PixelType);
103 
104 
107  const RegionType &GetBoundingBox() const
108  {
109  return m_BoundingBox;
110  }
111 
112 protected:
115  void PrintSelf(std::ostream & os, Indent indent) const;
116 
120  void IsolateLargestComponent(ImageType *) const;
121 
123  void FillHoles(ImageType *) const;
124 
127  void Center(ImageType *) const;
128 
132  void Crop(ImageType *);
133 
138  virtual void GenerateOutputInformation();
139 
144  virtual void GenerateInputRequestedRegion();
145 
146 
147 private:
148  PSMTrimLabelMapImageFilter(const Self &); //purposely not implemented
149  void operator=(const Self &); //purposely not implemented
150 
151  RegionType m_BoundingBox;
152  PixelType m_ForegroundValue;
153  PixelType m_BackgroundValue;
154 };
155 } // end namespace itk
156 
157 #ifndef ITK_MANUAL_INSTANTIATION
158 #include "itkPSMTrimLabelMapImageFilter.hxx"
159 #endif
160 
161 #endif
Process an input segmentation to produce an automatically cropped version with holes filled and cente...