[Insight-users] Problems with ImageToHistogramGenerator

Christian Marshall Rieck rieck at stud.ntnu.no
Tue Mar 13 11:42:21 EST 2007


I have a problem linking my program with a ImageToHistogramGenerator in 
it. As far as i can tell it is a fairly straight copy the example in the 
software guide, pg 686. (examples/statistics/ImageHistogram2.cxx)
Does anybody have any hints?
I have the header-file in my cmakelists.txt and have rerun cmake to update 
my project settings. (i don't know if this is necessary, but I have 
tried..) 


The error reported is: Segmentation error LNK2019: unresolved external 
symbol "protected: __thiscall 
itk::Statistics::DenseFrequencyContainer::DenseFrequencyContainer(void)" 
(??0DenseFrequencyContainer at Statistics@itk@@IAE at XZ) referenced in function 
"public: static class itk::SmartPointer<class 
itk::Statistics::DenseFrequencyContainer> __cdecl 
itk::Statistics::DenseFrequencyContainer::New(void)" 
(?New at DenseFrequencyContainer@Statistics at itk@@SA?AV?$SmartPointer at VDenseFrequencyContainer@Statistics at itk@@@3 at XZ)


The code looks like this:

#ifndef CBRSTAT_H
#define CBRSTAT_H

#include <itkScalarImageToHistogramGenerator.h>
#include <itkImage.h>

template<class T>
void GetHistogramFromImage(typename T::Pointer image, int numBins, float 
marginalScale) {
	
	typedef itk::Statistics::ScalarImageToHistogramGenerator<T> 
histTypeGenerator;
	typedef histTypeGenerator::HistogramType histType;

	histTypeGenerator::Pointer histGen = histTypeGenerator::New();

	histGen->SetInput(image);

	histGen->SetNumberOfBins(numBins);
	histGen->SetMarginalScale(marginalScale);
	histGen->SetHistogramMin(  0.0 );
	histGen->SetHistogramMax( 40000.0 );


	histGen->Compute();

	const histType * histogram = histGen->GetOutput();

	histType::ConstIterator it = histogram->Begin();
	histType::ConstIterator end = histogram->End();

	while(it != end) {
		std::cout << it.GetFrequency() << std::endl;
	}
}




Christian Marshall Rieck
93 49 54 75
----------------------------------------
All the good things in life are
fattening, cancer-causing or NP-complete.



More information about the Insight-users mailing list