Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itk_TensorToL2NormImageFilter_txx_
00018 #define _itk_TensorToL2NormImageFilter_txx_
00019 #endif
00020
00021 #include "itkTensorToL2NormImageFilter.h"
00022 #include <itkImageRegionIterator.h>
00023 #include <itkImageRegionConstIterator.h>
00024
00025 namespace itk
00026 {
00027
00028 template <class TInputImage, class TOutputImage>
00029 void
00030 TensorToL2NormImageFilter<TInputImage, TOutputImage>
00031 ::ThreadedGenerateData ( const OutputImageRegionType &outputRegionForThread, int threadId )
00032 {
00033 typedef ImageRegionIterator<OutputImageType> IteratorOutputType;
00034 typedef ImageRegionConstIterator<InputImageType> IteratorInputType;
00035
00036 unsigned long numPixels = outputRegionForThread.GetNumberOfPixels();
00037 unsigned long step = numPixels/100;
00038 unsigned long progress = 0;
00039
00040 IteratorOutputType itOut(this->GetOutput(), outputRegionForThread);
00041 IteratorInputType itIn(this->GetInput(), outputRegionForThread);
00042
00043 if( threadId==0 )
00044 this->UpdateProgress (0.0);
00045
00046 while(!itOut.IsAtEnd())
00047 {
00048 if( this->GetAbortGenerateData() )
00049 throw itk::ProcessAborted(__FILE__,__LINE__);
00050
00051
00052 OutputPixelType out = static_cast<OutputPixelType>( 0.0 );
00053
00054 InputPixelType T = itIn.Get();
00055
00056 if ( !(T[0]==0 && T[1]==0 && T[2]==0 && T[3]==0 && T[4]==0 && T[5]==0) )
00057 {
00058 double sum = T[0]*T[0] + T[3]*T[3] + T[5]*T[5]
00059 + T[1]*T[2]*2.0 + T[2]*T[4]*2.0 + T[1]*T[4]*2.0;
00060 out = static_cast<OutputPixelType>( vcl_sqrt( sum ));
00061 }
00062
00063 if( threadId==0 && step>0)
00064 {
00065 if( (progress%step)==0 )
00066 this->UpdateProgress ( double(progress)/double(numPixels) );
00067 }
00068
00069
00070 itOut.Set (out);
00071 ++progress;
00072 ++itOut;
00073 ++itIn;
00074
00075 }
00076
00077 if( threadId==0 )
00078 this->UpdateProgress (1.0);
00079
00080 }
00081
00082
00083
00084 }