[Numpy-discussion] Threshold

totonixsame@gmai... totonixsame@gmai...
Thu Dec 2 06:35:38 CST 2010


Hi all,

I' m developing a medical software named InVesalius [1], it is a free
software. It uses numpy arrays to store the medical images (CT and
MRI) and the mask, the mask is used to mark the region of interest and
to create 3D surfaces. Those array generally have 512x512 elements.
The mask is created based in threshold, with lower and upper bound,
this way:

mask = numpy.zeros(medical_image.shape, dtype="uint16")
mask[ numpy.logical_and( medical_image >= lower, medical_image <= upper)] = 255

Where lower and upper are the threshold bounds. Here I' m marking the
array positions where medical_image is between the threshold bounds
with 255, where isn' t with 0. The question is: Is there a better way
to do that?

Thank!

[1] - svn.softwarepublico.gov.br/trac/invesalius


More information about the NumPy-Discussion mailing list