I’m working on a dicom files and after investigating the pixel values range of the images it turned out to be around -2000 to 6000 range, which I assume corresponds to Hounsfield unit range HU, I will be using this code to normalize it,
image_transforms = transforms.Compose([transforms.ToTensor(), transforms.Resize((128, 128), interpolation=transforms.InterpolationMode.NEAREST), transforms.Normalize()])
however I’m not sure what normalize parameters(mean and std) I should use for this case.
In common use cases
ToTensor will output an already normalized tensor with values in the range
[0, 1] such that the
std values of the following
Normalize transformation would respect this range (and are thus set to values in
However, given that you are working with DICOM data, I don’t know which format you are passing to
ToTensor and if this transformation is already changing the range.
In any case, check the range of the tensor created by
ToTensor and adapt the stats of
Normalize to this range.
Thank you @ptrblck for your time,
As you mentioned
ToTensor does normalize by default if the the input is one of the stated formats in pytorch documentation of ToTensor, however in my case I’m passing a numpy array of float64 data type, so it is not doing any kind of normalization.
Right now I believe the best way to figure it out is to find the
std of a batch of the data and normalize upon it. I’m just not sure if this is the most efficient way.