]> Creatis software - clitk.git/blob - common/rtkImagXLookupTableImageFilter.h
Add define to avoid vtk warning on mac
[clitk.git] / common / rtkImagXLookupTableImageFilter.h
1 /*=========================================================================
2  *
3  *  Copyright RTK Consortium
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *         http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *=========================================================================*/
18
19 #ifndef __rtkImagXLookupTableImageFilter_h
20 #define __rtkImagXLookupTableImageFilter_h
21
22 #include "rtkLookupTableImageFilter.h"
23 #include <itkNumericTraits.h>
24
25 namespace rtk
26 {
27
28 /** \class ImagXLookupTableImageFilter
29  * \brief Lookup table for ImagX data.
30  *
31  * The lookup table converts the raw values measured by the panel to the
32  * logarithm of the value divided by the maximum numerical value. This could
33  * be improved with a calibration of the air value.
34  *
35  * \author Simon Rit
36  *
37  * \ingroup ImageToImageFilter
38  */
39 template <class TInputImage, class TOutputImage>
40 class ITK_EXPORT ImagXLookupTableImageFilter : public LookupTableImageFilter<TInputImage, TOutputImage>
41 {
42
43 public:
44   /** Standard class typedefs. */
45   typedef ImagXLookupTableImageFilter                       Self;
46   typedef LookupTableImageFilter<TInputImage, TOutputImage> Superclass;
47   typedef itk::SmartPointer<Self>                           Pointer;
48   typedef itk::SmartPointer<const Self>                     ConstPointer;
49
50   typedef typename TInputImage::PixelType                   InputImagePixelType;
51   typedef typename TOutputImage::PixelType                  OutputImagePixelType;
52   typedef typename Superclass::FunctorType::LookupTableType LookupTableType;
53
54   /** Method for creation through the object factory. */
55   itkNewMacro(Self);
56
57   /** Runtime information support. */
58   itkTypeMacro(ImagXLookupTableImageFilter, LookupTableImageFilter);
59 protected:
60   ImagXLookupTableImageFilter();
61   virtual ~ImagXLookupTableImageFilter() {
62   }
63
64 private:
65   ImagXLookupTableImageFilter(const Self&); //purposely not implemented
66   void operator=(const Self&);              //purposely not implemented
67
68 };
69
70 } // end namespace rtk
71
72 template <class TInputImage, class TOutputImage>
73 rtk::ImagXLookupTableImageFilter<TInputImage, TOutputImage>::ImagXLookupTableImageFilter()
74 {
75   // Create the lut
76   typename LookupTableType::Pointer lut = LookupTableType::New();
77   typename LookupTableType::SizeType size;
78   size[0] = itk::NumericTraits<InputImagePixelType>::max()-itk::NumericTraits<InputImagePixelType>::min()+1;
79   lut->SetRegions( size );
80   lut->Allocate();
81
82   OutputImagePixelType logRef = log(OutputImagePixelType(size[0]) );
83
84   // Iterate and set lut
85   itk::ImageRegionIteratorWithIndex<LookupTableType> it( lut, lut->GetBufferedRegion() );
86   it.GoToBegin();
87   while( !it.IsAtEnd() )
88     {
89     it.Set( logRef - log(it.GetIndex()[0]+1.) );
90     ++it;
91     }
92
93   // Set the lut to member and functor
94   this->SetLookupTable(lut);
95 }
96
97 #endif