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

Radhika Sivaramakrishna radhika.sivaramakrishna at synarc.com
Wed, 11 Feb 2004 12:15:24 -0800


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C3F0DB.C831BBF4
Content-Type: text/plain

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.

------_=_NextPart_001_01C3F0DB.C831BBF4
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2656.87">
<TITLE>RE: Problem with HistogramType::ConstIterator inside =
function</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Hi Luis,</FONT>
<BR><FONT SIZE=3D2>That was very sweet :-) </FONT>
<BR><FONT SIZE=3D2>The error is very non-illuminating that is why I =
said that.</FONT>
<BR><FONT SIZE=3D2>Here it is.</FONT>
</P>

<P><FONT =
SIZE=3D2>/export/jfs/rsivaram/PostExbrain-code/HistogramThreshold.txx:94=
: parse error</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp; before `=3D' token</FONT>
<BR><FONT =
SIZE=3D2>/export/jfs/rsivaram/PostExbrain-code/HistogramThreshold.txx:95=
: parse error</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp; before `=3D' token</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>The lines for which it is complaining are:</FONT>
</P>

<P><FONT SIZE=3D2>HistogramType::ConstIterator itr =3D =
histogram-&gt;Begin();</FONT>
<BR><FONT SIZE=3D2>HistogramType::ConstIterator end =3D =
histogram-&gt;End();</FONT>
</P>

<P><FONT SIZE=3D2>Radhika</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Luis Ibanez [<A =
HREF=3D"mailto:luis.ibanez at kitware.com">mailto:luis.ibanez at kitware.com</=
A>] </FONT>
<BR><FONT SIZE=3D2>Sent: Wednesday, February 11, 2004 12:13 PM</FONT>
<BR><FONT SIZE=3D2>To: Radhika Sivaramakrishna</FONT>
<BR><FONT SIZE=3D2>Cc: 'Miller, James V (Research)'; 'ITK'</FONT>
<BR><FONT SIZE=3D2>Subject: Re: Problem with =
HistogramType::ConstIterator inside function</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Hi Radhika,</FONT>
</P>

<P><FONT SIZE=3D2>It will be an extremely generous act on your =
part</FONT>
<BR><FONT SIZE=3D2>to share the text of the error message with =
us.</FONT>
</P>

<P><FONT SIZE=3D2>Our divinatory skill are *very very* limited...&nbsp; =
:-/</FONT>
</P>

<P><FONT SIZE=3D2>Please post the compiler error message that you =
get.</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Thanks</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>&nbsp;&nbsp; Luis</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-------------------------------</FONT>
<BR><FONT SIZE=3D2>Radhika Sivaramakrishna wrote:</FONT>
</P>

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

<P><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT =
SIZE=3D2>-----------------------------------------------------&nbsp; =
</FONT>
<BR><FONT SIZE=3D2>Confidentiality Notice. </FONT>
<BR><FONT SIZE=3D2>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.</FONT></P>

</BODY>
</HTML>
------_=_NextPart_001_01C3F0DB.C831BBF4--