ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLabelMapOverlayImageFilter.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 __itkLabelMapOverlayImageFilter_h
00019 #define __itkLabelMapOverlayImageFilter_h
00020 
00021 #include "itkLabelMapFilter.h"
00022 #include "itkBarrier.h"
00023 #include "itkLabelOverlayFunctor.h"
00024 #include "itkRGBPixel.h"
00025 
00026 namespace itk {
00027 
00051 template<class TLabelMap, class TFeatureImage, class TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
00052 class ITK_EXPORT LabelMapOverlayImageFilter :
00053     public LabelMapFilter<TLabelMap, TOutputImage>
00054 {
00055 public:
00057   typedef LabelMapOverlayImageFilter                Self;
00058   typedef LabelMapFilter<TLabelMap, TOutputImage>   Superclass;
00059   typedef SmartPointer<Self>                        Pointer;
00060   typedef SmartPointer<const Self>                  ConstPointer;
00061 
00063   typedef TLabelMap                                LabelMapType;
00064   typedef typename LabelMapType::Pointer           LabelMapPointer;
00065   typedef typename LabelMapType::ConstPointer      LabelMapConstPointer;
00066   typedef typename LabelMapType::RegionType        LabelMapRegionType;
00067   typedef typename LabelMapType::PixelType         LabelMapPixelType;
00068   typedef typename LabelMapType::LabelObjectType   LabelObjectType;
00069   typedef typename LabelObjectType::LabelType      LabelType;
00070   typedef typename LabelObjectType::LengthType     LengthType;
00071 
00072   typedef TFeatureImage                             FeatureImageType;
00073   typedef typename FeatureImageType::Pointer        FeatureImagePointer;
00074   typedef typename FeatureImageType::ConstPointer   FeatureImageConstPointer;
00075   typedef typename FeatureImageType::RegionType     FeatureImageRegionType;
00076   typedef typename FeatureImageType::PixelType      FeatureImagePixelType;
00077 
00078   typedef TOutputImage                             OutputImageType;
00079   typedef typename OutputImageType::Pointer        OutputImagePointer;
00080   typedef typename OutputImageType::ConstPointer   OutputImageConstPointer;
00081   typedef typename OutputImageType::RegionType     OutputImageRegionType;
00082   typedef typename OutputImageType::PixelType      OutputImagePixelType;
00083   typedef typename OutputImageType::IndexType      IndexType;
00084   typedef typename OutputImageType::SizeType       SizeType;
00085   typedef typename OutputImageType::RegionType     RegionType;
00086 
00087   typedef typename Functor::LabelOverlayFunctor<FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType> FunctorType;
00088 
00090   itkStaticConstMacro(InputImageDimension, unsigned int,
00091                       TLabelMap::ImageDimension);
00092   itkStaticConstMacro(OutputImageDimension, unsigned int,
00093                       TOutputImage::ImageDimension);
00094   itkStaticConstMacro(ImageDimension, unsigned int,
00095                       TOutputImage::ImageDimension);
00097 
00099   itkNewMacro(Self);
00100 
00102   itkTypeMacro(LabelMapOverlayImageFilter,
00103                ImageToImageFilter);
00104 
00106   void SetFeatureImage(const TFeatureImage *input)
00107     {
00108     // Process object is not const-correct so the const casting is required.
00109     this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
00110     }
00111 
00113   const FeatureImageType * GetFeatureImage()
00114     {
00115     return static_cast<FeatureImageType*>((this->ProcessObject::GetInput(1)));
00116     }
00117 
00119   void SetInput1(const TLabelMap *input)
00120     {
00121     this->SetInput( input );
00122     }
00123 
00125   void SetInput2(const TFeatureImage *input)
00126     {
00127     this->SetFeatureImage( input );
00128     }
00129 
00133   itkSetMacro( Opacity, double );
00134   itkGetConstReferenceMacro( Opacity, double );
00136 
00137 protected:
00138   LabelMapOverlayImageFilter();
00139   ~LabelMapOverlayImageFilter() {};
00140 
00144   void GenerateInputRequestedRegion();
00145 
00147   void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00148 
00149   virtual void BeforeThreadedGenerateData();
00150 
00151   virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId );
00152 
00153   virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject );
00154 
00155   virtual void GenerateOutputInformation();
00156 
00157   void PrintSelf(std::ostream& os, Indent indent) const;
00158 
00159 
00160 private:
00161   LabelMapOverlayImageFilter(const Self&); //purposely not implemented
00162   void operator=(const Self&); //purposely not implemented
00163 
00164   double                    m_Opacity;
00165   typename Barrier::Pointer m_Barrier;
00166 
00167 }; // end of class
00168 
00169 } // end namespace itk
00170 
00171 #ifndef ITK_MANUAL_INSTANTIATION
00172 #include "itkLabelMapOverlayImageFilter.hxx"
00173 #endif
00174 
00175 #endif
00176