[Insight-users] Statistic getting frequency of a Value
Karthik Krishnan
Karthik.Krishnan at kitware.com
Thu Jul 21 09:52:02 EDT 2005
Once you have created the ListSample, (You would rather use the
ScalarImageToListAdaptor). Create a histogram with two bins and the
frequency of second bin would be what you want, something like:
typedef itk::Statistics::ListSampleToHistogramGenerator<
ListSampleType, float > GeneratorType;
GeneratorType::Pointer generator = GeneratorType::New();
GeneratorType::HistogramType::SizeType size;
size.Fill(2);
generator->SetListSample( listsample );
generator->SetNumberOfBins( size );
generator->SetMarginalScale( 10.0 );
generator->Update();
GeneratorType::HistogramType::ConstPointer histogram =
generator->GetOutput();
GeneratorType::HistogramType::ConstIterator iter = histogram->Begin();
while ( iter != histogram->End() )
{
std::cout << " frequency = " << iter.GetFrequency() << std::endl;
++iter;
}
Bradley Lowekamp wrote:
>
> I have some images that are binary like, with values of 0 and 255. I
> want to count the number (or frequency of a specific value). I have
> created a ImageToListAdaptor converting my pixel type to a fixed
> array. I want to count the number of pixels that have a value of say
> 255. How do I do this?
>
>
> Thanks,
> Brad
>
> ========================================================
> Bradley Lowekamp
> Management Systems Designers Contractor for
> Office of High Performance Computing and Communications
> National Library of Medicine
> 'blowekamp at mail.nih.gov
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
More information about the Insight-users
mailing list