# Transform itk::Image to itk::SpatialObject

**URL:** https://discourse.itk.org/t/transform-itk-image-to-itk-spatialobject/371
**Category:** Engineering
**Created:** [October 30, 2017, 7:13pm UTC](https://discourse.itk.org/t/transform-itk-image-to-itk-spatialobject/371 "2017-10-30T19:13:09Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ray](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@Ray](https://discourse.itk.org/u/Ray)
#### Post date: [October 30, 2017, 7:13pm UTC](https://discourse.itk.org/t/transform-itk-image-to-itk-spatialobject/371/1 "2017-10-30T19:13:10Z")

</div>

What’s the best way to transform an itk::Image class to an itk::SpatialObject class?

Thanks!

Edit: The context is I have an itk::Image object which contains the a label map, and I would like to transform this object to a registration metric mask, i.e. itk::SpatialObject.

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [October 30, 2017, 8:31pm UTC](https://discourse.itk.org/t/transform-itk-image-to-itk-spatialobject/371/2 "2017-10-30T20:31:29Z")

</div>

Hello Ray,

I don’t think there is a function to convert directly from itk::Image to itk::SpatialObject. But you may be able to use [1] to convert from MetaObject to SpatialObject (FYI, I haven’t tried).  
For your registraton problem, you may be ableto simply use your label map directly if you select a metric that can work with this (you can try the sum of square difference).

[1] [https://itk.org/Doxygen/html/classitk\_1\_1MetaImageConverter.html](https://itk.org/Doxygen/html/classitk_1_1MetaImageConverter.html)
