Getting Houndsfield or Gray Value data from an image stack

Hello Nathaniel,

You can easily transform the memoryview into a numpy array using the function asarray from numpy.

Here is the example of the code I use:

import numpy as np

im = mimics.data.images["fixed"]  #selecting the image
mem_view = im.get_voxel_buffer()  #get the buffer in the memory view
buffer = np.asarray(mem_view)   #transform the memory view in a numpy array

print(buffer)

Regarding the conversion, we have the build-in mimics functions mimics.segment.GV2HU() and mimics.segment.HU2GV() that you can use to make the conversion between HU and Gray Value if needed.

Hope this helps.

Clément