ITK/Examples/Statistics/ListSample: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
No edit summary
(Deprecated content that is moved to sphinx)
 
Line 1: Line 1:
ListSample is the class to hold "measurements" for most of the Statistics classes.
{{warning|1=The media wiki content on this page is no longer maintained.  The examples presented on the https://itk.org/Wiki/*  pages likely require ITK version 4.13 or earlier releasesIn many cases, the examples on this page no longer conform to the best practices for modern ITK versions.}}
 
==ListSample.cxx==
<source lang="cpp">
#include "itkListSample.h"
#include "itkVector.h"
 
int main(int, char *[])
{
  typedef itk::Vector<float, 3> MeasurementVectorType;
  typedef itk::Statistics::ListSample<MeasurementVectorType> SampleType;
  SampleType::Pointer sample = SampleType::New();
 
  MeasurementVectorType mv;
  mv[0] = 1.0;
  mv[1] = 2.0;
  mv[2] = 4.0;
 
  sample->PushBack(mv);
 
  sample->Resize(3);
 
  mv[0] = 2.0;
   mv[1] = 4.0;
  mv[2] = 5.0;
  sample->SetMeasurementVector(1, mv);
 
  mv[0] = 3.0;
  mv[1] = 8.0;
  mv[2] = 6.0;
  sample->SetMeasurementVector(2, mv);
 
  for(unsigned long i = 0; i < sample->Size(); ++i)
    {
    std::cout << "id = " << i
              << "\t measurement vector = "
              << sample->GetMeasurementVector(i)
              << "\t frequency = "
              << sample->GetFrequency(i)
              << std::endl;
    }
 
  SampleType::Iterator iter = sample->Begin();
 
  while( iter != sample->End() )
    {
    std::cout << "id = " << iter.GetInstanceIdentifier()
              << "\t measurement vector = "
              << iter.GetMeasurementVector()
              << "\t frequency = "
              << iter.GetFrequency()
              << std::endl;
    ++iter;
    }
 
  std::cout << "Size = " << sample->Size() << std::endl;
  std::cout << "Total frequency = "
            << sample->GetTotalFrequency() << std::endl;
 
  return EXIT_SUCCESS;
}
</source>
 
 
{{ITKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 21:32, 6 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.