Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
itkExtractDwiChannelFilter.txx
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __itkExtractDwiChannelFilter_txx
18 #define __itkExtractDwiChannelFilter_txx
19 
20 #include <time.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 
24 #define _USE_MATH_DEFINES
25 #include <math.h>
26 
27 #include "itkImageRegionConstIterator.h"
28 #include "itkImageRegionConstIteratorWithIndex.h"
29 #include "itkImageRegionIterator.h"
30 
31 namespace itk {
32 
33 
34 template< class TInPixelType >
35 ExtractDwiChannelFilter< TInPixelType>::ExtractDwiChannelFilter()
36 {
37  this->SetNumberOfRequiredInputs( 1 );
38 }
39 
40 template< class TInPixelType >
41 void ExtractDwiChannelFilter< TInPixelType>::BeforeThreadedGenerateData()
42 {
43  typename InputImageType::Pointer inputImagePointer = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) );
44  if ( inputImagePointer->GetVectorLength()<=m_ChannelIndex )
45  itkExceptionMacro("Index out of bounds!");
46 }
47 
48 template< class TInPixelType >
49 void ExtractDwiChannelFilter< TInPixelType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType )
50 {
51  typename OutputImageType::Pointer outputImage = static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
52 
53  ImageRegionIterator< OutputImageType > oit(outputImage, outputRegionForThread);
54  oit.GoToBegin();
55 
56  typedef ImageRegionConstIterator< InputImageType > InputIteratorType;
57  typename InputImageType::Pointer inputImagePointer = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) );
58 
59  InputIteratorType git( inputImagePointer, outputRegionForThread );
60  git.GoToBegin();
61  while( !git.IsAtEnd() )
62  {
63  oit.Set( git.Get()[m_ChannelIndex] );
64  ++oit;
65  ++git;
66  }
67 
68  std::cout << "One Thread finished calculation" << std::endl;
69 }
70 
71 }
72 
73 #endif // __itkExtractDwiChannelFilter_txx