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