[Insight-users] Re: GetOutput() : not an itkImage method

Luis Ibanez luis.ibanez at kitware.com
Mon, 19 Jan 2004 11:48:18 -0500


Hi David,

Then problem is that "GetOutput()" is not
a method of the itk::Image class.

You typically invoke GetOutput() on ITK
filters in order to get the itk::Images
they generate as output.

In your case, you should use simply
a const raw pointer to the image. You
don't even need a SmartPointer.

The signature of the function should be

   unsigned long *
   imhist (const RGBImageType * NomFich, colorRGB color) {

instead of the current:

   unsigned long *
   imhist (RGBImageType::Pointer NomFich, colorRGB color) {

The image pointer must be const because you
are just computing the image histogram, so
there is no reason for the function to modify
the image internal data.

The call for the histogram generator will be

   histogramGenerator->SetInput(  NomFich  );

instead of the erroneous:

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


Note that "NomFich" is a very missleading name
for a variable that holds a pointer to an image.
Keep in mind that variable names are probably
the most important implicit documentation of
your code. I would suggest you to use something
like "inputImage" or "inputRGBImage".


Regards,


   Luis


--------------------
David Llanos wrote:

> hi Luis,
>  
> I have a problem when I compile my program with the member GetOutput() 
> in a function. This is the code:
>  
> ----------------------------------------------------------------------------------------------------------
> unsigned long * imhist (RGBImageType::Pointer NomFich, colorRGB color) {
>   SizeType size;
>   unsigned int channel = 0;
>   if (color==VERDE) {
>   channel = 1 ;  // Canal Verde
>   size[0] =   1;  // Numero de bins del canal Rojo
>   size[1] = 255;  // Numero de bins del canal Verde
>   size[2] =   1;  // Numero de bins del canal Azul
>   }
>   if (color==AZUL) {
>   channel = 2 ;  // Canal Azul
>   size[0] =   1;  // Numero de bins del canal Rojo
>   size[1] =   1;  // Numero de bins del canal Verde
>   size[2] = 255;  // Numero de bins del canal Azul
>   }
>   // Creamos el puntero generador del histograma
>   HistogramGeneratorType::Pointer histogramGenerator = 
> HistogramGeneratorType::New();
>   // Colocamos la imagen obtenida en nuestro puntero
>  
> 
>   histogramGenerator->SetInput(  NomFich  ->GetOutput() );   // *** 
> ERROR ***
>  
>  
>   histogramGenerator->SetNumberOfBins( size );
>   histogramGenerator->SetMarginalScale( 10.0 );
>   histogramGenerator->Compute();
>   const HistogramType * histogram = histogramGenerator->GetOutput();
>   const unsigned int histogramSize = histogram->Size();
>   std::cout << "Tamano del histograma " << histogramSize << std::endl;
>   histogramGenerator->SetNumberOfBins( size );
>   histogramGenerator->SetMarginalScale( 10.0 );
>   histogramGenerator->Compute();
>   unsigned long * Histograma;
>   for( unsigned int bin=0; bin < histogramSize; bin++ )
>     Histograma[bin]=histogram->GetFrequency( bin, channel );
>   return(Histograma);
> }
> -----------------------------------------------------------------------------------------------------------
> error C2039: 'GetOutput' : is not a member of 'Image<class 
> itk::RGBPixel<unsigned char>,2>'
> ----------------------------------------------------------------------------------------------------------------------------
>  
> and in the Main program:
> ----------------------------------------
> unsigned long * hist;
> hist = imhist(imgEspermasRGB,VERDE);
> ---------------------------------------
> and the definition:
>         unsigned long * imhist (RGBImageType::Pointer , colorRGB );
>  
>  
> Do you know what's the matter?
>  
> Thanks in advange and regards.
>  
>  
> 
>  
>  
>