ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkLabelMapContourOverlayImageFilter.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 __itkLabelMapContourOverlayImageFilter_h
00019 #define __itkLabelMapContourOverlayImageFilter_h
00020 
00021 #include "itkLabelMapFilter.h"
00022 #include "itkBarrier.h"
00023 #include "itkLabelOverlayFunctor.h"
00024 #include "itkRGBPixel.h"
00025 
00026 namespace itk {
00027 
00056 template<class TLabelMap, class TFeatureImage, class TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
00057 class ITK_EXPORT LabelMapContourOverlayImageFilter :
00058     public LabelMapFilter<TLabelMap, TOutputImage>
00059 {
00060 public:
00062   typedef LabelMapContourOverlayImageFilter         Self;
00063   typedef LabelMapFilter<TLabelMap, TOutputImage>   Superclass;
00064   typedef SmartPointer<Self>                        Pointer;
00065   typedef SmartPointer<const Self>                  ConstPointer;
00066 
00068   typedef TLabelMap                                LabelMapType;
00069   typedef typename LabelMapType::Pointer           LabelMapPointer;
00070   typedef typename LabelMapType::ConstPointer      LabelMapConstPointer;
00071   typedef typename LabelMapType::RegionType        LabelMapRegionType;
00072   typedef typename LabelMapType::PixelType         LabelMapPixelType;
00073   typedef typename LabelMapType::LabelObjectType   LabelObjectType;
00074   typedef typename LabelObjectType::LabelType      LabelType;
00075 
00076   typedef TFeatureImage                             FeatureImageType;
00077   typedef typename FeatureImageType::Pointer        FeatureImagePointer;
00078   typedef typename FeatureImageType::ConstPointer   FeatureImageConstPointer;
00079   typedef typename FeatureImageType::RegionType     FeatureImageRegionType;
00080   typedef typename FeatureImageType::PixelType      FeatureImagePixelType;
00081 
00082   typedef TOutputImage                             OutputImageType;
00083   typedef typename OutputImageType::Pointer        OutputImagePointer;
00084   typedef typename OutputImageType::ConstPointer   OutputImageConstPointer;
00085   typedef typename OutputImageType::RegionType     OutputImageRegionType;
00086   typedef typename OutputImageType::PixelType      OutputImagePixelType;
00087   typedef typename OutputImageType::IndexType      IndexType;
00088   typedef typename OutputImageType::SizeType       SizeType;
00089   typedef typename OutputImageType::RegionType     RegionType;
00090 
00091   typedef typename Functor::LabelOverlayFunctor<FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType> FunctorType;
00092 
00094   itkStaticConstMacro(LabelMapDimension, unsigned int,
00095                       TLabelMap::ImageDimension);
00096   itkStaticConstMacro(OutputImageDimension, unsigned int,
00097                       TOutputImage::ImageDimension);
00098   itkStaticConstMacro(ImageDimension, unsigned int,
00099                       TOutputImage::ImageDimension);
00101 
00102   enum
00103     {
00104     PLAIN = 0,
00105     CONTOUR = 1,
00106     SLICE_CONTOUR=2
00107     };
00108 
00109   enum
00110     {
00111     HIGH_LABEL_ON_TOP = 0,
00112     LOW_LABEL_ON_TOP = 1
00113     };
00114 
00116   itkNewMacro(Self);
00117 
00119   itkTypeMacro(LabelMapContourOverlayImageFilter,
00120                ImageToImageFilter);
00121 
00123   void SetFeatureImage(TFeatureImage *input)
00124     {
00125     // Process object is not const-correct so the const casting is required.
00126     this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
00127     }
00128 
00130   FeatureImageType * GetFeatureImage()
00131     {
00132     return static_cast<FeatureImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
00133     }
00134 
00136   void SetInput1(TLabelMap *input)
00137     {
00138     this->SetInput( input );
00139     }
00140 
00142   void SetInput2(TFeatureImage *input)
00143     {
00144     this->SetFeatureImage( input );
00145     }
00146 
00150   itkSetMacro( Opacity, double );
00151   itkGetConstReferenceMacro( Opacity, double );
00153 
00156   itkSetMacro( Type, int );
00157   itkGetConstReferenceMacro( Type, int );
00159 
00162   itkSetMacro( Priority, int );
00163   itkGetConstReferenceMacro( Priority, int );
00165 
00168   itkSetMacro( DilationRadius, SizeType );
00169   itkGetConstReferenceMacro( DilationRadius, SizeType );
00171 
00174   itkSetMacro( ContourThickness, SizeType );
00175   itkGetConstReferenceMacro( ContourThickness, SizeType );
00177 
00180   itkSetMacro( SliceDimension, int );
00181   itkGetConstReferenceMacro( SliceDimension, int );
00183 
00184 protected:
00185   LabelMapContourOverlayImageFilter();
00186   ~LabelMapContourOverlayImageFilter() {};
00187 
00191   void GenerateInputRequestedRegion();
00192 
00194   void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00195 
00196   virtual void BeforeThreadedGenerateData();
00197 
00198   virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId );
00199 
00200   virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject );
00201 
00202   void PrintSelf(std::ostream& os, Indent indent) const;
00203 
00204   virtual LabelMapType * GetLabelMap()
00205     {
00206     return m_TempImage;
00207     }
00208 
00209 private:
00210   LabelMapContourOverlayImageFilter(const Self&); //purposely not implemented
00211   void operator=(const Self&); //purposely not implemented
00212 
00213   double                    m_Opacity;
00214   typename Barrier::Pointer m_Barrier;
00215   int                       m_Type;
00216   int                       m_Priority;
00217   SizeType                  m_ContourThickness;
00218   SizeType                  m_DilationRadius;
00219   int                       m_SliceDimension;
00220 
00221   LabelMapPointer           m_TempImage;
00222 
00223 }; // end of class
00224 
00225 } // end namespace itk
00226 
00227 #ifndef ITK_MANUAL_INSTANTIATION
00228 #include "itkLabelMapContourOverlayImageFilter.hxx"
00229 #endif
00230 
00231 #endif
00232