1 /*=========================================================================
3 * Copyright RTK Consortium
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
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
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.
17 *=========================================================================*/
19 #ifndef __rtkImagXLookupTableImageFilter_h
20 #define __rtkImagXLookupTableImageFilter_h
22 #include "rtkLookupTableImageFilter.h"
23 #include <itkNumericTraits.h>
28 /** \class ImagXLookupTableImageFilter
29 * \brief Lookup table for ImagX data.
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.
37 * \ingroup ImageToImageFilter
39 template <class TInputImage, class TOutputImage>
40 class ITK_EXPORT ImagXLookupTableImageFilter : public LookupTableImageFilter<TInputImage, TOutputImage>
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;
50 typedef typename TInputImage::PixelType InputImagePixelType;
51 typedef typename TOutputImage::PixelType OutputImagePixelType;
52 typedef typename Superclass::FunctorType::LookupTableType LookupTableType;
54 /** Method for creation through the object factory. */
57 /** Runtime information support. */
58 itkTypeMacro(ImagXLookupTableImageFilter, LookupTableImageFilter);
60 ImagXLookupTableImageFilter();
61 virtual ~ImagXLookupTableImageFilter() {
65 ImagXLookupTableImageFilter(const Self&); //purposely not implemented
66 void operator=(const Self&); //purposely not implemented
70 } // end namespace rtk
72 template <class TInputImage, class TOutputImage>
73 rtk::ImagXLookupTableImageFilter<TInputImage, TOutputImage>::ImagXLookupTableImageFilter()
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 );
82 OutputImagePixelType logRef = log(OutputImagePixelType(size[0]) );
84 // Iterate and set lut
85 itk::ImageRegionIteratorWithIndex<LookupTableType> it( lut, lut->GetBufferedRegion() );
87 while( !it.IsAtEnd() )
89 it.Set( logRef - log(it.GetIndex()[0]+1.) );
93 // Set the lut to member and functor
94 this->SetLookupTable(lut);