how to assign value to small region in a big image?

hi, i have a image buffer pointer, whose size is : [64,64,64], now I want to assign the buffer values to start [0,0,64] to end [63,63, 127] in a big image whose size is [256,256,103]. Is there any filter can do this? Thank you!

That would be PasteImageFilter.

1 Like

Thank you! it worked perfectly!

1 Like

With SimpleITK you can set a sub-region like this:


import SimpleITK as sitk

img = sitk.Image(100,100,sitk.sitkUInt8)

img[20:40,20:40] = 255

That creates a black image, an then sets a square within it to white.

1 Like

Thank you! And yes, numpy array makes it convient in python. I have solved my problem in c++, thank you anyway.