[Insight-users] Compilation error with inPlace filters

Radhika Sivaramakrishna radhika.sivaramakrishna at synarc.com
Mon, 9 Feb 2004 10:39:06 -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_000_01C3EF3B.FF748F66
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C3EF3B.FF748F66"


------_=_NextPart_001_01C3EF3B.FF748F66
Content-Type: text/plain

Hi Luis,
I actually did the checkout this morning and I did see the Dashboard was
pretty green. I don't know if I am making a silly mistake or a more serious
error.
I have copied my code here which doesn't compile and gives the error
indicated below. I think the problem has something to do with the
IntImageType I put in for dealing with the Relabel.. filter. 

Sorry about not putting the correct subject. Will try to make sure to do it
from now on.

Radhika


-----Original Message-----
From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
Sent: Monday, February 09, 2004 10:34 AM
To: Radhika Sivaramakrishna
Cc: ITK
Subject: Re: [Insight-users] Compilation error with inPlace filters


Hi Radhika,


A number of changes were made last week for extending
the functionality of "InPlace" filters.

You probably updated your checkout in the middle of
one of such modifications.  Please trying cvs updating
to this morning (since the nightly Dashboard was quite
green today).


  Regards,


     Luis,


PS. Please don't reuse email threads with other subjects when
      you post questions about new topics/problems. This is
     confusing for anybody trying to follow a thread.


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

> Hi Luis,
> I am getting this very strange error message while compiling. Can you 
> explain what this could be?
>
> /home/rsivaram/Insight/Code/Common/itkInPlaceImageFilter.txx: In member
>    function `void itk::InPlaceImageFilter<TInputImage,
>    TOutputImage>::AllocateOutputs() [with TInputImage = main(int,
>    char**)::IntImageType, TOutputImage = main(int, char**)::ImageType]':
> /home/rsivaram/Insight/Code/Common/itkImageRegion.h:173:   
> instantiated from here
> /home/rsivaram/Insight/Code/Common/itkInPlaceImageFilter.txx:76: no 
> matching
>    function for call to `itk::InPlaceImageFilter<main(int,
>    char**)::IntImageType, main(int, 
> char**)::ImageType>::GraftOutput(main(int,
>    char**)::IntImageType*)'
> /home/rsivaram/Insight/Code/Common/itkImageSource.txx:95: candidates 
> are: void
>    itk::ImageSource<TOutputImage>::GraftOutput(TOutputImage*) [with
>    TOutputImage = main(int, char**)::ImageType]
>
>
> 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.
  


------_=_NextPart_001_01C3EF3B.FF748F66
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: [Insight-users] Compilation error with inPlace =
filters</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Hi Luis,</FONT>
<BR><FONT SIZE=3D2>I actually did the checkout this morning and I did =
see the Dashboard was pretty green. I don't know if I am making a silly =
mistake or a more serious error.</FONT></P>

<P><FONT SIZE=3D2>I have copied my code here which doesn't compile and =
gives the error indicated below. I think the problem has something to =
do with the IntImageType I put in for dealing with the Relabel.. =
filter. </FONT></P>

<P><FONT SIZE=3D2>Sorry about not putting the correct subject. Will try =
to make sure to do it from now on.</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: Monday, February 09, 2004 10:34 AM</FONT>
<BR><FONT SIZE=3D2>To: Radhika Sivaramakrishna</FONT>
<BR><FONT SIZE=3D2>Cc: ITK</FONT>
<BR><FONT SIZE=3D2>Subject: Re: [Insight-users] Compilation error with =
inPlace filters</FONT>
</P>
<BR>

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

<P><FONT SIZE=3D2>A number of changes were made last week for =
extending</FONT>
<BR><FONT SIZE=3D2>the functionality of &quot;InPlace&quot; =
filters.</FONT>
</P>

<P><FONT SIZE=3D2>You probably updated your checkout in the middle =
of</FONT>
<BR><FONT SIZE=3D2>one of such modifications.&nbsp; Please trying cvs =
updating</FONT>
<BR><FONT SIZE=3D2>to this morning (since the nightly Dashboard was =
quite</FONT>
<BR><FONT SIZE=3D2>green today).</FONT>
</P>
<BR>

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

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

<P><FONT SIZE=3D2>PS. Please don't reuse email threads with other =
subjects when</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; you post questions =
about new topics/problems. This is</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; confusing for anybody =
trying to follow a thread.</FONT>
</P>
<BR>

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

