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

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


Hi Radhika,

Thanks a lot,

Non-illuminating error messages are always
better than no messages at all.

Is this the *only* error message that you get ?

or those are the last couple of lines from a
long paragraph with messages about templates ?

Are you using VisualStudio 6.0 ?

The bottom line of the message is that you
are trying to use a type, that the compiler
has not recognized as being a type. Since you
have a chain of typedefs, the offending type
could be anyone in the chain. That make us
suspect that your actual error message is
much longer than what you just posted, and
that the illuminating part of the message is
at the beginning instead of the end.


Your function looks like an attempt to use
partial specialization, since your function
has a defined dimension for the image but
a templated parameter for the pixel type.


VisualStudio 6.0 *do not* support partial
specialization. If this is the compiler
that you are using you may want to consider
one of the following options:


A) Changing compiler   :-)


B) Templating the function over the
    entire image type, as opposed to
    just the pixel type.


Please let us know about the questions above.


Just keep in mind that is very hard to see
your screen from here...


Thanks


   Luis


------------------------------
Radhika Sivaramakrishna wrote:
> Hi Luis,
> That was very sweet :-)
> The error is very non-illuminating that is why I said that.
> Here it is.
> 
> /export/jfs/rsivaram/PostExbrain-code/HistogramThreshold.txx:94: parse 
> error
>    before `=' token
> /export/jfs/rsivaram/PostExbrain-code/HistogramThreshold.txx:95: parse 
> error
>    before `=' token
> 
> 
> The lines for which it is complaining are:
> 
> HistogramType::ConstIterator itr = histogram->Begin();
> HistogramType::ConstIterator end = histogram->End();
> 
> Radhika
> 
> 
> -----Original Message-----
> From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
> Sent: Wednesday, February 11, 2004 12:13 PM
> To: Radhika Sivaramakrishna
> Cc: 'Miller, James V (Research)'; 'ITK'
> Subject: Re: Problem with HistogramType::ConstIterator inside function
> 
> 
> 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.
>  >
> 
> 
>                                                     
> ----------------------------------------------------- 
> 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.
>