1 /*=========================================================================
2  *
3  *  Copyright Insight Software 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 #ifndef itkFullToHalfHermitianImageFilter_hxx
19 #define itkFullToHalfHermitianImageFilter_hxx
20 
21 #include "itkFullToHalfHermitianImageFilter.h"
22 
23 #include "itkImageAlgorithm.h"
24 #include "itkProgressReporter.h"
25 
26 namespace itk
27 {
28 
29 template< typename TInputImage >
30 FullToHalfHermitianImageFilter< TInputImage >
FullToHalfHermitianImageFilter()31 ::FullToHalfHermitianImageFilter()
32 {
33   this->SetActualXDimensionIsOdd(false);
34   this->DynamicMultiThreadingOn();
35 }
36 
37 template< typename TInputImage >
38 void
39 FullToHalfHermitianImageFilter< TInputImage >
GenerateOutputInformation()40 ::GenerateOutputInformation()
41 {
42   // Call the superclass' implementation of this method
43   Superclass::GenerateOutputInformation();
44 
45   // Get pointers to the input and output
46   typename InputImageType::ConstPointer inputPtr = this->GetInput();
47   typename OutputImageType::Pointer outputPtr = this->GetOutput();
48 
49   if ( !inputPtr || !outputPtr )
50     {
51     return;
52     }
53 
54   const typename InputImageType::SizeType &   inputSize =
55     inputPtr->GetLargestPossibleRegion().GetSize();
56   const typename InputImageType::IndexType &  inputStartIndex =
57     inputPtr->GetLargestPossibleRegion().GetIndex();
58 
59   typename OutputImageType::SizeType outputSize;
60   typename OutputImageType::IndexType outputStartIndex;
61 
62   for ( unsigned int i = 0; i < OutputImageType::ImageDimension; i++ )
63     {
64     outputSize[i] = inputSize[i];
65     outputStartIndex[i] = inputStartIndex[i];
66     }
67   outputSize[0] = ( inputSize[0] / 2 ) + 1;
68 
69   typename OutputImageType::RegionType outputLargestPossibleRegion;
70   outputLargestPossibleRegion.SetSize( outputSize );
71   outputLargestPossibleRegion.SetIndex( outputStartIndex );
72 
73   outputPtr->SetLargestPossibleRegion( outputLargestPossibleRegion );
74   this->SetActualXDimensionIsOdd( inputSize[0] % 2 != 0 );
75 }
76 
77 template< typename TInputImage >
78 void
79 FullToHalfHermitianImageFilter< TInputImage >
GenerateInputRequestedRegion()80 ::GenerateInputRequestedRegion()
81 {
82   Superclass::GenerateInputRequestedRegion();
83 
84   // Get pointers to the input and output
85   typename InputImageType::Pointer inputPtr  =
86     const_cast< InputImageType * >( this->GetInput() );
87   if ( inputPtr )
88     {
89     inputPtr->SetRequestedRegionToLargestPossibleRegion();
90     }
91 }
92 
93 template< typename TInputImage >
94 void
95 FullToHalfHermitianImageFilter< TInputImage >
DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread)96 ::DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread)
97 {
98   typename InputImageType::ConstPointer inputPtr = this->GetInput();
99   typename OutputImageType::Pointer outputPtr = this->GetOutput();
100 
101   if ( !inputPtr || !outputPtr )
102     {
103     return;
104     }
105 
106   // Copy the non-reflected region.
107   ImageAlgorithm::Copy( inputPtr.GetPointer(), outputPtr.GetPointer(),
108                         outputRegionForThread, outputRegionForThread );
109 }
110 
111 } // end namespace itk
112 
113 #endif // itkFullToHalfHermitianImageFilter_hxx
114