[Insight-users] Re: Problem with HistogramType::ConstIterator inside function

Luis Ibanez luis.ibanez at kitware.com
Wed, 11 Feb 2004 15:12:51 -0500


Hi Radhika,

It will be an extremely generous act on your part
to share the text of the error message with us.

Our divinatory skill are *very very* limited...  :-/

Please post the compiler error message that you get.


Thanks


   Luis


-------------------------------
Radhika Sivaramakrishna wrote:

> 
> Hi Luis and Jim,
> 
> I was trying to use the ScalarImageToHistogramGenerator inside a 
> function to which I pass an image and mask. I am running into some problems.
> 
> My function is templated and is defined like this:
> 
> template <class PixelType>
> void HistogramThreshold(const itk::Image< PixelType, 3> * image,
>             itk::Image< PixelType, 3> * mask)
> 
> The code where I get the error is very similar to one of the histogram 
> examples and is like this:
> 
> typedef itk::Statistics::ScalarImageToHistogramGenerator<
>                                                     ImageType
>                                                           >   
> HistogramGeneratorType;
> 
>   HistogramGeneratorType::Pointer histogramGenerator = 
> HistogramGeneratorType::New();
> 
> histogramGenerator->SetInput(  image );
> 
>   histogramGenerator->SetNumberOfBins( NumberOfBins );
>   histogramGenerator->SetMarginalScale( MarginalScale );
>   histogramGenerator->Compute();
> 
>   typedef HistogramGeneratorType::HistogramType  HistogramType;
> 
>   const HistogramType * histogram = histogramGenerator->GetOutput();
> 
>   const unsigned int histogramSize = histogram->Size();
> 
>   std::cout << "Histogram size " << histogramSize << std::endl;
> 
>   HistogramType::ConstIterator itr = histogram->Begin();
>   HistogramType::ConstIterator end = histogram->End();
> 
> The compile error I am getting is hardly descriptive. It says that there 
> is a parse error in this definition of itr and end (see above). I do not 
> get this error when this whole thing is one main function.
> 
> My suspicion is it has something to do with typename etc. Can you tell 
> me exactly how to define the two Histogram iterators without getting 
> this error?
> 
> Thanks
> Radhika
> 
>                                                     
> ----------------------------------------------------- 
> Confidentiality Notice.
> This email message is for the sole use of the intended recipient(s) and 
> may contain confidential and privileged information. Any unauthorized 
> review, use, disclosure or distribution is prohibited. If you are not 
> the intended recipient, please contact the sender by reply email and 
> destroy all copies of the original message. If you are the intended 
> recipient, please be advised that the content of this message is subject 
> to access, review and disclosure by the sender's Email System Administrator.
>