[Insight-users] Wrong matrix obtained using ScalarImageToRunLengthMatrixFilter

Françoise LEFEBVRE lefebvre at imnc.in2p3.fr
Tue Jul 24 12:03:20 EDT 2012


Hi,

I implemented the following source code in order to compute run length 
parameters using first the ScalarImageToRunLengthMatrixFilter class 
followed by HistogramToRunLengthFeaturesFilter.

The code for the first step is :

     typedef itk::Image<unsigned char,2> ImageType2UC;
     typedef 
itk::Statistics::ScalarImageToRunLengthMatrixFilter<ImageType2UC>
                 ScalarImageToRunLengthMatrixFilterType;
     typedef ScalarImageToRunLengthMatrixFilterType::HistogramType
                 RunLengthHistogramType;

     ScalarImageToRunLengthMatrixFilterType::Pointer filterRL = 
ScalarImageToRunLengthMatrixFilterType::New();
     ImageType2UC::OffsetType offset = {1, 0};
     filterRL->SetOffset(offset);
     filterRL->SetNumberOfBinsPerAxis(3);
     filterRL->SetPixelValueMinMax(1, 3);
     filterRL->SetInput(imTest);
     filterRL->Update();

     RunLengthHistogramType::ConstIterator it = 
filterRL->GetOutput()->Begin();
     for (int j =0; j < filterRL->GetOutput()->GetSize(0); j++)
     {
         QString strLg;
         for (int i =0; i < filterRL->GetOutput()->GetSize(1); i++, ++it)
             strLg += QString().sprintf("%3d", it.GetFrequency());
         qDebug() << strLg;
     }

I tested it on a very simple matrix (from Chu et al, 1990)

1  1  2  3  3
2  2  3  1  1
3  1  2  2  3
2  3  1  1  2
1  1  2  2  3

The resulting matrix was :
  5  6  0
  6  0  0
  0  0  0

whereas the expected one is :
1 4 0
3 3 0
5 1 0

Has someone any experience using those classes ?

Thank you in advance,

-- 
Françoise LEFEBVRE
IMNC (Imagerie et Modélisation en Neurobiologie et Cancérologie)
Campus d'Orsay - Bât 440
91405 ORSAY Cedex
01 69 15 51 87



More information about the Insight-users mailing list