【发布时间】:2013-06-27 05:39:06
【问题描述】:
有没有更漂亮的方法来做到这一点?具体来说,这些最大值是否可以通过 numpy API 获得?我无法在 API 中找到它们,尽管很容易找到它们 here in the docs。
MAX_VALUES = {np.uint8: 255, np.uint16: 65535, np.uint32: 4294967295, \
np.uint64: 18446744073709551615}
try:
image = MAX_VALUES[image.dtype] - image
except KeyError:
raise ValueError, "Image must be array of unsigned integers."
像 PIL 和 cv2 这样的包提供了方便的工具来反转图像,但是在代码中的这一点上,我有一个 numpy 数组——接下来是更复杂的分析——我想坚持使用 numpy。
【问题讨论】:
标签: python image-processing numpy