I am trying to get the log of an image for some further processing, the minimum pixel value in the image is zero and hence i am trying to take log(1+image), but even after adding 1 to every element the minimum value of the array is still showing as 0 and hence np.log is throwing a divide by zero encountered in log and setting the value to -inf which is causing me problems down the line.
import numpy as np
import skimage.io as io
image = io.imread('./PET_image.tif')
image_2 = image + 1
print(np.amin(image))
print(np.amin(image_2))
np.log(image)
both the print np.amin() statements are printing out 0.
0
0
error.py:8: RuntimeWarning: divide by zero encountered in log
np.log(image_2)
But after adding 1 to the array shouldn't the minimum value be 1? I'm pretty sure I'm missing something extremely stupid, but this is making my head split and any help is greatly appreciated.