<P><FONT SIZE=3D2>&gt; Hi Luis,</FONT>
<BR><FONT SIZE=3D2>&gt; I am getting this very strange error message =
while compiling. Can you </FONT>
<BR><FONT SIZE=3D2>&gt; explain what this could be?</FONT>
<BR><FONT SIZE=3D2>&gt;</FONT>
<BR><FONT SIZE=3D2>&gt; =
/home/rsivaram/Insight/Code/Common/itkInPlaceImageFilter.txx: In =
member</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp; function `void =
itk::InPlaceImageFilter&lt;TInputImage,</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp; =
TOutputImage&gt;::AllocateOutputs() [with TInputImage =3D =
main(int,</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp; char**)::IntImageType, =
TOutputImage =3D main(int, char**)::ImageType]':</FONT>
<BR><FONT SIZE=3D2>&gt; =
/home/rsivaram/Insight/Code/Common/itkImageRegion.h:173:&nbsp;&nbsp; =
</FONT>
<BR><FONT SIZE=3D2>&gt; instantiated from here</FONT>
<BR><FONT SIZE=3D2>&gt; =
/home/rsivaram/Insight/Code/Common/itkInPlaceImageFilter.txx:76: no =
</FONT>
<BR><FONT SIZE=3D2>&gt; matching</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp; function for call to =
`itk::InPlaceImageFilter&lt;main(int,</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp; char**)::IntImageType, =
main(int, </FONT>
<BR><FONT SIZE=3D2>&gt; =
char**)::ImageType&gt;::GraftOutput(main(int,</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp; =
char**)::IntImageType*)'</FONT>
<BR><FONT SIZE=3D2>&gt; =
/home/rsivaram/Insight/Code/Common/itkImageSource.txx:95: candidates =
</FONT>
<BR><FONT SIZE=3D2>&gt; are: void</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp; =
itk::ImageSource&lt;TOutputImage&gt;::GraftOutput(TOutputImage*) =
[with</FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp;&nbsp;&nbsp; TOutputImage =3D main(int, =
char**)::ImageType]</FONT>
<BR><FONT SIZE=3D2>&gt;</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;</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>

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

<P><FONT FACE=3D"Arial" SIZE=3D2 COLOR=3D"#000000"></FONT>&nbsp;

</BODY>
</HTML>
------_=_NextPart_001_01C3EF3B.FF748F66--

------_=_NextPart_000_01C3EF3B.FF748F66
Content-Type: application/octet-stream;
	name="HistogramThreshold.cxx"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="HistogramThreshold.cxx"

#include "itkScalarImageToHistogramGenerator.h"
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkMaskImageFilter.h"
#include "itkImageFileWriter.h"
#include "itkBinaryThresholdImageFilter.h"
#include "itkHistogram.h"
#include "itkConnectedComponentImageFilter.h"
#include "itkRelabelComponentImageFilter.h"
#include "itkBinaryErodeImageFilter.h"
#include "itkBinaryDilateImageFilter.h"
#include "itkBinaryBallStructuringElement.h"

