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 __itkBinaryReconstructionByErosionImageFilter_h 00019 #define __itkBinaryReconstructionByErosionImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 #include "itkAttributeLabelObject.h" 00023 #include "itkLabelMap.h" 00024 #include "itkBinaryNotImageFilter.h" 00025 #include "itkBinaryImageToLabelMapFilter.h" 00026 #include "itkBinaryReconstructionLabelMapFilter.h" 00027 #include "itkAttributeOpeningLabelMapFilter.h" 00028 #include "itkLabelMapMaskImageFilter.h" 00029 00030 00031 namespace itk { 00032 00054 template<class TInputImage> 00055 class ITK_EXPORT BinaryReconstructionByErosionImageFilter : 00056 public ImageToImageFilter<TInputImage, TInputImage> 00057 { 00058 public: 00060 typedef BinaryReconstructionByErosionImageFilter Self; 00061 typedef ImageToImageFilter<TInputImage, TInputImage> Superclass; 00062 typedef SmartPointer<Self> Pointer; 00063 typedef SmartPointer<const Self> ConstPointer; 00064 00066 typedef TInputImage InputImageType; 00067 typedef TInputImage OutputImageType; 00068 typedef typename InputImageType::Pointer InputImagePointer; 00069 typedef typename InputImageType::ConstPointer InputImageConstPointer; 00070 typedef typename InputImageType::RegionType InputImageRegionType; 00071 typedef typename InputImageType::PixelType InputImagePixelType; 00072 typedef typename OutputImageType::Pointer OutputImagePointer; 00073 typedef typename OutputImageType::ConstPointer OutputImageConstPointer; 00074 typedef typename OutputImageType::RegionType OutputImageRegionType; 00075 typedef typename OutputImageType::PixelType OutputImagePixelType; 00076 00078 itkStaticConstMacro(InputImageDimension, unsigned int, 00079 TInputImage::ImageDimension); 00080 itkStaticConstMacro(OutputImageDimension, unsigned int, 00081 TInputImage::ImageDimension); 00082 itkStaticConstMacro(ImageDimension, unsigned int, 00083 TInputImage::ImageDimension); 00085 00086 typedef BinaryNotImageFilter< InputImageType > NotType; 00087 typedef AttributeLabelObject< SizeValueType, ImageDimension, bool> LabelObjectType; 00088 typedef typename itk::LabelMap< LabelObjectType > LabelMapType; 00089 typedef typename itk::BinaryImageToLabelMapFilter< InputImageType, LabelMapType > LabelizerType; 00090 typedef typename itk::BinaryReconstructionLabelMapFilter< LabelMapType, InputImageType > ReconstructionType; 00091 typedef typename itk::AttributeOpeningLabelMapFilter< LabelMapType > OpeningType; 00092 typedef typename itk::LabelMapMaskImageFilter< LabelMapType, OutputImageType > BinarizerType; 00093 00095 itkNewMacro(Self); 00096 00098 itkTypeMacro(BinaryReconstructionByErosionImageFilter, ImageToImageFilter); 00099 00106 itkSetMacro(FullyConnected, bool); 00107 itkGetConstReferenceMacro(FullyConnected, bool); 00108 itkBooleanMacro(FullyConnected); 00110 00111 #ifdef ITK_USE_CONCEPT_CHECKING 00112 00113 itkConceptMacro(InputEqualityComparableCheck, 00114 (Concept::EqualityComparable<InputImagePixelType>)); 00115 itkConceptMacro(IntConvertibleToInputCheck, 00116 (Concept::Convertible<int, InputImagePixelType>)); 00117 itkConceptMacro(InputOStreamWritableCheck, 00118 (Concept::OStreamWritable<InputImagePixelType>)); 00119 00121 #endif 00122 00127 itkSetMacro(BackgroundValue, OutputImagePixelType); 00128 itkGetConstMacro(BackgroundValue, OutputImagePixelType); 00130 00135 itkSetMacro(ForegroundValue, OutputImagePixelType); 00136 itkGetConstMacro(ForegroundValue, OutputImagePixelType); 00138 00140 void SetMarkerImage(InputImageType *input) 00141 { 00142 // Process object is not const-correct so the const casting is required. 00143 this->SetNthInput( 0, const_cast<InputImageType *>(input) ); 00144 } 00145 00147 InputImageType * GetMarkerImage() 00148 { 00149 return static_cast<InputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(0))); 00150 } 00151 00153 void SetMaskImage(const InputImageType *input) 00154 { 00155 // Process object is not const-correct so the const casting is required. 00156 this->SetNthInput( 1, const_cast<InputImageType *>(input) ); 00157 } 00158 00160 InputImageType * GetMaskImage() 00161 { 00162 return static_cast<InputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1))); 00163 } 00164 00165 00166 protected: 00167 BinaryReconstructionByErosionImageFilter(); 00168 ~BinaryReconstructionByErosionImageFilter() {}; 00169 void PrintSelf(std::ostream& os, Indent indent) const; 00170 00174 void GenerateInputRequestedRegion(); 00175 00177 void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)); 00178 00181 void GenerateData(); 00182 00183 00184 private: 00185 BinaryReconstructionByErosionImageFilter(const Self&); //purposely not implemented 00186 void operator=(const Self&); //purposely not implemented 00187 00188 bool m_FullyConnected; 00189 OutputImagePixelType m_BackgroundValue; 00190 OutputImagePixelType m_ForegroundValue; 00191 }; // end of class 00192 00193 } // end namespace itk 00194 00195 #ifndef ITK_MANUAL_INSTANTIATION 00196 #include "itkBinaryReconstructionByErosionImageFilter.hxx" 00197 #endif 00198 00199 #endif 00200