if w<h:
normalized_char = np.ones((h, h), dtype='uint8')
start = (h-w)/2
normalized_char[:, start:start+w] = char
else:
normalized_char = np.ones((w, w), dtype='uint8')
start = (w-h)/2
normalized_char[start:start+h, :] = char
jupyter上でこれを実行すると、このエラー、私はこのエラーを解決することができますどのようにTypeError:スライスインデックスは、整数またはNoneまたは__index__メソッドを持たなければなりません。それを解決するには?
<ipython-input-8-15d17de04b9c> in extractCharactersNew(function)
60 normalized_char = np.ones((h, h), dtype='uint8')
61 start = (h-w)/2
---> 62 normalized_char[:, start:start+w] = char
63 else:
64 normalized_char = np.ones((w, w), dtype='uint8')
TypeError: slice indices must be integers or None or have an __index__ method
を取得?
'(h-w)/ 2'は浮動小数点です。 – user2357112