ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkComposeRGBImageFilter.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 __itkComposeRGBImageFilter_h
00019 #define __itkComposeRGBImageFilter_h
00020 
00021 #include "itkTernaryFunctorImageFilter.h"
00022 #include "itkRGBPixel.h"
00023 
00024 namespace itk
00025 {
00026 namespace Functor
00027 {
00028 template< class TInput >
00029 class ComposeRGB
00030 {
00031 public:
00032   typedef RGBPixel< TInput > OutputType;
00033   ComposeRGB() {}
00034   ~ComposeRGB() {}
00035   bool operator!=(const ComposeRGB &) const
00036   {
00037     return false;
00038   }
00039 
00040   bool operator==(const ComposeRGB & other) const
00041   {
00042     return !( *this != other );
00043   }
00044 
00045   inline OutputType operator()(const TInput & R,
00046                                const TInput & G,
00047                                const TInput & B) const
00048   {
00049     OutputType rgbPixel;
00050 
00051     rgbPixel.Set(R, G, B);
00052     return rgbPixel;
00053   }
00054 };
00055 }
00056 
00069 template< typename TInputImage,
00070           typename TOutputImage =
00071             Image< RGBPixel< typename TInputImage::PixelType >,
00072                    ::itk::GetImageDimension< TInputImage >::ImageDimension > >
00073 class ITK_EXPORT ComposeRGBImageFilter:
00074   public
00075   TernaryFunctorImageFilter< TInputImage, TInputImage,
00076                              TInputImage, TOutputImage,
00077                              Functor::ComposeRGB< typename TInputImage::PixelType >   >
00078 {
00079 public:
00081   typedef ComposeRGBImageFilter           Self;
00082   typedef TernaryFunctorImageFilter<
00083     TInputImage, TInputImage,
00084     TInputImage, TOutputImage,
00085     Functor::ComposeRGB<
00086       typename TInputImage::PixelType > > Superclass;
00087 
00088   typedef SmartPointer< Self >       Pointer;
00089   typedef SmartPointer< const Self > ConstPointer;
00090 
00091   typedef typename Superclass::OutputImageType OutputImageType;
00092 
00094   itkNewMacro(Self);
00095 
00097   itkTypeMacro(ComposeRGBImageFilter,
00098                TernaryFunctorImageFilter);
00099 protected:
00100   ComposeRGBImageFilter() {}
00101   virtual ~ComposeRGBImageFilter() {}
00102 private:
00103   ComposeRGBImageFilter(const Self &); //purposely not implemented
00104   void operator=(const Self &);        //purposely not implemented
00105 };
00106 } // end namespace itk
00108 
00109 #endif
00110