# Resampling a Labelmap Volume

**URL:** <https://discourse.slicer.org/t/resampling-a-labelmap-volume/5545>\
**Category:** Support\
**Tags:** resample, binarylabelmap, labelmap\
**Created:** [January 28, 2019, 5:14pm UTC](https://discourse.slicer.org/t/resampling-a-labelmap-volume/5545 "2019-01-28T17:14:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevenagl12](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/stevenagl12/32/3391_2.png) [@stevenagl12](https://discourse.slicer.org/u/stevenagl12)\
**Post date:** [January 28, 2019, 5:14pm UTC](https://discourse.slicer.org/t/resampling-a-labelmap-volume/5545/1 "2019-01-28T17:14:16Z")

</div>

How can I resample a binary labelmap volume to an image origin of [0,0,0] and an image spacing of [1,1,1] that preserves the labelmap classes in the volume output? Is there a way to do this programmatically?

---

<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:** [January 29, 2019, 1:03am UTC](https://discourse.slicer.org/t/resampling-a-labelmap-volume/5545/2 "2019-01-29T01:03:46Z")

</div>

You can use any of the resample modules. The simplest way to preserve label values is to use nearest neighbor “interpolation”.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 29, 2019, 1:48am UTC](https://discourse.slicer.org/t/resampling-a-labelmap-volume/5545/3 "2019-01-29T01:48:41Z")

</div>

> [@stevenagl12](#):
>
> Is there a way to do this programmatically?

To invoke the resample volume programmatically, you could look into:

- [How to run CLI module from Python?](https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ#How_to_run_CLI_module_from_Python.3F)
- [How to call a CLI module from a C++ loadable module?](https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ#How_to_call_a_CLI_module_from_a_C.2B.2B_loadable_module.3F)
