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&lt; short, 1 &gt; MeasurementVectorType;</div><div>typedef itk::Image&lt; MeasurementVectorType, 3 &gt; ArrayImageType;</div>
<div>typedef itk::ScalarToArrayCastImageFilter&lt; ImageType, ArrayImageType &gt; CasterType;</div><div>typedef itk::Statistics::ImageToListSampleAdaptor&lt; ArrayImageType &gt; SampleType;</div><div>typedef itk::Statistics::Histogram&lt; short,itk::Statistics::DenseFrequencyContainer2 &gt; HistogramType;</div>
<div>typedef itk::Statistics::SampleToHistogramFilter&lt;SampleType, HistogramType&gt; SampleToHistogramFilterType;</div></div><div><br></div><div><div>CasterType::Pointer caster = CasterType::New();</div><div>caster-&gt;SetInput( reader-&gt;GetOutput() );</div>
<div>caster-&gt;Update();</div><div><br></div><div>SampleType::Pointer sample = SampleType::New();</div><div>sample-&gt;SetImage( caster-&gt;GetOutput() );</div><div><br></div><div>SampleToHistogramFilterType::Pointer sampleToHistogramFilter = SampleToHistogramFilterType::New();</div>
<div>sampleToHistogramFilter-&gt;SetInput(sample);</div><div><br></div><div>SampleToHistogramFilterType::HistogramSizeType histogramSize(1);</div><div>histogramSize.Fill((max-min)+1);</div><div>sampleToHistogramFilter-&gt;SetHistogramSize(histogramSize);</div>
<div> </div><div>sampleToHistogramFilter-&gt;Update();</div><div> </div><div>const HistogramType* histogram = sampleToHistogramFilter-&gt;GetOutput();</div><div><br></div><div><div>for ( short i = 0; i &lt; histogram-&gt;GetSize()[0]; i++ )</div>
<div>{</div><div>   std::cout &lt;&lt; i &lt;&lt; &quot; - &quot; &lt;&lt; histogram-&gt;GetBinMin(0, i) &lt;&lt; &quot; - &quot; &lt;&lt; histogram-&gt;GetBinMax(0, i) &lt;&lt; &quot; - &quot; &lt;&lt; histogram-&gt;GetFrequency(i) &lt;&lt; std::endl; </div>
<div>}</div></div><div> </div></div>