| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkMinimumDecisionRule.cxx.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 |
DEF |
=========================================================================*/ |
| 17 |
|
#include "itkMinimumDecisionRule.h" |
| 18 |
|
|
| 19 |
|
namespace itk |
| 20 |
|
{ |
| 21 |
|
|
| 22 |
|
MinimumDecisionRule |
| 23 |
|
::MinimumDecisionRule() |
| 24 |
|
{ |
| 25 |
|
|
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
unsigned int |
| 29 |
|
MinimumDecisionRule |
| 30 |
|
::Evaluate( const VectorType &discriminantScores) const |
| 31 |
|
{ |
| 32 |
|
|
| 33 |
|
double minimumDistance = discriminantScores[0]; |
| 34 |
|
unsigned int classifiedPixelIndex = 0; |
| 35 |
LEN |
unsigned int numberOfClasses = static_cast<unsigned int>( discriminantScores.size() ); |
| 36 |
|
|
| 37 |
|
//Loop through the probabilities to get the best index |
| 38 |
|
for(unsigned int classIndex = 1; classIndex < numberOfClasses; classIndex++ ) |
| 39 |
|
{ |
| 40 |
|
if( discriminantScores[classIndex] < minimumDistance ) |
| 41 |
|
{ |
| 42 |
|
minimumDistance = discriminantScores[classIndex]; |
| 43 |
|
classifiedPixelIndex = classIndex; |
| 44 |
|
} |
| 45 |
|
}// end for |
| 46 |
|
|
| 47 |
|
return classifiedPixelIndex; |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
unsigned int |
| 52 |
|
MinimumDecisionRule |
| 53 |
|
::Evaluate( const ArrayType &discriminantScores) const |
| 54 |
|
{ |
| 55 |
|
|
| 56 |
|
double minimumDistance = discriminantScores[0]; |
| 57 |
|
unsigned int classifiedPixelIndex = 0; |
| 58 |
LEN |
unsigned int numberOfClasses = static_cast<unsigned int>( discriminantScores.Size() ); |
| 59 |
|
|
| 60 |
|
//Loop through the probabilities to get the best index |
| 61 |
|
for(unsigned int classIndex = 1; classIndex < numberOfClasses; classIndex++ ) |
| 62 |
|
{ |
| 63 |
|
if( discriminantScores[classIndex] < minimumDistance ) |
| 64 |
|
{ |
| 65 |
|
minimumDistance = discriminantScores[classIndex]; |
| 66 |
|
classifiedPixelIndex = classIndex; |
| 67 |
|
} |
| 68 |
|
}// end for |
| 69 |
|
|
| 70 |
|
return classifiedPixelIndex; |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
} // namespace itk |
| 75 |
|
|
| 76 |
EOF |
|
| 77 |
EOF,EML |
|
| 78 |
EOF,EML |
|
| 79 |
EOF,EML |
|
| 80 |
EOF,EML |
|
| 81 |
EOF,EML |
|
| 82 |
EOF,EML |
|
| 83 |
EOF,EML |
|