void CreateImage(ImageType::Pointer image);
int main(int, char *[])
{
const unsigned int MeasurementVectorSize = 1;
const unsigned int binsPerDimension = 30;
ImageType::Pointer image = ImageType::New();
CreateImage(image);
ImageToHistogramFilterType::HistogramType::MeasurementVectorType lowerBound(binsPerDimension);
lowerBound.Fill(0);
ImageToHistogramFilterType::HistogramType::MeasurementVectorType upperBound(binsPerDimension);
upperBound.Fill(255) ;
size.Fill(binsPerDimension);
ImageToHistogramFilterType::Pointer imageToHistogramFilter = ImageToHistogramFilterType::New();
imageToHistogramFilter->SetInput(image);
imageToHistogramFilter->SetHistogramBinMinimum(lowerBound);
imageToHistogramFilter->SetHistogramBinMaximum(upperBound);
imageToHistogramFilter->SetHistogramSize(size);
imageToHistogramFilter->Update();
ImageToHistogramFilterType::HistogramType* histogram = imageToHistogramFilter->GetOutput();
std::cout << "Frequency = ";
for(unsigned int i = 0; i < histogram->GetSize()[0]; ++i)
{
std::cout << histogram->GetFrequency(i) << " ";
}
std::cout << std::endl;
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
while(!imageIterator.IsAtEnd())
{
imageIterator.Set(122);
++imageIterator;
}
}