Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个灰色图像的3D-numpy数组,看起来像这样:
[[[120,120,120],[67,67,67]]...]
显然,我的每个 RG 和 B 都相同,因为它是灰色图像 - 这是多余的。我想得到一个新的二维数组,它看起来像:
[[120,67]...]
这意味着将每个像素的数组 [x,x,x] 取为值 x
我怎样才能做到这一点?
如果你的形状ndarray是(M,N,3),那么你可以得到一个(M,N)灰度图像,如下所示:
ndarray
>>> gray = img[:,:,0]