[Insight-users] itkWarpImageFilter
Luis Ibanez
luis.ibanez at kitware.com
Wed May 10 09:21:39 EDT 2006
Hi Markus,
The multiplication of the vector values seems to be ok in your code,
what is suspicious is the way in which you save the warped images.
I will suggest you to first save the intermediate deformation fields
in MetaImage format and try to read those files with Paraview
http://www.paraview.org
With that, you will be able to verify if your multiplication of the
deformation field is working as expected.
If so, you can also put an ImageFileWriter inside the loop in order
to save the wrapped image. Something like
for( step.... )
...
fieldWriter->SetInput( intermediateField );
fieldWriter->SetFileName("fieldN.mhd"); // use here a sprintf %d
warpFilter->SetDeformationField( intermediateField );
warpFilter->Update();
warpedImage = warpFilter->GetOutput();
imageWriter->SetInput( warpedImage );
imageWriter->SetFileName( "imageN.mhd" ); // use a sprintf %d
imageWriter->Update();
...
Right know you seem to be delegating that the demonsImage class
whose code is not posted in your email.
A common mistake is to forget that you are reusing the smart
pointer of the wrapped image inside your loop, and if you are
simply gathering such pointers in list, at the end all of them
will be assigned to the same image (the last one).
Please try writing the deformation fields and the deformed
images as you go inside the "step" loop. That will help you to
identify what may be working wrong.
Please let us know what you find,
Thanks,
Luis
======================
Markus Losacker wrote:
> Hi Luis,
>
> thanks for your help! I tried to scale the deformation field by a
> weighting factor, but all my warped images are the same.
> Here is my code:
>
> ConstDeformationIteratorType inputIt(
> replacementField, deformationRegion );
> *for*(step = 1; step <= warpSteps; step++)
> {
> *if* (step == 1 || step == warpSteps)
> {
> }
> *else* {
> warpWeight = *static_cast*<double>(step) /
> warpSteps;
> cerr << "weight = " << warpWeight << endl;
> dest = sliceSize * (begin + (step-1));
> cerr << "step" << step << endl;
> DeformationIteratorType outputIt(
> intermediateField, deformationRegion);
> *for*(inputIt.GoToBegin(),
> outputIt.GoToBegin(); !inputIt.IsAtEnd(); ++inputIt, ++outputIt)
> {
> outputIt.Set( inputIt.Get() * warpWeight );
> }
> warpFilter->SetDeformationField(
> intermediateField );
> warpFilter->Update();
> warpedImage = warpFilter->GetOutput();
> warpedImage->Update();
> cerr << "warp updated" << endl;
> demonImage = mitk::Image::New();
> ///conatains the warpedImage/
> demonImage->InitializeByItk(&(*warpedImage),
> 1, -1, -1);
> cerr << "initialized" << end;
>
> demonImage->SetVolume(warpedImage->GetBufferPointer());
> cerr << "volume set" << endl;
> warpedVtkData = vtkImageData :: New();
> warpedVtkData =
> demonImage->GetVtkImageData(0,0);
> warpedData = warpedVtkData->GetScalarPointer();
> shortWarpedData = *static_cast*<short
> *>(demonImage->GetData());
> cerr << "warpeddatawritten" << endl;
>
> *for* (sliceCopy_y = 0; sliceCopy_y < y_max;
> sliceCopy_y++)
> {
> *for* (sliceCopy_x = 0; sliceCopy_x <
> x_max; sliceCopy_x++)
> {
>
> doubleContourData[sliceCopy_x +
> (x_max*sliceCopy_y) + ( (begin +( step-1 ) ) * sliceSize ) ] =
> shortWarpedData[sliceCopy_x + (x_max*sliceCopy_y)];
> }
> }
>
> /// /
> cerr << "deleted " << endl;
> cerr << " " << endl;
> }
> }
>
> Best Regards
>
> Markus
>
>
>
>
>
> Luis Ibanez wrote:
>
>> Hi Markus,
>>
>> If you already solved the deformable registration problem between your
>> fixed and moving images, and have at hand the resulting deformation
>> field, you can generate the intermediate version of the deformed moving
>> image by taking the deformation field and multiplying it with a number
>> between 0.0 and 1.0, then using the resulting vector field in the Warp
>> ImageFilter.
>>
>>
>> In pseudocode it will look like
>>
>> for i = 1 to 10
>> {
>> intermediateField = deformationField * i / 10.0
>> intermediateImage = Warp( movingimage, intermediateFiedl )
>> }
>>
>> Please let us know if you need more details on how to implement this
>> code.
>>
>>
>> Regards,
>>
>>
>> Luis
>>
>>
>>
>> -----------------------
>> Markus Losacker wrote:
>>
>>> Hi all,
>>>
>>> I´m new to ITK. I have 3D MRI Data, wich is segmented in some
>>> parallel slices. Each segemted slice is a 2D binary image. I´d like
>>> to Iterpolize these slices to a 3D binary image.
>>> I tried it with the demonsRegistration and the warpImageFilter and I
>>> got it running. My problem is that I can only Interpolize one slice
>>> between some slices. Is there the possibility to interpolize several
>>> images between a moving and a fixed image with the same deformation
>>> field?
>>> The output should be something like a sequence from the fixed to the
>>> moving image.
>>>
>>> Best Regards
>>>
>>> Markus
>>>
>>>
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list