Hi everyone <div><br></div><div>I am calculating a histogram of a grayscale image (3D volume) using a ImageToListSampleAdaptor and a SampleToHistogramFilter pipeline (see below) - I feel I control the bounds of the bins better this way. </div>
<div><br></div><div>So I am interested in extracting some information from the resulting 1 dimensional histogram, specifically the frequency container vector or the maximum value (bin index and frequency value) of the frequency container vector. </div>
<div><br></div><div>Any suggestions on how to do this? I could not identify a straightforward way of doing this... </div><div><br></div><div>Do I need to traverse the histogram and calculate the max value separately? </div>
<div><br></div><div>Any suggestions are appreciated. </div><div><br>Sergio </div><div><br></div><div>Code ----- </div><div><div>typedef itk::FixedArray< short, 1 > MeasurementVectorType;</div><div>typedef itk::Image< MeasurementVectorType, 3 > ArrayImageType;</div>
<div>typedef itk::ScalarToArrayCastImageFilter< ImageType, ArrayImageType > CasterType;</div><div>typedef itk::Statistics::ImageToListSampleAdaptor< ArrayImageType > SampleType;</div><div>typedef itk::Statistics::Histogram< short,itk::Statistics::DenseFrequencyContainer2 > HistogramType;</div>
<div>typedef itk::Statistics::SampleToHistogramFilter<SampleType, HistogramType> SampleToHistogramFilterType;</div></div><div><br></div><div><div>CasterType::Pointer caster = CasterType::New();</div><div>caster->SetInput( reader->GetOutput() );</div>
<div>caster->Update();</div><div><br></div><div>SampleType::Pointer sample = SampleType::New();</div><div>sample->SetImage( caster->GetOutput() );</div><div><br></div><div>SampleToHistogramFilterType::Pointer sampleToHistogramFilter = SampleToHistogramFilterType::New();</div>
<div>sampleToHistogramFilter->SetInput(sample);</div><div><br></div><div>SampleToHistogramFilterType::HistogramSizeType histogramSize(1);</div><div>histogramSize.Fill((max-min)+1);</div><div>sampleToHistogramFilter->SetHistogramSize(histogramSize);</div>
<div> </div><div>sampleToHistogramFilter->Update();</div><div> </div><div>const HistogramType* histogram = sampleToHistogramFilter->GetOutput();</div><div><br></div><div><div>for ( short i = 0; i < histogram->GetSize()[0]; i++ )</div>
<div>{</div><div> std::cout << i << " - " << histogram->GetBinMin(0, i) << " - " << histogram->GetBinMax(0, i) << " - " << histogram->GetFrequency(i) << std::endl; </div>
<div>}</div></div><div> </div></div>