-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Hi,
in nail.py I've got this error. TypeError and IndexError.
$ python nail.py
Traceback (most recent call last):
File "nail.py", line 61, in
x, y = getInteriorPoints(x, y)
File "nail.py", line 30, in getInteriorPoints
ext(amin(ylist), amax(ylist), i)
File "nail.py", line 24, in ext
naily.extend((ones(b-a)*i).tolist())
File "/usr/local/lib/python2.7/dist-packages/numpy/core/numeric.py", line 192, in ones
a = empty(shape, dtype, order)
TypeError: 'float' object cannot be interpreted as an index
I resolved this line change.
#a, b=round(a), round(b)
a = int (round(a))
b = int (round(b))
After that, I also got error message. IndexError.
Traceback (most recent call last):
File "nail.py", line 65, in
applyTexture(x, y)
File "nail.py", line 52, in applyTexture
val2 = color.rgb2lab((im[x, y]/255.).reshape(len(x), 1, 3)).reshape(len(x), 3)
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
I resolved by int value.
apply x list to int type.
change to int type
int_x = map(int,x)
int_y = map(int,y)
and use int_x lather than x, int_y lather than y.
val2 = color.rgb2lab((im[int_x, int_y]/255.).reshape(len(int_x), 1, 3)).reshape(len(int_x), 3)
this line also replaced.
x substituted by int_x and y by int_y
im[int_x, int_y] = color.lab2rgb(val2.reshape(len(int_x), 1, 3)).reshape(len(int_x), 3)*255
then I can see result image.
in Ubuntu 16.10
python 2.7
blush.py is ok. but lipstick.py is also same issue. Maybe this change also could be applied to lipstick.py file.
I share for others.
Thank you.
in python 3 map function have to change little bit different way.
http://stackoverflow.com/questions/7368789/convert-all-strings-in-a-list-to-int