[Insight-users] Mean and Covariance trouble with sample classification

Aditya C antariksh at gmail.com
Thu Apr 6 15:09:02 EDT 2006


Hi,

I've been trying to compute the means and variances for each class resulting 
from a classification process.

-When I try to use the MeanCalculator on individual classes, what I get 
instead is the global mean for the entire sample set even though I specify 
individual class labels with GetClassSample() before running the 
MeanCalculator method.

-The ITK classification algorithms do provide per class mean estimates, 
however I also require the variances for each class (the VarianceCalculator 
works in a similar manner, so the problem affects both the MeanCalculator and 
CovarianceCalculator)

Please advise.

Thanks in advance.

-Aditya Chandramouli
Student
ULg, Belgium

----------------------------
typename ClassifierType::OutputType* membershipSample = 
classifier->GetOutput();	//classifier results in a membership sample

/* .
   .
   .
*/

typedef itk::Vector<InputImagePixelType, 1> MeasurementVectorType;
typedef itk::Image<MeasurementVectorType, Dimension> ArrayImageType;
typedef itk::Statistics::ImageToListAdaptor<ArrayImageType> CastSampleType;

typedef itk::Statistics::MeanCalculator< CastSampleType > MeanAlgorithmType;
  
typename MeanAlgorithmType::Pointer meanAlgorithm = MeanAlgorithmType::New();

for (unsigned i=0; i < 3; ++i)
{

  //variable i specifies the individual class on which the meanAlgorithm is 
supposed to run

 
meanAlgorithm->SetInputSample( membershipSample->GetClassSample(i)->GetSample());

  meanAlgorithm->Update();
		
  std::cout << "Sample mean = " << *(meanAlgorithm->GetOutput()) << std::endl;	
}
	
----------------------------

(pseudo-)Output:

Sample mean for class 1 = [132.319]
Sample mean for class 2 = [132.319]
Sample mean for class 3 = [132.319]


More information about the Insight-users mailing list