1 /*===================================================================
3 The Medical Imaging Interaction Toolkit (MITK)
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 See LICENSE.txt or http://www.mitk.org for details.
15 ===================================================================*/
17 #ifndef __itkExtractDwiChannelFilter_txx
18 #define __itkExtractDwiChannelFilter_txx
24 #define _USE_MATH_DEFINES
27 #include "itkImageRegionConstIterator.h"
28 #include "itkImageRegionConstIteratorWithIndex.h"
29 #include "itkImageRegionIterator.h"
34 template< class TInPixelType >
35 ExtractDwiChannelFilter< TInPixelType>::ExtractDwiChannelFilter()
37 this->SetNumberOfRequiredInputs( 1 );
40 template< class TInPixelType >
41 void ExtractDwiChannelFilter< TInPixelType>::BeforeThreadedGenerateData()
43 typename InputImageType::Pointer inputImagePointer = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) );
44 if ( inputImagePointer->GetVectorLength()<=m_ChannelIndex )
45 itkExceptionMacro("Index out of bounds!");
48 template< class TInPixelType >
49 void ExtractDwiChannelFilter< TInPixelType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType )
51 typename OutputImageType::Pointer outputImage = static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
53 ImageRegionIterator< OutputImageType > oit(outputImage, outputRegionForThread);
56 typedef ImageRegionConstIterator< InputImageType > InputIteratorType;
57 typename InputImageType::Pointer inputImagePointer = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) );
59 InputIteratorType git( inputImagePointer, outputRegionForThread );
61 while( !git.IsAtEnd() )
63 oit.Set( git.Get()[m_ChannelIndex] );
68 std::cout << "One Thread finished calculation" << std::endl;
73 #endif // __itkExtractDwiChannelFilter_txx