]> Creatis software - clitk.git/blob - common/rtkImagXRawToAttenuationImageFilter.txx
Add define to avoid vtk warning on mac
[clitk.git] / common / rtkImagXRawToAttenuationImageFilter.txx
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 __rtkImagXRawToAttenuationImageFilter_txx
20 #define __rtkImagXRawToAttenuationImageFilter_txx
21
22 #include <itkImageFileWriter.h>
23
24 namespace rtk
25 {
26
27 template<class TInputImage, class TOutputImage>
28 void
29 ImagXRawToAttenuationImageFilter<TInputImage, TOutputImage>
30 ::GenerateInputRequestedRegion()
31 {
32   typename Superclass::InputImagePointer inputPtr =
33     const_cast< TInputImage * >( this->GetInput() );
34   if ( !inputPtr )
35     return;
36
37   m_CropFilter->SetInput(inputPtr); //SR: this is most likely useless
38   m_LookupTableFilter->GetOutput()->SetRequestedRegion(this->GetOutput()->GetRequestedRegion() );
39   m_LookupTableFilter->GetOutput()->PropagateRequestedRegion();
40 }
41
42 template <class TInputImage, class TOutputImage>
43 ImagXRawToAttenuationImageFilter<TInputImage, TOutputImage>
44 ::ImagXRawToAttenuationImageFilter()
45 {
46   m_CropFilter = CropFilterType::New();
47   m_ScatterFilter = ScatterFilterType::New();
48   m_LookupTableFilter = LookupTableFilterType::New();
49
50   //Permanent internal connections
51   m_ScatterFilter->SetInput( m_CropFilter->GetOutput() );
52   m_LookupTableFilter->SetInput( m_ScatterFilter->GetOutput() );
53
54   //Default filter parameters
55   typename CropFilterType::SizeType border = m_CropFilter->GetLowerBoundaryCropSize();
56   border[0] = 4;
57   border[1] = 4;
58   m_CropFilter->SetBoundaryCropSize(border);
59 }
60
61 template<class TInputImage, class TOutputImage>
62 void
63 ImagXRawToAttenuationImageFilter<TInputImage, TOutputImage>
64 ::GenerateOutputInformation()
65 {
66   m_CropFilter->SetInput(this->GetInput() );
67   m_LookupTableFilter->UpdateOutputInformation();
68   this->GetOutput()->SetOrigin( m_LookupTableFilter->GetOutput()->GetOrigin() );
69   this->GetOutput()->SetSpacing( m_LookupTableFilter->GetOutput()->GetSpacing() );
70   this->GetOutput()->SetDirection( m_LookupTableFilter->GetOutput()->GetDirection() );
71   this->GetOutput()->SetLargestPossibleRegion( m_LookupTableFilter->GetOutput()->GetLargestPossibleRegion() );
72 }
73
74 template<class TInputImage, class TOutputImage>
75 void
76 ImagXRawToAttenuationImageFilter<TInputImage, TOutputImage>
77 ::GenerateData()
78 {
79   m_CropFilter->SetInput(this->GetInput() );
80   m_LookupTableFilter->Update();
81   this->GraftOutput( m_LookupTableFilter->GetOutput() );
82 }
83
84 } // end namespace rtk
85 #endif