Hi,<br><br>I'm using the <b>BSplineScatteredDataPointSetToImageFilter </b>from the Insight Journal. However,<br>I cannot find the correct parameter in order to make the filter work and does not crash during the evaluation.<br>
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.<br><br>Here you can find the code, unfortunately it crashes (either due to memory problems or without any error output)<br>
<br><br>const unsigned int ParametricDimension = 4;<br> const unsigned int DataDimension = 3;<br><br> typedef double RealType;<br> typedef itk ::Vector <RealType , DataDimension > VectorType;<br> typedef itk ::Image <VectorType , ParametricDimension > ImageType;<br>
<br> typedef itk :: PointSet <VectorType , ParametricDimension > PointSetType ;<br> PointSetType :: Pointer pointSet = PointSetType :: New ();<br> <br> // Set the sample points<br> for ( int img_num = 0; img_num < m_configuration.num_projections ; img_num++ ) <br>
{<br> int num = 0;<br> for( int idx = 0; idx <= <a href="http://points.at">points.at</a>(img_num).size()-3; idx+=3 )<br> {<br> <br> VectorType v;<br> v[0] = <a href="http://points.at">points.at</a>(img_num)[idx];<br>
v[1] = <a href="http://points.at">points.at</a>(img_num)[idx+1];<br> v[2] = <a href="http://points.at">points.at</a>(img_num)[idx+2];<br> pointSet->SetPointData(num, v);<br><br> num++;<br>
<br> }<br> }<br> // Instantiate the filter and set the parameters<br> typedef itk::myBSplineScatteredDataPointSetToImageFilter<PointSetType , ImageType > FilterType;<br> FilterType :: Pointer filter = FilterType :: New ();<br>
<br> // Define the parametric domain<br> ImageType :: SpacingType spacing; <br> spacing[0] = 42.0f;<br> spacing[1] = 42.0f;<br> spacing[2] = 42.0f;<br> spacing[3] = 2.0f;<br> ImageType :: SizeType size; <br>
size[0] = 6;<br> size[1] = 6;<br> size[2] = 6;<br> size[3] = 67;<br> ImageType :: PointType origin; <br> origin.Fill( 0.0 );<br><br> filter ->SetSize( size );<br> filter ->SetOrigin( origin );<br>
filter ->SetSpacing( spacing );<br> filter ->SetInput( pointSet );<br><br> filter -> SetSplineOrder ( 3 );<br> FilterType :: ArrayType ncps;<br> ncps.SetElement(0,6);<br> ncps.SetElement(1,6);<br>
ncps.SetElement(2,6);<br> ncps.SetElement(3,67);<br><br> filter -> SetNumberOfControlPoints ( ncps );<br> filter -> SetNumberOfLevels ( 5 );<br> filter -> SetGenerateOutputImage ( false );<br><br>
try<br> {<br> filter ->Update ();<br> }<br> catch ( itk::ExceptionObject & excp )<br> {<br> std :: cerr << "Test 2: itkBSplineScatteredDataImageFilter exception thrown" << std:: endl;<br>
std::cerr<< excp <<std::endl;<br> }<br><br>Thank you for your help!<br><br>Best,<br><br>Kerstin<br>