You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi developers, I happen to find out that PixelAcess class fails to use Numpy int as index, while Python built-in int, Python built-in float and even Numpy float all work fine. I'm using Python 3.6.1, Numpy 1.15.0, PIL 7.2.0.
An example is provided as follows.
code:
importnumpyasnpfromPILimportImageimportosbase=os.path.dirname(os.path.realpath(__file__))
im_path=os.path.join(base, 'xxxx.bmp')
pix=Image.open(im_path).load()
default_float_coor= [1.1, 9.9]
default_int_coor= [1,10]
numpy_float_coor=np.array([1.1, 9.9])
numpy_int_coor=np.array([1, 10])
print(type(pix))
print('pix at default_float_coor: ', pix[default_float_coor[0], default_float_coor[1]])
print('pix at default_int_coor: ', pix[default_int_coor[0], default_int_coor[1]])
print(type(numpy_float_coor[0]))
print('pix at numpy_float_coor: ', pix[numpy_float_coor[0], numpy_float_coor[1]])
print(type(numpy_int_coor[0]))
print('pix at numpy_int_coor: ', pix[numpy_int_coor[0],numpy_int_coor[1]])
Output:
<class 'PixelAccess'>
pix at default_float_coor: (71, 71, 75)
pix at default_int_coor: (70, 70, 70)
<class 'numpy.float64'>
pix at numpy_float_coor: (71, 71, 75)
<class 'numpy.int32'>
Traceback (most recent call last):
File "e:/HanLab_MyLab/Updated Codes/PreProcessing/draft.py", line 22, in <module>
print('pix at numpy_int_coor: ', pix[numpy_int_coor[0],numpy_int_coor[1]])
TypeError: an integer is required
np.int64 fails too as I trialed.
It would add to much convenience if Numpy int could serve as index.
Thx.
The text was updated successfully, but these errors were encountered:
Hi developers, I happen to find out that PixelAcess class fails to use Numpy int as index, while Python built-in int, Python built-in float and even Numpy float all work fine. I'm using Python 3.6.1, Numpy 1.15.0, PIL 7.2.0.
An example is provided as follows.
code:
Output:
np.int64 fails too as I trialed.
It would add to much convenience if Numpy int could serve as index.
Thx.
The text was updated successfully, but these errors were encountered: