[Insight-users] Question regarding BSplineScatteredDataPointSetToImageFilter

Kerstin Müller kerstin.mueller612 at googlemail.com
Fri Dec 23 04:19:23 EST 2011


Hi,

I'm using the *BSplineScatteredDataPointSetToImageFilter *from the Insight
Journal. However,
I cannot find the correct parameter in order to make the filter work and
does not crash during the evaluation.
I'll have scattered 3-D points over time and I want to fit a 4-D Bspline
field to that points. Afterwards I want to evaluate the Bspline on a dense
volume grid to one time step.

Here you can find the code, unfortunately it crashes (either due to memory
problems or without any error output)


const unsigned int ParametricDimension = 4;
    const unsigned int DataDimension = 3;

    typedef double RealType;
    typedef itk ::Vector <RealType , DataDimension > VectorType;
    typedef itk ::Image <VectorType , ParametricDimension > ImageType;

    typedef itk :: PointSet <VectorType , ParametricDimension >
PointSetType ;
    PointSetType :: Pointer pointSet = PointSetType :: New ();

    // Set the sample points
    for ( int img_num = 0; img_num < m_configuration.num_projections ;
img_num++ )
    {
        int num = 0;
        for( int idx = 0; idx <= points.at(img_num).size()-3; idx+=3 )
        {

            VectorType v;
            v[0] = points.at(img_num)[idx];
            v[1] = points.at(img_num)[idx+1];
            v[2] = points.at(img_num)[idx+2];
            pointSet->SetPointData(num, v);

            num++;

        }
    }
    // Instantiate the filter and set the parameters
    typedef itk::myBSplineScatteredDataPointSetToImageFilter<PointSetType ,
ImageType > FilterType;
    FilterType :: Pointer filter = FilterType :: New ();

    // Define the parametric domain
    ImageType :: SpacingType spacing;
    spacing[0] = 42.0f;
    spacing[1] = 42.0f;
    spacing[2] = 42.0f;
    spacing[3] = 2.0f;
    ImageType :: SizeType size;
    size[0] = 6;
    size[1] = 6;
    size[2] = 6;
    size[3] = 67;
    ImageType :: PointType origin;
    origin.Fill( 0.0 );

    filter ->SetSize( size );
    filter ->SetOrigin( origin );
    filter ->SetSpacing( spacing );
    filter ->SetInput( pointSet );

    filter -> SetSplineOrder ( 3 );
    FilterType :: ArrayType ncps;
    ncps.SetElement(0,6);
    ncps.SetElement(1,6);
    ncps.SetElement(2,6);
    ncps.SetElement(3,67);

    filter -> SetNumberOfControlPoints ( ncps );
    filter -> SetNumberOfLevels ( 5 );
    filter -> SetGenerateOutputImage ( false );

    try
    {
        filter ->Update ();
    }
    catch ( itk::ExceptionObject & excp )
    {
        std :: cerr << "Test 2: itkBSplineScatteredDataImageFilter
exception thrown" << std:: endl;
        std::cerr<< excp <<std::endl;
    }

Thank you for your help!

Best,

Kerstin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111223/edcea4dd/attachment.htm>


More information about the Insight-users mailing list