# Image Registration microCT image to STL file 

**URL:** https://discourse.slicer.org/t/image-registration-microct-image-to-stl-file/27820
**Category:** Support
**Tags:** registration, segmentation, python, 3d-model
**Created:** [February 15, 2023, 6:41am UTC](https://discourse.slicer.org/t/image-registration-microct-image-to-stl-file/27820 "2023-02-15T06:41:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![elrond11](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/elrond11/32/18421_2.png) [@elrond11](https://discourse.slicer.org/u/elrond11)
#### Post date: [February 15, 2023, 6:41am UTC](https://discourse.slicer.org/t/image-registration-microct-image-to-stl-file/27820/1 "2023-02-15T06:41:12Z")

</div>

I have an STL file that I used to 3D print bone samples. I then scanned those 3D printed bone samples and converted those files to nii files. I am trying to run image registration in Slicer to evaluate the quality of the 3D printing, but I am not sure how to register a surface mesh and a 3D image. I would like to run a simple rigid transformation using BRAINS and a linear transform.

I was able to get a linear transform to work using the original image file that I used to make the STL file but that is not quite what was 3D printed. As there is mesh operations that would slightly change this. Is there an easy way to convert the STL file to a nii or nrrd for example?

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 15, 2023, 6:47am UTC](https://discourse.slicer.org/t/image-registration-microct-image-to-stl-file/27820/2 "2023-02-15T06:47:20Z")

</div>

You lose some accuracy if you rasterize the surface mesh into a binary labelmap, so probably you can get more accurate results if you segment the CT scans and compare them to the original surface meshes (STL files) using ModelToModelDistance extension. You can align the meshes before the comparison using [model registration](https://slicer.readthedocs.io/en/latest/user_guide/registration.html#model-registration).

---

<div class="post-metadata">

### Author: ![elrond11](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/elrond11/32/18421_2.png) [@elrond11](https://discourse.slicer.org/u/elrond11)
#### Post date: [February 15, 2023, 6:57am UTC](https://discourse.slicer.org/t/image-registration-microct-image-to-stl-file/27820/3 "2023-02-15T06:57:58Z")

</div>

I have segmentations of the CT scans, but I was thinking segmentation could introduce other errors into the image. Noise or loss of connectivity in the structures of the sample.

Could you provide some documentation about rasterizing the surface mesh into a binary labelmap? Additonally, I am confused on how to resample an image in Slicer. I would like for the CT image and the STL file to be of the same image size.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 15, 2023, 7:07am UTC](https://discourse.slicer.org/t/image-registration-microct-image-to-stl-file/27820/4 "2023-02-15T07:07:30Z")

</div>

> [@elrond11](#):
>
> Could you provide some documentation about rasterizing the surface mesh into a binary labelmap?

I mean importing a model (surface mesh) into binary labelmap representation in a segmentation: [Segmentations — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/user_guide/modules/segmentations.html#import-an-existing-segmentation-from-model-surface-mesh-file)

> [@elrond11](#):
>
> I am confused on how to resample an image in Slicer. I would like for the CT image and the STL file to be of the same image size.

CT imaging, segmentation, all import/export operations, etc. all maintain the correct physical size. All processing and comparison methods in Slicer operate in physical space (image resolution does not matter). Therefore, there should be ne need for resizing or resampling for any comparison.

If you want to resample images anyway then you can use resampling modules, such as “Resample Scalar/Vector/DWI Volume” module.

---

<div class="post-metadata">

### Author: ![elrond11](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/elrond11/32/18421_2.png) [@elrond11](https://discourse.slicer.org/u/elrond11)
#### Post date: [February 15, 2023, 6:29pm UTC](https://discourse.slicer.org/t/image-registration-microct-image-to-stl-file/27820/5 "2023-02-15T18:29:11Z")

</div>

I am still having some issues with resampling and the image sizes. Can I provide you with the images so you can understand what the issue is?

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 15, 2023, 8:53pm UTC](https://discourse.slicer.org/t/image-registration-microct-image-to-stl-file/27820/6 "2023-02-15T20:53:43Z")

</div>

Yes, sure, you can upload the images anywhere (dropbox, onedrive, google drive, etc.) and post the download link here. Make sure the image do not contain patient health information (anonymize or use public or non-human data).
