ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkBinaryShapeKeepNObjectsImageFilter_h 00019 #define __itkBinaryShapeKeepNObjectsImageFilter_h 00020 00021 #include "itkShapeLabelObject.h" 00022 #include "itkBinaryImageToLabelMapFilter.h" 00023 #include "itkShapeLabelMapFilter.h" 00024 #include "itkShapeKeepNObjectsLabelMapFilter.h" 00025 #include "itkLabelMapToBinaryImageFilter.h" 00026 00027 namespace itk 00028 { 00046 template< class TInputImage > 00047 class ITK_EXPORT BinaryShapeKeepNObjectsImageFilter: 00048 public ImageToImageFilter< TInputImage, TInputImage > 00049 { 00050 public: 00052 typedef BinaryShapeKeepNObjectsImageFilter Self; 00053 typedef ImageToImageFilter< TInputImage, TInputImage > Superclass; 00054 typedef SmartPointer< Self > Pointer; 00055 typedef SmartPointer< const Self > ConstPointer; 00056 00058 typedef TInputImage InputImageType; 00059 typedef TInputImage OutputImageType; 00060 typedef typename InputImageType::Pointer InputImagePointer; 00061 typedef typename InputImageType::ConstPointer InputImageConstPointer; 00062 typedef typename InputImageType::RegionType InputImageRegionType; 00063 typedef typename InputImageType::PixelType InputImagePixelType; 00064 typedef typename OutputImageType::Pointer OutputImagePointer; 00065 typedef typename OutputImageType::ConstPointer OutputImageConstPointer; 00066 typedef typename OutputImageType::RegionType OutputImageRegionType; 00067 typedef typename OutputImageType::PixelType OutputImagePixelType; 00068 00070 itkStaticConstMacro(InputImageDimension, unsigned int, 00071 TInputImage::ImageDimension); 00072 itkStaticConstMacro(OutputImageDimension, unsigned int, 00073 TInputImage::ImageDimension); 00074 itkStaticConstMacro(ImageDimension, unsigned int, 00075 TInputImage::ImageDimension); 00077 00078 typedef SizeValueType LabelType; 00079 00080 typedef ShapeLabelObject< LabelType, itkGetStaticConstMacro(ImageDimension) > LabelObjectType; 00081 typedef LabelMap< LabelObjectType > LabelMapType; 00082 typedef BinaryImageToLabelMapFilter< InputImageType, LabelMapType > LabelizerType; 00083 typedef Image< typename OutputImageType::PixelType, itkGetStaticConstMacro(OutputImageDimension) > 00084 ShapeLabelFilterOutput; 00085 typedef ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput > LabelObjectValuatorType; 00086 typedef typename LabelObjectType::AttributeType AttributeType; 00087 typedef ShapeKeepNObjectsLabelMapFilter< LabelMapType > KeepNObjectsType; 00088 typedef LabelMapToBinaryImageFilter< LabelMapType, OutputImageType > BinarizerType; 00089 00091 itkNewMacro(Self); 00092 00094 itkTypeMacro(BinaryShapeKeepNObjectsImageFilter, 00095 ImageToImageFilter); 00096 00103 itkSetMacro(FullyConnected, bool); 00104 itkGetConstReferenceMacro(FullyConnected, bool); 00105 itkBooleanMacro(FullyConnected); 00107 00108 #ifdef ITK_USE_CONCEPT_CHECKING 00109 00110 itkConceptMacro( InputEqualityComparableCheck, 00111 ( Concept::EqualityComparable< InputImagePixelType > ) ); 00112 itkConceptMacro( IntConvertibleToInputCheck, 00113 ( Concept::Convertible< int, InputImagePixelType > ) ); 00114 itkConceptMacro( InputOStreamWritableCheck, 00115 ( Concept::OStreamWritable< InputImagePixelType > ) ); 00116 00118 #endif 00119 00124 itkSetMacro(BackgroundValue, OutputImagePixelType); 00125 itkGetConstMacro(BackgroundValue, OutputImagePixelType); 00127 00132 itkSetMacro(ForegroundValue, OutputImagePixelType); 00133 itkGetConstMacro(ForegroundValue, OutputImagePixelType); 00135 00139 itkGetConstMacro(NumberOfObjects, SizeValueType); 00140 itkSetMacro(NumberOfObjects, SizeValueType); 00142 00148 itkGetConstMacro(ReverseOrdering, bool); 00149 itkSetMacro(ReverseOrdering, bool); 00150 itkBooleanMacro(ReverseOrdering); 00152 00157 itkGetConstMacro(Attribute, AttributeType); 00158 itkSetMacro(Attribute, AttributeType); 00159 void SetAttribute(const std::string & s) 00160 { 00161 this->SetAttribute( LabelObjectType::GetAttributeFromName(s) ); 00162 } 00164 00165 protected: 00166 BinaryShapeKeepNObjectsImageFilter(); 00167 ~BinaryShapeKeepNObjectsImageFilter() {} 00168 void PrintSelf(std::ostream & os, Indent indent) const; 00169 00173 void GenerateInputRequestedRegion(); 00174 00176 void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ); 00177 00180 void GenerateData(); 00181 00182 private: 00183 BinaryShapeKeepNObjectsImageFilter(const Self &); //purposely not implemented 00184 void operator=(const Self &); //purposely not implemented 00185 00186 bool m_FullyConnected; 00187 OutputImagePixelType m_BackgroundValue; 00188 OutputImagePixelType m_ForegroundValue; 00189 SizeValueType m_NumberOfObjects; 00190 bool m_ReverseOrdering; 00191 AttributeType m_Attribute; 00192 }; // end of class 00193 } // end namespace itk 00194 00195 #ifndef ITK_MANUAL_INSTANTIATION 00196 #include "itkBinaryShapeKeepNObjectsImageFilter.hxx" 00197 #endif 00198 00199 #endif 00200