| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkNeighborhoodInnerProduct.txx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:42 $ |
| 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 _itkNeighborhoodInnerProduct_txx |
| 18 |
DEF |
#define _itkNeighborhoodInnerProduct_txx |
| 19 |
|
#include "itkNeighborhoodInnerProduct.h" |
| 20 |
|
|
| 21 |
|
#include "itkNumericTraits.h" |
| 22 |
|
|
| 23 |
|
namespace itk { |
| 24 |
|
|
| 25 |
|
template<class TImage, class TOperator, class TComputation> |
| 26 |
LEN |
typename NeighborhoodInnerProduct<TImage, TOperator, TComputation>::OutputPixelType |
| 27 |
|
NeighborhoodInnerProduct<TImage, TOperator, TComputation> |
| 28 |
|
::operator()(const std::slice &s, |
| 29 |
|
const ConstNeighborhoodIterator<TImage> &it, |
| 30 |
|
const OperatorType &op) const |
| 31 |
|
{ |
| 32 |
|
typename OperatorType::ConstIterator o_it; |
| 33 |
|
OutputPixelType sum = NumericTraits<OutputPixelType>::Zero; |
| 34 |
|
|
| 35 |
|
o_it = op.Begin(); |
| 36 |
|
const typename OperatorType::ConstIterator op_end = op.End(); |
| 37 |
|
|
| 38 |
|
const unsigned int start = static_cast<unsigned int>( s.start() ); |
| 39 |
|
const unsigned int stride = static_cast<unsigned int>( s.stride() ); |
| 40 |
|
for ( unsigned int i = start; o_it < op_end; i+=stride, ++o_it ) |
| 41 |
|
{ |
| 42 |
|
sum += static_cast<OutputPixelType>(*o_it) |
| 43 |
IND |
******* static_cast<OutputPixelType>(it.GetPixel(i)); |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
return sum; |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
template<class TImage, class TOperator, class TComputation> |
| 52 |
LEN |
typename NeighborhoodInnerProduct<TImage, TOperator, TComputation>::OutputPixelType |
| 53 |
|
NeighborhoodInnerProduct<TImage, TOperator, TComputation> |
| 54 |
|
::operator()(const std::slice &s, |
| 55 |
|
/* const ImageBoundaryCondition<TImage> *,*/ |
| 56 |
|
const NeighborhoodType &N, |
| 57 |
|
const OperatorType &op) const |
| 58 |
|
{ |
| 59 |
|
typename OperatorType::ConstIterator o_it; |
| 60 |
|
OutputPixelType sum = NumericTraits<OutputPixelType>::Zero; |
| 61 |
|
|
| 62 |
|
o_it = op.Begin(); |
| 63 |
|
const typename OperatorType::ConstIterator op_end = op.End(); |
| 64 |
|
|
| 65 |
|
const unsigned int start = static_cast<unsigned int>( s.start() ); |
| 66 |
|
const unsigned int stride = static_cast<unsigned int>( s.stride() ); |
| 67 |
|
for ( unsigned int i = start; o_it < op_end; i+=stride, ++o_it ) |
| 68 |
|
{ |
| 69 |
|
sum += static_cast<OutputPixelType>(*o_it) |
| 70 |
IND |
******* static_cast<OutputPixelType>(N[i]); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
return sum; |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
|
| 78 |
EML |
|
| 79 |
|
}// end namespace itk |
| 80 |
|
#endif |
| 81 |
|
|