[Insight-users] filter->GetOutput(i) returning NULL
Ramón Casero Cañas
rcasero at gmail.com
Thu Jun 14 13:41:15 EDT 2012
On 14/06/12 18:21, Bradley Lowekamp wrote:
> Hello,
>
> You should look at the different types these methods are returning as
> thy are different an sometime incompatible. The warning message says
> what the problem is:
>
> WARNING: In /usr/local/include/ITK-4.1/itkImageSource.hxx, line 112
> DanielssonDistanceMapImageFilter (0x26707d0): dynamic_cast to output
> type failed
>
> These are the methods you should be come familiar with:
>
> OutputImageType * ImageSource::GetOutput (unsigned int idx)
>
> VectorImageType * DanielssonDistanceMapImageFilter::GetVectorDistanceMap
> (void)
>
>
> Then there is:
> DataObject * ProcessObject::GetOutput (const DataObjectIdentifierType &key)
>
> You can perform a dynamic_cast on the return of the ProcessObject's
> method to the correct image type. It is best to check that the result is
> not NULL in case the dynamic_cast fails.
Hi Brad,
Many thanks for your reply. It's not possible to use
ProcessObject::GetOutput(...) because it's a protected method.
GetVectorDistanceMap() uses a dynamic_cast on
ProcessObject::GetOutput(...), but for my program I cannot depend on
specific method names for each filter.
That's why I was trying to use ImageSource::GetOutput(unsigned int idx),
as it seemed logical that filter->GetOutput(2) would provide the 3rd
output of the filter.
However, as you say, the output type is itk::ImageSource< TOutputImage
>, which is not the type of the VectorDistanceMap. So I don't really
understand what the purpose of ImageSource::GetOutput(unsigned int idx) is.
I think I just found the solution:
this->derivedFilter->GetOutputs()[2].GetPointer()
provides the same pointer as
this->derivedFilter->GetVectorDistanceMap()
Best regards,
Ramon.
--
Dr. Ramón Casero Cañas
Computational Biology
Department of Computer Science
University of Oxford
Wolfson Building, Parks Rd
Oxford OX1 3QD
tlf +44 (0) 1865 610737
web http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas
photos http://www.flickr.com/photos/rcasero/
More information about the Insight-users
mailing list