ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkAreaOpeningImageFilter.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 __itkAreaOpeningImageFilter_h
00019 #define __itkAreaOpeningImageFilter_h
00020 
00021 #include "itkAttributeMorphologyBaseImageFilter.h"
00022 
00023 namespace itk
00024 {
00059 template< class TInputImage, class TOutputImage, class TAttribute = typename TInputImage::SpacingType::ValueType >
00060 class ITK_EXPORT AreaOpeningImageFilter:
00061   public AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
00062                                              std::greater< typename TInputImage::PixelType > >
00063 
00064 {
00065 public:
00066   typedef AreaOpeningImageFilter Self;
00067   typedef AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
00068                                               std::greater< typename TInputImage::PixelType > >
00069   Superclass;
00070 
00071   typedef SmartPointer< Self >       Pointer;
00072   typedef SmartPointer< const Self > ConstPointer;
00073 
00078   typedef typename TOutputImage::PixelType         OutputPixelType;
00079   typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
00080   typedef typename TInputImage::PixelType          InputPixelType;
00081   typedef typename TInputImage::InternalPixelType  InputInternalPixelType;
00082   typedef typename TInputImage::IndexType          IndexType;
00083   typedef typename TInputImage::OffsetType         OffsetType;
00084   typedef typename TInputImage::SizeType           SizeType;
00085   typedef TAttribute                               AttributeType;
00086 
00087   itkStaticConstMacro(ImageDimension, unsigned int,
00088                       TOutputImage::ImageDimension);
00089 
00091   itkNewMacro(Self);
00092 
00094   itkTypeMacro(AreaOpeningImageFilter,
00095                AttributeMorphologyBaseImageFilter);
00096 
00100   itkSetMacro(UseImageSpacing, bool);
00101   itkGetConstReferenceMacro(UseImageSpacing, bool);
00102   itkBooleanMacro(UseImageSpacing);
00103 protected:
00104   AreaOpeningImageFilter()
00105   {
00106     m_UseImageSpacing = true;
00107   }
00109 
00110   virtual ~AreaOpeningImageFilter() {}
00111 
00112   void GenerateData()
00113   {
00114     this->m_AttributeValuePerPixel = 1;
00115     if ( m_UseImageSpacing )
00116       {
00117       // compute pixel size
00118       double psize = 1.0;
00119       for ( unsigned i = 0; i < ImageDimension; i++ )
00120         {
00121         psize *= this->GetInput()->GetSpacing()[i];
00122         }
00123       this->m_AttributeValuePerPixel = static_cast< AttributeType >( psize );
00124       // std::cout << "m_AttributeValuePerPixel: " <<
00125       // this->m_AttributeValuePerPixel << std::endl;
00126       // and call superclass implementation of GenerateData()
00127       }
00128     Superclass::GenerateData();
00129   }
00130 
00131   void PrintSelf(std::ostream & os, Indent indent) const
00132   {
00133     Superclass::PrintSelf(os, indent);
00134     os << indent << "UseImageSpacing: "  << m_UseImageSpacing << std::endl;
00135   }
00136 
00137 private:
00138 
00139   AreaOpeningImageFilter(const Self &); //purposely not implemented
00140   void operator=(const Self &);         //purposely not implemented
00141 
00142   bool m_UseImageSpacing;
00143 };
00144 } // namespace itk
00145 #endif
00146