# 2D to 3D Registration

**URL:** https://discourse.itk.org/t/2d-to-3d-registration/2112
**Category:** Beginner Questions
**Created:** [July 31, 2019, 3:34pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112 "2019-07-31T15:34:48Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![svabhishek29](https://discourse.itk.org/user_avatar/discourse.itk.org/svabhishek29/32/926_2.png) [@svabhishek29](https://discourse.itk.org/u/svabhishek29)
#### Post date: [July 31, 2019, 3:34pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/1 "2019-07-31T15:34:48Z")

</div>

hi,

i was looking an example for registration of 2D images with 3D images, i can’t find any examples on this topic.

can someone please direct me to an example or a library that can do this

Thanks

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [July 31, 2019, 3:56pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/2 "2019-07-31T15:56:34Z")

</div>

Hi @svabhishek29,

Welcome to the ITK community! ☀

The ITKTwoProjectionRegistration module can be used:

> **[InsightSoftwareConsortium/ITKTwoProjectionRegistration](https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration)**
>
> ITK-Based Implementation of Two-Projection 2D/3D Registration Method with an Application in Patient Setup for External Beam Radiotherapy - InsightSoftwareConsortium/ITKTwoProjectionRegistration

A description is found in the Insight Journal article:

[https://www.insight-journal.org/browse/publication/784](https://www.insight-journal.org/browse/publication/784)

[https://www.insight-journal.org/download/viewpdf/784/3/download](https://www.insight-journal.org/download/viewpdf/784/3/download)

Python packages can be installed with

```auto
pip install itk-twoprojectionregistration

```

---

<div class="post-metadata">

### Author: ![svabhishek29](https://discourse.itk.org/user_avatar/discourse.itk.org/svabhishek29/32/926_2.png) [@svabhishek29](https://discourse.itk.org/u/svabhishek29)
#### Post date: [August 8, 2019, 2:41pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/3 "2019-08-08T14:41:09Z")

</div>

is it possible to write a simple example for this please? i am not a professional developer and an example would help greatly.

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: [August 8, 2019, 3:17pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/4 "2019-08-08T15:17:24Z")

</div>

Have you looked at [TwoProjection2D3DRegistration.cxx](https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/blob/master/test/TwoProjection2D3DRegistration.cxx)?

> <https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/blob/01f8ce7e4ec9d86459ba7497c41141858076b9ed/test/TwoProjection2D3DRegistration.cxx#L107-L112>

This example looks like a good starting point, even if you can’t use it as is.

---

<div class="post-metadata">

### Author: ![svabhishek29](https://discourse.itk.org/user_avatar/discourse.itk.org/svabhishek29/32/926_2.png) [@svabhishek29](https://discourse.itk.org/u/svabhishek29)
#### Post date: [August 8, 2019, 3:46pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/5 "2019-08-08T15:46:53Z")

</div>

oh,  
sorry, my bad, i did not go through all the files, saw the root folder and then tried to implement it.

---

<div class="post-metadata">

### Author: ![James\_Tso](https://discourse.itk.org/user_avatar/discourse.itk.org/james_tso/32/1106_2.png) [@James\_Tso](https://discourse.itk.org/u/James_Tso)
#### Post date: [December 15, 2019, 4:14pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/6 "2019-12-15T16:14:28Z")

</div>

Hi, I am also doing this topic now, but in Python.  
Are there useful usage instructions or documentations of itk-twoprojectionregistration module.

Thank you for the help.

---

<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: [December 16, 2019, 2:02pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/7 "2019-12-16T14:02:05Z")

</div>

That module came with an Insight Journal paper titled [ITK-Based Implementation of Two-Projection 2D/3D Registration Method with an Application in Patient Setup for External Beam Radiotherapy](http://hdl.handle.net/10380/3245).

---

<div class="post-metadata">

### Author: ![changken1](https://discourse.itk.org/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@changken1](https://discourse.itk.org/u/changken1)
#### Post date: [May 6, 2020, 3:09pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/8 "2020-05-06T15:09:40Z")

</div>

Hi,

I am trying to use the GetDRRSiddonJacobsRayTracing function [https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/blob/master/test/GetDRRSiddonJacobsRayTracing.cxx](https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/blob/master/test/GetDRRSiddonJacobsRayTracing.cxx).

However, I am a little confused about the usage in python. After running the pip install (pip install itk-twoprojectionregistration), I am not sure how to actually use the function. Does anyone have any example code in python on importing and usage of the function?

Thank you!

---

<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: [May 6, 2020, 3:45pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/9 "2020-05-06T15:45:20Z")

</div>

@simon.rit might have some advice.

---

<div class="post-metadata">

### Author: ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)
#### Post date: [May 6, 2020, 7:56pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/10 "2020-05-06T19:56:10Z")

</div>

Not really, I am not very familiar with this module. I think `itk::SiddonJacobsRayCastInterpolateImageFunction` is an interpolator for the registration framework of ITK so maybe you need to find a python registration example and adapt it to your case? Or a resample image filter example? Sorry I can’t help more…

---

<div class="post-metadata">

### Author: ![timeanddoctor](https://discourse.itk.org/user_avatar/discourse.itk.org/timeanddoctor/32/1473_2.png) [@timeanddoctor](https://discourse.itk.org/u/timeanddoctor)
#### Post date: [May 19, 2020, 4:34am UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/11 "2020-05-19T04:34:09Z")

</div>

This is my first quistion.  
I am confused about the usage in python for this module.  
I have two images(0&90 degree, 512_512) and a CT volume(512_512, z=256). I want get the transform after the registration in python. I pip installed this module and I learned how to read the DICOM files.  
What’s the code I should write? There is no example code for python after Google and github researching.  
Thanks.

 ![image](https://discourse.itk.org/uploads/default/original/2X/e/e573fbc9b19cd70156d146a7a71d59ecd2624fe4.png)

---

<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: [May 19, 2020, 12:46pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/12 "2020-05-19T12:46:28Z")

</div>

You should write out the [final transform](https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/blob/4a478b98e77adaae6a8599fa080bedaf3f19067c/test/TwoProjection2D3DRegistration.cxx#L845-L848). This [example](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/IO/TransformReadWrite.cxx) shows how.

---

<div class="post-metadata">

### Author: ![timeanddoctor](https://discourse.itk.org/user_avatar/discourse.itk.org/timeanddoctor/32/1473_2.png) [@timeanddoctor](https://discourse.itk.org/u/timeanddoctor)
#### Post date: [May 19, 2020, 10:54pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/13 "2020-05-19T22:54:24Z")

</div>

Dear dzenanz:  
Thank you very much!

```
import itk

a=itk.TwoProjectionRegistrationPython
helpInformation=a.getDRRSiddonJacobsRayTracing('-h')
print(helpInformation)

```

I get som problem:

```
  File "d:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
    execfile(filename, namespace)

  File "d:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/1/.spyder-py3/temp.py", line 10, in <module>
    a=itk.TwoProjectionRegistrationPython

  File "d:\ProgramData\Anaconda3\lib\site-packages\itkLazy.py", line 48, in __getattribute__
    value = types.ModuleType. __getattribute__ (self, attr)

AttributeError: module 'itk' has no attribute 'TwoProjectionRegistrationPython'
```

---

<div class="post-metadata">

### Author: ![timeanddoctor](https://discourse.itk.org/user_avatar/discourse.itk.org/timeanddoctor/32/1473_2.png) [@timeanddoctor](https://discourse.itk.org/u/timeanddoctor)
#### Post date: [May 19, 2020, 10:57pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/14 "2020-05-19T22:57:54Z")

</div>

This is the [paper’s](https://github.com/midas-journal/midas-journal-784/blob/master/Test%20commands.bat) code:

```
REM Test using down-sized CT
getDRRSiddonJacobsRayTracing -rp 0 -rx -3 -ry 4 -rz 2 -t 5 5 5 -iso 99.62 101.18 65 -res 1 1 -size 256 256 -o boxheadDRRDev1_G0.tif BoxheadCT.img
getDRRSiddonJacobsRayTracing -rp 90 -rx -3 -ry 4 -rz 2 -t 5 5 5 -iso 99.62 101.18 65 -res 1 1 -size 256 256 -o boxheadDRRDev1_G90.tif BoxheadCT.img
2D3DTwoProjRegistration -res 1 1 1 1 -iso 99.62 101.18 65 -o boxheadDRRDev1_G0_Reg.tif boxheadDRRDev1_G90_Reg.tif boxheadDRRDev1_G0.tif 0 boxheadDRRDev1_G90.tif 90 BoxheadCT.img

```

Can I use this module in python just given such argv?  
Thanks

---

<div class="post-metadata">

### Author: ![timeanddoctor](https://discourse.itk.org/user_avatar/discourse.itk.org/timeanddoctor/32/1473_2.png) [@timeanddoctor](https://discourse.itk.org/u/timeanddoctor)
#### Post date: [May 21, 2020, 11:36am UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/15 "2020-05-21T11:36:09Z")

</div>

> [@timeanddoctor](#):
>
> File “d:\ProgramData\Anaconda3\lib\site-packages\spyder\_kernels\customize\spydercustomize.py”, line 668, in runfile execfile(filename, namespace) File “d:\ProgramData\Anaconda3\lib\site-packages\spyder\_kernels\customize\spydercustomize.py”, line 108, in execfile exec(compile(f.read(), filename, ‘exec’), namespace) File “C:/Users/1/.spyder-py3/temp.py”, line 10, in a=itk.TwoProjectionRegistrationPython File “d:\ProgramData\Anaconda3\lib\site-packages\itkLazy.py”, line 48, in **getattribute** value = types.ModuleType. **getattribute** (self, attr) AttributeError: module ‘itk’ has no attribute ‘TwoProjectionRegistrationPython’

It seems error…

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [June 10, 2020, 3:00pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/16 "2020-06-10T15:00:50Z")

</div>

@timeanddoctor

To install the `itk-twoprojectionregistration` Python package:

```auto
python -m pip install --upgrade itk-twoprojectionregistration

```

---

<div class="post-metadata">

### Author: ![timeanddoctor](https://discourse.itk.org/user_avatar/discourse.itk.org/timeanddoctor/32/1473_2.png) [@timeanddoctor](https://discourse.itk.org/u/timeanddoctor)
#### Post date: [June 11, 2020, 10:37am UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/17 "2020-06-11T10:37:37Z")

</div>

```
python -m pip install --upgrade itk-twoprojectionregistration
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting itk-twoprojectionregistration
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/65/d9/019f54967c7ff39ddb9b617d5640c0a5e3ea33781519f925e487c2f522bf/itk_twoprojectionregistration-1.1.0-cp35-cp35m-win_amd64.whl (457kB)
    100% |████████████████████████████████| 460kB 313kB/s
Collecting itk>=5.1.0.post2 (from itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4e/38/51e8635c30bcb755531ff72369fb9853dab53138c5221b38475b71dcb84c/itk-5.1.0.post2-cp35-cp35m-win_amd64.whl
Requirement not upgraded as not directly required: numpy in d:\programdata\anaconda3\lib\site-packages (from itk>=5.1.0.post2->itk-twoprojectionregistration) (1.14.5)
Collecting itk-io==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0c/82/1068ed9941e140ab556a1b2ee57786cb9e70bb0371b3851b0525dc7c2dcf/itk_io-5.1.0.post2-cp35-cp35m-win_amd64.whl (5.7MB)
    100% |████████████████████████████████| 5.7MB 1.3MB/s
Collecting itk-filtering==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5c/0d/a933eb2d9617329eaeb923435482d639eb2d57c4f98d5fb525c555f8badf/itk_filtering-5.1.0.post2-cp35-cp35m-win_amd64.whl (23.7MB)
    100% |████████████████████████████████| 23.7MB 195kB/s
Collecting itk-registration==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9d/93/749dbe63bab8a10a2619f854befb013ea4797df9df6458b4f4b2561ab76e/itk_registration-5.1.0.post2-cp35-cp35m-win_amd64.whl (4.5MB)
    100% |████████████████████████████████| 4.5MB 1.6MB/s
Collecting itk-core==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/82/7b/32057792ca5c4a8b0e2ec3501a25bc21125bd00c4adf389fd5a93dcced13/itk_core-5.1.0.post2-cp35-cp35m-win_amd64.whl (25.3MB)
    100% |████████████████████████████████| 25.3MB 145kB/s
Collecting itk-segmentation==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fa/a8/5eead8d6d8384733c8cd7163800662bad311923deb8ae3826bdb5dfafdde/itk_segmentation-5.1.0.post2-cp35-cp35m-win_amd64.whl (3.3MB)
    100% |████████████████████████████████| 3.3MB 1.9MB/s
Collecting itk-numerics==5.1.0.post2 (from itk>=5.1.0.post2->itk-twoprojectionregistration)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f7/8e/29ea13d6b709d7125d05a94690ce74df6620afcdbf3005c23dc2da0463ad/itk_numerics-5.1.0.post2-cp35-cp35m-win_amd64.whl (12.3MB)
    100% |████████████████████████████████| 12.3MB 900kB/s
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
tensorflow 1.10.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible.
tensorflow-gpu 1.10.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible.
pygmsh 5.0.1 has requirement meshio<3.0,>=2.0, but you'll have meshio 4.0.13 which is incompatible.
Installing collected packages: itk-core, itk-io, itk-numerics, itk-filtering, itk-registration, itk-segmentation, itk, itk-twoprojectionregistration
  Found existing installation: itk-core 5.1.0
    Uninstalling itk-core-5.1.0:
      Successfully uninstalled itk-core-5.1.0
  Found existing installation: itk-io 5.1.0
    Uninstalling itk-io-5.1.0:
      Successfully uninstalled itk-io-5.1.0
  Found existing installation: itk-numerics 5.1.0
    Uninstalling itk-numerics-5.1.0:
      Successfully uninstalled itk-numerics-5.1.0
  Found existing installation: itk-filtering 5.1.0
    Uninstalling itk-filtering-5.1.0:
      Successfully uninstalled itk-filtering-5.1.0
  Found existing installation: itk-registration 5.1.0
    Uninstalling itk-registration-5.1.0:
      Successfully uninstalled itk-registration-5.1.0
  Found existing installation: itk-segmentation 5.1.0
    Uninstalling itk-segmentation-5.1.0:
      Successfully uninstalled itk-segmentation-5.1.0
  Found existing installation: itk 5.1.0
    Uninstalling itk-5.1.0:
      Successfully uninstalled itk-5.1.0
  Found existing installation: itk-twoprojectionregistration 1.0.1
    Uninstalling itk-twoprojectionregistration-1.0.1:
      Successfully uninstalled itk-twoprojectionregistration-1.0.1
Successfully installed itk-5.1.0.post2 itk-core-5.1.0.post2 itk-filtering-5.1.0.post2 itk-io-5.1.0.post2 itk-numerics-5.1.0.post2 itk-registration-5.1.0.post2 itk-segmentation-5.1.0.post2 itk-twoprojectionregistration-1.1.0
You are using pip version 19.0.1, however version 20.2b1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

```

I update the code and still get the some error.

```
  File "d:\ProgramData\Anaconda3\lib\site-packages\itkLazy.py", line 48, in __getattribute__
value = types.ModuleType. __getattribute__ (self, attr)

AttributeError: module 'itk' has no attribute 'TwoProjectionRegistrationPython'
```

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [June 11, 2020, 12:54pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/18 "2020-06-11T12:54:44Z")

</div>

To instantiate a TwoProjectionImageRegistrationMethod class,

```auto
ImageType = itk.Image[itk.F, 3]
registration_method = itk.TwoProjectionImageRegistrationMethod[ImageType, ImageType].New()

```

---

<div class="post-metadata">

### Author: ![wangjun456](https://discourse.itk.org/user_avatar/discourse.itk.org/wangjun456/32/2409_2.png) [@wangjun456](https://discourse.itk.org/u/wangjun456)
#### Post date: [December 1, 2021, 3:41pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/19 "2021-12-01T15:41:20Z")

</div>

hi, I changed your program to a fixed image, but the result is an all black image.

---

<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: [December 1, 2021, 3:51pm UTC](https://discourse.itk.org/t/2d-to-3d-registration/2112/20 "2021-12-01T15:51:37Z")

</div>

Can you please start a new topic, and describe your problem in more detail?

[Next page](https://discourse.itk.org/t/2d-to-3d-registration/2112.md?page=2)
