# Add a rigid transform and a deformable transform together

**URL:** https://discourse.itk.org/t/add-a-rigid-transform-and-a-deformable-transform-together/4083
**Category:** Algorithms
**Created:** [April 29, 2021, 6:32am UTC](https://discourse.itk.org/t/add-a-rigid-transform-and-a-deformable-transform-together/4083 "2021-04-29T06:32:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hfeng](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/b5ac83/32.png) [@hfeng](https://discourse.itk.org/u/hfeng)
#### Post date: [April 29, 2021, 6:32am UTC](https://discourse.itk.org/t/add-a-rigid-transform-and-a-deformable-transform-together/4083/1 "2021-04-29T06:32:51Z")

</div>

I am trying to do a image registration that consists of two stages.  
The first stage is selected to be Versor3DRigid and the second stage is selected to be Demons.  
The first stage can give a transform, the second stage can give me a deformation field that can be changed to a displacement field transform by using itkDisplacementFieldTransform. I am trying to add these two transforms together by using itkCompositeTransform. But an error message is given:  
"  
no matching function for call to ‘itk::CompositeTransform\<double, 3\>::AddTransform(itk::SmartPointer\<itk::DisplacementFieldTransform\<float, 3\> \>&)  
"  
Is there a way to achieve this goal of adding these two transforms together?  
Thanks.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 29, 2021, 12:31pm UTC](https://discourse.itk.org/t/add-a-rigid-transform-and-a-deformable-transform-together/4083/2 "2021-04-29T12:31:04Z")

</div>

What happens if instead of `compositeTransform->AddTransform(displacementFieldTransform);` you call `compositeTransform->AddTransform(displacementFieldTransform.GetPointer());`?

---

<div class="post-metadata">

### Author: ![hfeng](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/b5ac83/32.png) [@hfeng](https://discourse.itk.org/u/hfeng)
#### Post date: [May 4, 2021, 11:47pm UTC](https://discourse.itk.org/t/add-a-rigid-transform-and-a-deformable-transform-together/4083/3 "2021-05-04T23:47:31Z")

</div>

I bypassed this problem by change the transform to a deformation field and used itk::AddImageFilter to add the deformation fields together.  
Thanks.
