How to change the size of a sitk::Image object

Hi, I create a class that contains a sitk::Image as one of its attributes but in the moment of the creation of the class I do not know what should be its size. So, how do I change the size of that object?

Thanks.

You can do something like:

m_Image = sitk::Image(512, 512, 128, sitk.sitkInt16);

Internally, this assignment is done with pointers and lazy coping so it is efficient. In SimpleITK 2.0 it will be slightly more efficient with rvalue reference support.

1 Like