📄 itkweightedmeancalculator.h
字号:
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkWeightedMeanCalculator.h,v $
Language: C++
Date: $Date: 2003/09/10 14:29:48 $
Version: $Revision: 1.5 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkWeightedMeanCalculator_h
#define __itkWeightedMeanCalculator_h
#include <vnl/vnl_vector.h>
#include <vnl/vnl_matrix.h>
#include "itkArray.h"
#include "itkVector.h"
#include "itkFunctionBase.h"
#include "itkSampleAlgorithmBase.h"
namespace itk{
namespace Statistics{
/** \class WeightedMeanCalculator
* \brief calculates sample mean where each measurement vector has
* associated weight value
*
* To run this algorithm, you have plug in the target sample data
* using SetInpuSample method and provides weight by an array or function.
*. Then call the Update method to run the alogithm.
*
* \sa MeanCalculator SampleAlgorithmBase
*/
template< class TSample >
class WeightedMeanCalculator :
public SampleAlgorithmBase< TSample >
{
public:
/**Standard class typedefs. */
typedef WeightedMeanCalculator Self;
typedef SampleAlgorithmBase< TSample > Superclass ;
typedef SmartPointer<Self> Pointer;
/**Standard Macros */
itkTypeMacro(WeightedMeanCalculator, SampleAlgorithmBase);
itkNewMacro(Self) ;
itkStaticConstMacro(MeasurementVectorSize, unsigned int,
TSample::MeasurementVectorSize);
typedef typename TSample::MeasurementVectorType MeasurementVectorType ;
/** Mean (output) typedef */
typedef Vector< double, itkGetStaticConstMacro(MeasurementVectorSize) > OutputType ;
/** Array typedef for weights */
typedef Array< double > WeightArrayType ;
/** Sets the weights using an array */
void SetWeights(WeightArrayType* array) ;
/** Gets the weights array */
WeightArrayType* GetWeights() ;
/** Weight calculation function typedef */
typedef FunctionBase< MeasurementVectorType, double > WeightFunctionType ;
/** Sets the wiehts using an function
* the function should have a method,
* Evaluate(MeasurementVectorType&) */
void SetWeightFunction(WeightFunctionType* func) ;
/** Gets the weight function */
WeightFunctionType* GetWeightFunction() ;
/** Returns the mean vector as the result */
OutputType* GetOutput() ;
protected:
WeightedMeanCalculator() ;
virtual ~WeightedMeanCalculator() {}
void PrintSelf(std::ostream& os, Indent indent) const;
/** Calculates the mean and save it */
void GenerateData() ;
private:
WeightArrayType* m_Weights ;
WeightFunctionType* m_WeightFunction ;
OutputType m_Output ;
} ; // end of class
} // end of namespace Statistics
} // end of namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkWeightedMeanCalculator.txx"
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -