1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkImageModelEstimatorBase.txx,v $
Language: C++
Date: $Date: 2003-09-10 14:28:32 $
Version: $Revision: 1.10 $
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 _itkImageModelEstimatorBase_txx
#define _itkImageModelEstimatorBase_txx
#include "itkImageModelEstimatorBase.h"
#include "itkCommand.h"
namespace itk
{
template <class TInputImage,
class TMembershipFunction>
ImageModelEstimatorBase<TInputImage, TMembershipFunction>
::ImageModelEstimatorBase(void):
m_NumberOfModels( 0 )
{
}
template <class TInputImage,
class TMembershipFunction>
ImageModelEstimatorBase<TInputImage, TMembershipFunction>
::~ImageModelEstimatorBase()
{
}
template <class TInputImage,
class TMembershipFunction>
void
ImageModelEstimatorBase<TInputImage, TMembershipFunction>
::Update()
{
GenerateData() ;
}
template <class TInputImage,
class TMembershipFunction>
void
ImageModelEstimatorBase<TInputImage, TMembershipFunction>
::GenerateData()
{
/*
if( ( m_NumberOfModels == 0 ) ||
( m_MembershipFunctions.size() == 0 ) ||
( m_NumberOfClasses != m_MembershipFunctions.size() ) )
{
throw ExceptionObject(__FILE__, __LINE__);
}
*/
this->EstimateModels();
}
/*
* PrintSelf
*/
template <class TInputImage,
class TMembershipFunction>
void
ImageModelEstimatorBase<TInputImage, TMembershipFunction>
::PrintSelf( std::ostream& os, Indent indent ) const
{
Superclass::PrintSelf(os,indent);
os << indent << "Number of models: " << m_NumberOfModels << std::endl;
os << indent << " " << std::endl;
os << indent <<"Results of the model estimator."<<std::endl;
os << indent <<"===================================="<<std::endl;
for (unsigned int classIndex = 0 ; classIndex < m_NumberOfModels ; classIndex++)
{
os << indent << "Statistics for " << classIndex << std::endl;
(m_MembershipFunctions[classIndex])->Print(os);
os << indent <<"===================================="<<std::endl;
}
os << indent << " " << std::endl;
os << indent << "InputImage: ";
os << m_InputImage.GetPointer() << std::endl;
}// end PrintSelf
//------------------------------------------------------------------
// Add a membership function corresponding to the class index
//------------------------------------------------------------------
template <class TInputImage,
class TMembershipFunction>
unsigned int
ImageModelEstimatorBase<TInputImage, TMembershipFunction>
::AddMembershipFunction(MembershipFunctionPointer function)
{
m_MembershipFunctions.push_back(function) ;
return static_cast<unsigned int>( m_MembershipFunctions.size() );
}
} // namespace itk
#endif
|