[ITK] Problem to pass value from an array to a histogram

Matt McCormick matt.mccormick at kitware.com
Thu Jan 8 11:48:32 EST 2015


Hi Cyril,

If you are trying to use this version [1] of SetFrequency, then
declare the index variable as

  HistogramType::Index index;

instead of

  int index[2]

HTH,
Matt

[1] http://www.itk.org/Doxygen/html/classitk_1_1Statistics_1_1Histogram.html#aedd20d5304684326df28c6bd10ec3130

On Thu, Jan 8, 2015 at 10:45 AM, Cyril Jaudet <drcjaudet at gmail.com> wrote:
> Hello,
> I want to implement new texture analysis in c++ Grey size zone matrix.
> I succeed to create a 2d matrix with the corresponding value. Now, the goal
> is to transform it to an histogram and to use it with
> itkHistogramToRunLengthFeaturesFilter to extract the features.
> Unfortunately a problem appaers when  i use SetFrequency to store the value
> of the matrix to the histogram.
>
> invalid conversion from ‘int*’ to ‘itk::Statistics::Histogram<float,
> itk::Statistics::DenseFrequencyContainer2>::InstanceIdentifier {aka long
> unsigned int}’ [-fpermissive]
>               histogram->SetFrequency(index, frequency);
>
> i try to remplace the matrix value by 0 or 2.0 and it didn't work either.
>
> Here the part of the code:
>
> typedef  itk::Statistics::SparseFrequencyContainer2 FrequencyContainerType;
> typedef  FrequencyContainerType::AbsoluteFrequencyType FrequencyType;
>
> typedef itk::Statistics::Histogram< float, FrequencyContainerType>
> HistogramType;
>
>      unsigned int numberOfComponents=2;
>      HistogramType::Pointer histogram = HistogramType::New();
>
>      HistogramType::SizeType size(numberOfComponents);
>      size[0]=D;
>      size[1]=Max_volume;
>
>      HistogramType::MeasurementVectorType lowerBound(numberOfComponents);
>      lowerBound[0]=1;
>      lowerBound[1]=1;
>      HistogramType::MeasurementVectorType upperBound(numberOfComponents);
>      upperBound[0]=D;
>      upperBound[1]=Max_volume;
>
>      histogram->Initialize(size, lowerBound, upperBound );
>      histogram->SetToZero();
>
>      int index[2];
>      for(int level_Grey=0; level_Grey<D; level_Grey++ )
>      {
>          for(int N=0; N<Max_volume;N++)
>          {
>              index[0]=level_Grey;
>              index[1]=N;
>              histogram->SetFrequency(index,
> static_cast<FrequencyType>(Z[level_Grey][N]));
>          }
>      }
>
> Thanks you,
>
> Cyril Jaudet
> Medical physicist, phd
>
>
> cyril.jaudet at uzbrussel.be
>
> Laarbeeklaan 101 - 1090 Brussel
> Tel 02 477 52 35 - Fax 02 477 YY YY
>
> www.uzbrussel.be
>
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>


More information about the Community mailing list