int main( int argc, char * argv [] )
{

  if( argc < 2 )
    {
    std::cerr << "Missing command line arguments" << std::endl;
    std::cerr << "Usage :  ImageHistogram1  inputImageFileName =
inputMaskFileName " << std::endl;
    return -1;
    }

  typedef unsigned char      PixelType;
  typedef int        		  IntType;
  const unsigned int          Dimension =3D 3;

  typedef itk::Image<PixelType, Dimension > ImageType;
  typedef itk::Image<IntType, Dimension > IntImageType;

  typedef itk::Image<PixelType, Dimension > ImageType;
  typedef itk::ImageFileReader< ImageType > ReaderType;
  typedef itk::ImageFileWriter< CharImageType > WriterType;
  typedef itk::MaskImageFilter<ImageType,ImageType,ImageType> =
MaskFilterType;
  typedef itk::BinaryThresholdImageFilter<ImageType, ImageType> =
BinaryThresholdFilterType;
  typedef itk::ImageRegionConstIteratorWithIndex< ImageType > =
ConstIteratorType;
  typedef itk::ImageRegionIteratorWithIndex< ImageType > IteratorType;
=0A=
=0A=

  typedef itk::BinaryBallStructuringElement<
                        PixelType,
                        Dimension  >             =
StructuringElementType;

  typedef itk::BinaryErodeImageFilter<
                              ImageType,
                              ImageType,
                              StructuringElementType>  ErodeFilterType;

  typedef itk::BinaryDilateImageFilter<
                              ImageType,
                              ImageType,
                            StructuringElementType >  DilateFilterType;

  typedef itk::ConnectedComponentImageFilter<ImageType,IntImageType > =
CCFilterType;
  typedef itk::RelabelComponentImageFilter<IntImageType,ImageType > =
RCFilterType;

  MaskFilterType::Pointer masker =3D MaskFilterType::New();
  BinaryThresholdFilterType::Pointer thresholdermask =3D =
BinaryThresholdFilterType::New();

  ReaderType::Pointer readerimage =3D ReaderType::New();
  ReaderType::Pointer readermask =3D ReaderType::New();
  WriterType::Pointer writer =3D WriterType::New();
  CCFilterType::Pointer ccfilter =3D CCFilterType::New();
  RCFilterType::Pointer rcfilter =3D RCFilterType::New();
  ErodeFilterType::Pointer  binaryErode  =3D ErodeFilterType::New();
  DilateFilterType::Pointer binaryDilate =3D DilateFilterType::New();

  PixelType background =3D   0;
  PixelType foreground =3D 255;

  StructuringElementType structuringElement;
  structuringElement.SetRadius( 1 );  // 3x3 structuring element

  structuringElement.CreateStructuringElement();

  binaryErode->SetKernel(  structuringElement );
  binaryDilate->SetKernel( structuringElement );
  binaryErode->SetErodeValue(foreground);
  binaryDilate->SetDilateValue(foreground);

  thresholdermask->SetOutsideValue( background );
  thresholdermask->SetInsideValue(  foreground );


  readerimage->SetFileName( argv[1] );

  try
    {
    readerimage->Update();
    }
  catch( itk::ExceptionObject & excp )
    {
    std::cerr << "Problem encoutered while reading image file : " << =
argv[1] << std::endl;
    std::cerr << excp << std::endl;
    return -1;
    }

  readermask->SetFileName( argv[2] );

  try
    {
    readermask->Update();
    }
  catch( itk::ExceptionObject & excp )
    {
    std::cerr << "Problem encoutered while reading image file : " << =
argv[1] << std::endl;
    std::cerr << excp << std::endl;
    return -1;
    }

  std::cout << " Completed reading input images " << std::endl;
  readerimage->Update();
  readermask->Update();
  ImageType::Pointer image =3D readerimage->GetOutput();
  ImageType::Pointer mask =3D readermask->GetOutput();

  typedef itk::Statistics::ScalarImageToHistogramGenerator<
                                                    ImageType
                                                          >   =
HistogramGeneratorType;

  HistogramGeneratorType::Pointer histogramGenerator =3D =
HistogramGeneratorType::New();

  masker->SetInput1(readerimage->GetOutput());
  masker->SetInput2(readermask->GetOutput());
  masker->Update();

  histogramGenerator->SetInput(  masker->GetOutput() );

  histogramGenerator->SetNumberOfBins( 128 );
  histogramGenerator->SetMarginalScale( 10.0 );
  histogramGenerator->Compute();

  typedef HistogramGeneratorType::HistogramType  HistogramType;

  const HistogramType * histogram =3D histogramGenerator->GetOutput();

  const unsigned int histogramSize =3D histogram->Size();

  std::cout << "Histogram size " << histogramSize << std::endl;

 /* for( unsigned int bin=3D0; bin < histogramSize; bin++ )
    {
    std::cout << "bin =3D " << bin << " frequency =3D ";
    std::cout << histogram->GetFrequency( bin, 0 ) << std::endl;
    } */


  HistogramType::ConstIterator itr =3D histogram->Begin();
  HistogramType::ConstIterator end =3D histogram->End();

  unsigned int bin =3D 1;
  unsigned long totalhist =3D 0;
  ++itr; // To skip the zero count
  while( itr !=3D end )
      {
    //  std::cout << "bin =3D " << bin << " frequency =3D ";
    //  std::cout << itr.GetFrequency() << std::endl;
      totalhist +=3D itr.GetFrequency();
      ++itr;
      ++bin;
      }
  std::cout << " Total " << totalhist << std::endl;
 // std::cout << " Total frequency " << histogram->GetTotalFrequency() =
<< std::endl;
//  std::cout << " Quantile at 90th percentile " << =
histogram->Quantile(0,0.90) << std::endl;

  unsigned long probability =3D 0;
  unsigned int threshold;
  bin=3D1;
  itr =3D histogram->Begin();
  ++itr; // To skip the zero count
  while( (itr !=3D end) && (probability <=3D 0.90*totalhist ))
      {
      std::cout << "bin =3D " << bin << " frequency =3D ";
      probability +=3D itr.GetFrequency();
      std::cout << probability << std::endl;
      threshold =3D bin*2;
      ++itr;
      ++bin;
      }

  std::cout << " Threshold value " << threshold << std::endl;
  std::cout << " Probability value " << probability << std::endl;

  ImageType::RegionType region =3D image->GetBufferedRegion();
  IteratorType maskit(mask,region);
  ConstIteratorType gsit(image,region);

  gsit.GoToBegin();
  maskit.GoToBegin();
  while( ! gsit.IsAtEnd() && ! maskit.IsAtEnd())
    {
  	if (gsit.Get() > threshold)
  	{
  		maskit.Set(0);
  	}
  	++maskit;
  	++gsit;
  }
  binaryErode->SetInput(mask);
  ccfilter->SetInput(binaryErode->GetOutput());
  rcfilter->SetInput(ccfilter->GetOutput());
  rcfilter->Update();

  thresholdermask->SetInput( rcfilter->GetOutput() );
  thresholdermask->SetLowerThreshold( 1 );
  thresholdermask->SetUpperThreshold( 1 );
  binaryDilate->SetInput(thresholdermask->GetOutput());
  writer->SetFileName("finalmask.img");
  writer->SetInput(binaryDilate->GetOutput());
  writer->Update();

  return 0;

}



------_=_NextPart_000_01C3EF3B.FF748F66--