Medical Imaging Interaction Toolkit  2018.4.99-936b789b
Medical Imaging Interaction Toolkit
itkSpectra1DImageFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 /*=========================================================================
13  *
14  * Copyright Insight Software Consortium
15  *
16  * Licensed under the Apache License, Version 2.0 (the "License");
17  * you may not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * http://www.apache.org/licenses/LICENSE-2.0.txt
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an "AS IS" BASIS,
24  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  *
28  *=========================================================================*/
29 #ifndef itkSpectra1DImageFilter_h
30 #define itkSpectra1DImageFilter_h
31 
32 #include "itkImageToImageFilter.h"
33 #include "itkDefaultConvertPixelTraits.h"
34 #include "itkImageRegionConstIterator.h"
35 
36 #include "vnl/algo/vnl_fft_base.h"
37 #include "vnl/algo/vnl_fft_1d.h"
38 
39 #include <utility>
40 #include <map>
41 
43 
44 namespace itk
45 {
46 
57 template< typename TInputImage, typename TSupportWindowImage, typename TOutputImage >
59  public ImageToImageFilter< TInputImage,
60  TOutputImage >
61 {
62 public:
63  itkStaticConstMacro( ImageDimension, unsigned int, TInputImage::ImageDimension );
64 
65  typedef TInputImage InputImageType;
66  typedef TSupportWindowImage SupportWindowImageType;
67  typedef TOutputImage OutputImageType;
68 
69  typedef typename DefaultConvertPixelTraits< typename OutputImageType::PixelType >::ComponentType
71 
74  typedef ImageToImageFilter< InputImageType, OutputImageType > Superclass;
77 
78  itkTypeMacro( Spectra1DImageFilter, ImageToImageFilter );
79  itkNewMacro( Self );
80 
83  itkSetInputMacro( SupportWindowImage, SupportWindowImageType );
84  itkGetInputMacro( SupportWindowImage, SupportWindowImageType );
85 
86 protected:
88  virtual ~Spectra1DImageFilter() {};
89 
90  typedef typename OutputImageType::RegionType OutputImageRegionType;
91 
92  virtual void GenerateOutputInformation() ITK_OVERRIDE;
93  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
94  virtual void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
95 
96 private:
97  Spectra1DImageFilter( const Self & ); // purposely not implemented
98  void operator=( const Self & ); // purposely not implemented
99 
100  typedef vcl_complex< ScalarType > ComplexType;
101  typedef vnl_vector< ComplexType > ComplexVectorType;
102  typedef vnl_vector< ScalarType > SpectraVectorType;
103  typedef typename InputImageType::IndexType IndexType;
104  typedef std::pair< IndexType, SpectraVectorType > SpectraLineType;
105  typedef std::deque< SpectraLineType > SpectraLinesContainerType;
106  typedef typename SupportWindowImageType::PixelType SupportWindowType;
107  typedef ImageRegionConstIterator< InputImageType > InputImageIteratorType;
108  typedef vnl_fft_1d< ScalarType > FFT1DType;
109 
111  typedef typename Spectra1DSupportWindowFilterType::FFT1DSizeType FFT1DSizeType;
112 
113  typedef std::map< FFT1DSizeType, SpectraVectorType > LineWindowMapType;
114 
115  struct PerThreadData
116  {
117  ComplexVectorType ComplexVector;
118  SpectraVectorType SpectraVector;
119  typename InputImageType::SizeType LineImageRegionSize;
120  LineWindowMapType LineWindowMap;
121  };
122  typedef std::vector< PerThreadData > PerThreadDataContainerType;
123  PerThreadDataContainerType m_PerThreadDataContainer;
124 
125  SpectraLineType ComputeSpectra( const IndexType & lineIndex, ThreadIdType threadId );
126  void AddLineWindow( FFT1DSizeType length, LineWindowMapType & lineWindowMap );
127 };
128 
129 } // end namespace itk
130 
131 #ifndef ITK_MANUAL_INSTANTIATION
132 #include "itkSpectra1DImageFilter.hxx"
133 #endif
134 
135 #endif // itkSpectra1DImageFilter_h
itkSetInputMacro(SupportWindowImage, SupportWindowImageType)
OutputImageType::RegionType OutputImageRegionType
virtual void GenerateOutputInformation() ITK_OVERRIDE
SmartPointer< const Self > ConstPointer
DefaultConvertPixelTraits< typename OutputImageType::PixelType >::ComponentType ScalarType
Generate an image of local spectra computation support windows.
itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension)
virtual void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) ITK_OVERRIDE
ImageToImageFilter< InputImageType, OutputImageType > Superclass
virtual void BeforeThreadedGenerateData() ITK_OVERRIDE
TSupportWindowImage SupportWindowImageType
itkGetInputMacro(SupportWindowImage, SupportWindowImageType)
Generate an image of local spectra.