[Insight-users] Re: GetOutput() : not an itkImage method
Luis Ibanez
luis.ibanez at kitware.com
Mon, 19 Jan 2004 12:47:11 -0500
Hi David,
If you get a link error it is likely
that the implementation of the function
was not recompiled using the new signature.
Did you recompiled the file where the
function is implemented ?
Please do a Rebuild_All in your
project. (or clean and then build).
Regards,
Luis
-----------------------------------
David wrote:
> Very thanks for your help.
>
> But with this modify, I get a new error in the linking:
>
> procesadorImagenEsperma.obj : error LNK2001: unresolved external symbol
> "private: unsigned long * __thiscall ProcesadorImagenEspermas::imhist(class
> itk::Image<class itk::RGBPixel<unsigned char>,2> const *,enum colorRGB)"
> (?imhist at ProcesadorImagenEsp
> ermas at at AAEPAKPBV?$Image at V?$RGBPixel at E at itk at at $01 at itk at at W4colorRGB at at at Z)
> Debug/clasificaEsperma.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
>
> What's the matter now?
>
> very thanks, Luis.
>
> ----- Original Message -----
> From: "Luis Ibanez" <luis.ibanez at kitware.com>
> To: "David Llanos" <gva02 at elai.upm.es>
> Cc: <Insight-users at itk.org>
> Sent: Monday, January 19, 2004 5:48 PM
> Subject: Re: GetOutput() : not an itkImage method
>
>
>
>>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.
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>
>
>