# Using Displacement Map to Deform or Morph a Segment/Model

**URL:** <https://discourse.slicer.org/t/using-displacement-map-to-deform-or-morph-a-segment-model/18552>\
**Category:** Support\
**Created:** [July 7, 2021, 3:12am UTC](https://discourse.slicer.org/t/using-displacement-map-to-deform-or-morph-a-segment-model/18552 "2021-07-07T03:12:48Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Fluvio\_Lobo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fluvio_lobo/32/81262_2.png) [@Fluvio\_Lobo](https://discourse.slicer.org/u/Fluvio_Lobo)\
**Post date:** [July 13, 2021, 2:31am UTC](https://discourse.slicer.org/t/using-displacement-map-to-deform-or-morph-a-segment-model/18552/3 "2021-07-13T02:31:20Z")

</div>

@lassoan,

I found [this post](https://discourse.slicer.org/t/merge-scalars-of-two-models/15682/3) and I am trying to repeat the process;

First, I ran **Model To Model Distance** and created `D_rev2orig` as the “displacement model”  
Additionally, I have a “target” model `D_ST` which I would like to warp/deform.

 ![figure_disp_map](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/9/69b428da699103a73f84737b3763eb520d7052b4.jpeg)  
 ![figure_skin_model](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/e/fe251c1a674b401d1e320c78e8b1b31288ccd34a.png)

Here is what I am doing to warp the “target” model;

```auto
dispModel = getNode("D_rev2orig")
targetModel = getNode("D_ST")

dispMesh = dispModel.GetMesh()
dispMesh.GetPointData().SetActiveVectors("PointToPointVector")

warp = vtk.vtkWarpVector()
warp.SetInputData(dispMesh)

warp.SetScaleFactor(1.0)
warp.Update()
targetModel.SetPolyDataConnection(warp.GetOutputPort())

```

This overrides the `D_ST` “target” model and generates a weird hybrid model;

 ![figure_output_warp](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/d/5d8ddb90d0e2a4b6dc39268782e2c08dbff350bb.jpeg)

This model has the `PointToPointVector` attribute from the displacement model `D_rev2orig`, but does not have the geometry of the “target” model. The geometry is not the same as the “displacement model” however, so maybe I am just missing something in the script above?

---

_[View the full topic](https://discourse.slicer.org/t/using-displacement-map-to-deform-or-morph-a-segment-model/18552)._
