ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkBinaryShapeOpeningImageFilter.h
Go to the documentation of this file.
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 __itkBinaryShapeOpeningImageFilter_h
00019 #define __itkBinaryShapeOpeningImageFilter_h
00020 
00021 #include "itkShapeLabelObject.h"
00022 #include "itkBinaryImageToLabelMapFilter.h"
00023 #include "itkShapeLabelMapFilter.h"
00024 #include "itkShapeOpeningLabelMapFilter.h"
00025 #include "itkLabelMapToBinaryImageFilter.h"
00026 
00027 namespace itk
00028 {
00046 template< class TInputImage >
00047 class ITK_EXPORT BinaryShapeOpeningImageFilter:
00048   public ImageToImageFilter< TInputImage, TInputImage >
00049 {
00050 public:
00052   typedef BinaryShapeOpeningImageFilter                  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, TInputImage::ImageDimension);
00071   itkStaticConstMacro(OutputImageDimension, unsigned int, TInputImage::ImageDimension);
00072   itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
00074 
00075   typedef SizeValueType LabelType;
00076 
00077   typedef ShapeLabelObject< LabelType, itkGetStaticConstMacro(ImageDimension) >     LabelObjectType;
00078   typedef LabelMap< LabelObjectType >                                               LabelMapType;
00079   typedef BinaryImageToLabelMapFilter< InputImageType, LabelMapType >               LabelizerType;
00080   typedef Image< typename OutputImageType::PixelType, itkGetStaticConstMacro(OutputImageDimension) >
00081   ShapeLabelFilterOutput;
00082   typedef ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput >  LabelObjectValuatorType;
00083   typedef typename LabelObjectType::AttributeType                      AttributeType;
00084   typedef ShapeOpeningLabelMapFilter< LabelMapType >                   OpeningType;
00085   typedef LabelMapToBinaryImageFilter< LabelMapType, OutputImageType > BinarizerType;
00086 
00088   itkNewMacro(Self);
00089 
00091   itkTypeMacro(BinaryShapeOpeningImageFilter, ImageToImageFilter);
00092 
00099   itkSetMacro(FullyConnected, bool);
00100   itkGetConstReferenceMacro(FullyConnected, bool);
00101   itkBooleanMacro(FullyConnected);
00103 
00104 #ifdef ITK_USE_CONCEPT_CHECKING
00105 
00106   itkConceptMacro( InputEqualityComparableCheck,
00107                    ( Concept::EqualityComparable< InputImagePixelType > ) );
00108   itkConceptMacro( IntConvertibleToInputCheck,
00109                    ( Concept::Convertible< int, InputImagePixelType > ) );
00110   itkConceptMacro( InputOStreamWritableCheck,
00111                    ( Concept::OStreamWritable< InputImagePixelType > ) );
00112 
00114 #endif
00115 
00120   itkSetMacro(BackgroundValue, OutputImagePixelType);
00121   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00123 
00128   itkSetMacro(ForegroundValue, OutputImagePixelType);
00129   itkGetConstMacro(ForegroundValue, OutputImagePixelType);
00131 
00135   itkGetConstMacro(Lambda, double);
00136   itkSetMacro(Lambda, double);
00138 
00145   itkGetConstMacro(ReverseOrdering, bool);
00146   itkSetMacro(ReverseOrdering, bool);
00147   itkBooleanMacro(ReverseOrdering);
00149 
00154   itkGetConstMacro(Attribute, AttributeType);
00155   itkSetMacro(Attribute, AttributeType);
00156   void SetAttribute(const std::string & s)
00157   {
00158     this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
00159   }
00161 
00162 protected:
00163   BinaryShapeOpeningImageFilter();
00164   ~BinaryShapeOpeningImageFilter() {}
00165   void PrintSelf(std::ostream & os, Indent indent) const;
00166 
00169   void GenerateInputRequestedRegion();
00170 
00172   void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
00173 
00176   void GenerateData();
00177 
00178 private:
00179   BinaryShapeOpeningImageFilter(const Self &); //purposely not implemented
00180   void operator=(const Self &);                //purposely not implemented
00181 
00182   bool                 m_FullyConnected;
00183   OutputImagePixelType m_BackgroundValue;
00184   OutputImagePixelType m_ForegroundValue;
00185   double               m_Lambda;
00186   bool                 m_ReverseOrdering;
00187   AttributeType        m_Attribute;
00188 }; // end of class
00189 } // end namespace itk
00190 
00191 #ifndef ITK_MANUAL_INSTANTIATION
00192 #include "itkBinaryShapeOpeningImageFilter.hxx"
00193 #endif
00194 
00195 #endif
00196