KWStyle - itkVectorMeanImageFunction.txx
 
Matrix View
Description

1 /*=========================================================================
2
3     Program:   Insight Segmentation & Registration Toolkit
4     Module:    $RCSfile: itkVectorMeanImageFunction.txx.html,v $
5     Language:  C++
6     Date:      $Date: 2006/01/17 19:15:49 $
7     Version:   $Revision: 1.4 $
8
9     Copyright (c) Insight Software Consortium. All rights reserved.
10     See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12        This software is distributed WITHOUT ANY WARRANTY; without even 
13        the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14        PURPOSE.  See the above copyright notices for more information.
15
16   =========================================================================*/
17 DEF #ifndef _itkVectorMeanImageFunction_txx
18 DEF #define _itkVectorMeanImageFunction_txx
19 #include "itkVectorMeanImageFunction.h"
20
21 #include "itkNumericTraits.h"
22 #include "itkConstNeighborhoodIterator.h"
23
24 namespace itk
25 {
26
27 /**
28 IND **** Constructor
29 IND ****/
30 template <class TInputImage, class TCoordRep>
31 VectorMeanImageFunction<TInputImage,TCoordRep>
32 ::VectorMeanImageFunction()
33 {
34   m_NeighborhoodRadius = 1;
35 }
36
37
38 /**
39 IND ****
40 IND ****/
41 template <class TInputImage, class TCoordRep>
42 void
43 VectorMeanImageFunction<TInputImage,TCoordRep>
44 ::PrintSelf(std::ostream& os, Indent indent) const
45 {
46   this->Superclass::PrintSelf(os,indent);
47   os << indent << "NeighborhoodRadius: "  << m_NeighborhoodRadius << std::endl;
48 }
49
50
51 /**
52  *
53  */
54 template <class TInputImage, class TCoordRep>
55 typename VectorMeanImageFunction<TInputImage,TCoordRep>
56 ::RealType
57 VectorMeanImageFunction<TInputImage,TCoordRep>
58 ::EvaluateAtIndex(const IndexType& index) const
59 {
60   RealType sum;
61   typedef  typename TInputImage::PixelType   PixelType;
62   typedef  typename PixelType::ValueType     PixelComponentType;
63 LEN,TDA   typedef  typename NumericTraits< PixelComponentType >::RealType PixelComponentRealType;
64   
65   const unsigned int VectorDimension = 
66 IND ******::itk::GetVectorDimension< PixelType >::VectorDimension;
67
68   sum.Fill( NumericTraits< PixelComponentRealType >::Zero );
69   
70   if( !this->GetInputImage() )
71     {
72     sum.Fill( NumericTraits< PixelComponentRealType >::max() );
73     return sum;
74     }
75   
76   if ( !this->IsInsideBuffer( index ) )
77     {
78     sum.Fill( NumericTraits< PixelComponentRealType >::max() );
79     return sum;
80     }
81
82   // Create an N-d neighborhood kernel, using a zeroflux boundary condition
83   typename InputImageType::SizeType kernelSize;
84   kernelSize.Fill( m_NeighborhoodRadius );
85   
86   ConstNeighborhoodIterator<InputImageType>
87 LEN,IND ****it(kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
88
89   // Set the iterator at the desired location
90   it.SetLocation(index);
91
92   // Walk the neighborhood
93   const unsigned int size = it.Size();
94   for (unsigned int i = 0; i < size; ++i)
95     {
96     for(unsigned int dim=0; dim<VectorDimension; dim++)
97       {
98       sum[dim] += static_cast<PixelComponentRealType>( it.GetPixel(i)[dim] );
99       }
100     }
101   for(unsigned int dim=0; dim<VectorDimension; dim++)
102     {
103     sum[dim] /= double(it.Size());
104     }
105              
106   return ( sum );
107 }
108
109
110 // namespace itk
111
112 #endif
113

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:53PM
© Kitware Inc.