Reputation: 2455
I am trying to use numpy to normalize a set of MRI images, but it seems to be not working. The simplified code is:
img = nib.load(img_path).get_data() #img is a numpy array
print("pre\n============================")
plt.imshow(img[:,:,100])
plt.ioff()
plt.show()
img = (img - 47.08389527329749)/125.64995558389833
print("post\n============================")
plt.imshow(img[:,:,100])
plt.ioff()
plt.show()
To calculate the mean and std values with numpy:
mean = np.mean(image_list) # 47.08389527329749
std = np.std(image_list) # 125.64995558389833
But the result images are similar:
pre:
post:
Which part am I doing wrong here?
Upvotes: 1
Views: 3225
Reputation: 499
You should print the numerical values of your matrix and not plot the images. I think the process went fine. Normalization has the purpose to center the values in a given interval, here the values of a standard normal distribution, and set the same range if you use several attributes. It is not supposed to remove the relative differences between values of a given attribute, here the pixels intensities.
Upvotes: 1