# How to ensure DRR generated image has the same size as Input Xray image during 2d/3dregistration

**URL:** https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445
**Category:** Algorithms
**Created:** [September 8, 2020, 4:09pm UTC](https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445 "2020-09-08T16:09:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Henco](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/cab0a1/32.png) [@Henco](https://discourse.itk.org/u/Henco)
#### Post date: [September 8, 2020, 4:09pm UTC](https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445/1 "2020-09-08T16:09:02Z")

</div>

Good Morning All,

I have a question regarding the itk2d3dregistration module. I’m using it to register a CT liver volume to an XRay of said liver. I’ve extracted the vessels in both the 2d and 3d images and used those as my inputs. The registration runs well and outputs a 2d DRR with the correct orientation. However, the output’s size is smaller than the input. I would like to have these be equal in size. How would I change my code?  
Here’s the input xray vessels I’m registering to:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/8/83faec774e49708f0c260937f7bc27607d4caaa6.png)  
And the output xray:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/d/d9dc9c8cec7edf11b504b24ace4bfd130696036c.png)  
And here they are overlaid so that you can see the size difference better:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/7/786847686fca3b98be71a997b64fe4118de76e77.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: [September 8, 2020, 4:42pm UTC](https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445/2 "2020-09-08T16:42:27Z")

</div>

1. make sure you are doing registration in physical space
2. you can surely set some parameters which control the size of the generated DRR

---

<div class="post-metadata">

### Author: ![Henco](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/cab0a1/32.png) [@Henco](https://discourse.itk.org/u/Henco)
#### Post date: [September 8, 2020, 7:03pm UTC](https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445/3 "2020-09-08T19:03:39Z")

</div>

Hi Dr. Zukić,

1. I believe that I am doing the registration in physical space.
2. Ah yes I’ve found those parameters, but it seems that I didn’t explain my issue as clearly as I now can.  
The size of the output DRR and the XRay are the same, as are the spacing and origin. But as you can see the images are not the same, because the 3D model is smaller than the XRay. So the 3D model is projected but then all the pixels outside of this region are set to 0. My more specific question is now “Is there a way to stretch the outputDRR to match the XRay image and if so would it have something to do with the source to distance parameter of the RayCastInterpolator?”

---

<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: [September 8, 2020, 7:06pm UTC](https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445/4 "2020-09-08T19:06:22Z")

</div>

> [@Henco](#):
>
> source to distance parameter

Either that, or camera view angle. Reduce the distance, or reduce the viewing angle.

---

<div class="post-metadata">

### Author: ![Henco](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/cab0a1/32.png) [@Henco](https://discourse.itk.org/u/Henco)
#### Post date: [September 8, 2020, 7:58pm UTC](https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445/5 "2020-09-08T19:58:23Z")

</div>

Thank you for the suggestions. I’m trying to play with the distance right now. I can’t find any mention of viewing angle in the [code example](https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/blob/master/test/TwoProjection2D3DRegistration.cxx). Would that be inside the interpolator or the writer function?

---

<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: [September 8, 2020, 8:00pm UTC](https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445/6 "2020-09-08T20:00:33Z")

</div>

I am not familiar with that code. Viewing angle might be implicit or hard-coded.

---

<div class="post-metadata">

### Author: ![wwe1633](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/ebca7d/32.png) [@wwe1633](https://discourse.itk.org/u/wwe1633)
#### Post date: [September 4, 2023, 3:38am UTC](https://discourse.itk.org/t/how-to-ensure-drr-generated-image-has-the-same-size-as-input-xray-image-during-2d-3dregistration/3445/7 "2023-09-04T03:38:07Z")

</div>

hello, I want to know if two 2d images is a must, because I only have one corresponding X-ray image
