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 __itkAdcImageFilter_txx
18 #define __itkAdcImageFilter_txx
24 #define _USE_MATH_DEFINES
27 #include "itkImageRegionConstIterator.h"
28 #include "itkImageRegionConstIteratorWithIndex.h"
29 #include "itkImageRegionIterator.h"
34 template< class TInPixelType, class TOutPixelType >
35 AdcImageFilter< TInPixelType, TOutPixelType>
38 this->SetNumberOfRequiredInputs( 1 );
41 template< class TInPixelType, class TOutPixelType >
43 AdcImageFilter< TInPixelType, TOutPixelType>
44 ::BeforeThreadedGenerateData()
46 typename OutputImageType::Pointer outputImage =
47 static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
48 outputImage->FillBuffer(0.0);
51 template< class TInPixelType, class TOutPixelType >
53 AdcImageFilter< TInPixelType, TOutPixelType>
54 ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType )
56 typename OutputImageType::Pointer outputImage =
57 static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
59 ImageRegionIterator< OutputImageType > oit(outputImage, outputRegionForThread);
62 typedef ImageRegionConstIterator< InputImageType > InputIteratorType;
63 typename InputImageType::Pointer inputImagePointer = NULL;
64 inputImagePointer = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) );
66 InputIteratorType git( inputImagePointer, outputRegionForThread );
68 while( !git.IsAtEnd() )
70 typename InputImageType::PixelType pix = git.Get();
71 TOutPixelType outval = 0;
75 for (unsigned int i=0; i<inputImagePointer->GetVectorLength(); i++)
77 GradientDirectionType g = m_GradientDirections->GetElement(i);
78 if (g.magnitude()<0.001)
93 for (unsigned int i=0; i<inputImagePointer->GetVectorLength(); i++)
95 GradientDirectionType g = m_GradientDirections->GetElement(i);
96 if (g.magnitude()>0.001)
98 double twonorm = g.two_norm();
99 double b = m_B_value*twonorm*twonorm;
105 outval -= std::log(S/S0)/b;
116 if (outval==outval && outval<10000)
123 std::cout << "One Thread finished calculation" << std::endl;
126 template< class TInPixelType, class TOutPixelType >
128 AdcImageFilter< TInPixelType, TOutPixelType>
129 ::PrintSelf(std::ostream& os, Indent indent) const
131 Superclass::PrintSelf(os,indent);
136 #endif // __itkAdcImageFilter_txx