[Insight-users] runtime warnings when hooking up hessian filter to eigenanalysis2d filter.

Luis Ibanez luis.ibanez at kitware.com
Thu Mar 15 16:44:12 EST 2007


Hi Max,

ImageAdaptors are somehow incompatible with dynamic_cast test.

In general, using dynamic_casts is a violation of the basic principles of
 Generic Programming. However, we have been forced to use it in several
places, for example, when managing itkEventObject.

In the case that you are confronting, the use of ImageAdaptors happens
to be incompatible with the dynamic_casts that the ITK code is attempting.

In order to get rid of the warnings, you may have to use a real ITK Filter
instead of an ImageAdaptor. In that way, the input image to the
EigenAnalysis2DImageFilter will actually correspond to the type that
your are setting in its template parameters.


Another option is for you to modify the code of the EigenAnalysis2DImageFilte
to accept a Hessian image, instead of expecting the three components of the
Hessian to be passed as independent images. For an example on how to do
this, you may want to look at the code of the

Hessian3DToVesselnessMeasureImageFilter

http://public.kitware.com/Insight/Doxygen/html/classitk_1_1Hessian3DToVesselnessMeasureImageFilter.html




      Regards,


           Luis


----------------------------------------------------------------------------------------
On 3/15/07, max power <zouookmoetenwerken at gmail.com> wrote:
> Hello,
>
> In my image processing pipeline, I have to generate the eigenvalues of the
> hessian.  I'm not a long-time ITK user, but I figured the combination of
> Itk::HessianRecursiveGaussianFilter and an itk::EigenAnalysis2DImageFilter
> were the best components to use.  I've put an nth-component adapter
> inbetween to select the right parts of the hessian matrix to feed to the
> three inputs of the eigen analysis filter.
>
> Everything compiles and runs well now, except for a few pesky warnings at
> runtime:
>
> WARNING: In
> /usr/local/include/InsightToolkit/BasicFilters/itkEigenAnalysis2DImageFilter.txx,
> line 133
> ImageToImageFilter (0x689390):
> EigenAnalysis2DImageFilter::GetMaxEigenVector(): dynamic_cast has failed. A
> reinterpret_cast is being attempted.
> Type name is: N3itk5ImageINS_6VectorIfLj2EEELj2EEE
>
> Running this trough demangle with a _Z prepended showed that this was of
> type
> itk::Image<itk::Vector<float, 2u>, 2u>
>
> I feel this has something to do with the floatvectorimage that the
> eigenvalue filter is outputting perhaps, but I cannot find the cause of this
> warning.
>
>
> My current processing pipeline is as follows:
>
>
> typedef float FloatPixelType;
>
> typedef itk::Image<FloatPixelType, Dimension> FloatImageType;
>
> typedef itk::HessianRecursiveGaussianImageFilter<
> FloatImageType> HessianFilter;
>
> typedef itk::Image<
> itk::Vector< FloatPixelType, 2 >,
> Dimension > FloatVectorImageType;
>
> typedef itk::EigenAnalysis2DImageFilter<
> FloatImageType,
> FloatImageType,
> FloatVectorImageType> EigenAnalysis2DImageFilterType;
>
> // to make the output of the hessian filter readable by the
> // eigenanalysis filter, we need to adapt the image
> typedef itk::NthElementPixelAccessor<
> FloatPixelType,
> HessianFilter::OutputPixelType > OutputImageAdaptorType;
>
> typedef itk::AdaptImageFilter<
> HessianFilter::OutputImageType,
> FloatImageType,
> OutputImageAdaptorType > AdaptType;
>
>
> // the hessian filter is hooked up to the original input filter
> HessianFilter::Pointer hesFilter = HessianFilter::New();
> hesFilter->SetInput( readCast->GetOutput() );
>
> EigenAnalysis2DImageFilterType::Pointer eigFilter =
> EigenAnalysis2DImageFilterType::New();
>
> // make the three components of the hessian to the eigFilter
> AdaptType::Pointer adapterE0 = AdaptType::New();
> adapterE0->SetInput( hesFilter->GetOutput() );
> adapterE0->GetAccessor().SetElementNumber( 0 );
>
> AdaptType::Pointer adapterE1 = AdaptType::New();
> adapterE1->SetInput( hesFilter->GetOutput() );
> adapterE1->GetAccessor().SetElementNumber( 1 );
>
> AdaptType::Pointer adapterE2 = AdaptType::New();
> adapterE2->SetInput( hesFilter->GetOutput() );
> adapterE2->GetAccessor().SetElementNumber( 2 );
>
> // and hook up the adapted images to the eigen analysis filter.
> eigFilter->SetInput1( adapterE0->GetOutput() );
> eigFilter->SetInput2( adapterE1->GetOutput() );
> eigFilter->SetInput3( adapterE2->GetOutput() );
>
>
> And then the eigFilter's getOutput(0) and getOutput(1) are used in further
> processing.
>
> I hope someone can help to shed some light on these warnings.
>
> Thanks,
> Jorik
>


More information about the Insight-users mailing list