如何使用YUV图像获取灰度图像Pygame
How to get grayscale image using YUV image Pygame
我正在努力学习 Pygame,我想从简单的事情开始。我只是坚持从图像中消除 U 和 V 通道以获得灰度图像。
cam = pygame.camera.Camera(self.clist[0], self.size, "YUV")
有什么方法可以做到?
如果你可以使用PIL/pillow库,你可以将pygame图像转换成PIL图像,在那里进行灰度转换,然后转换回来。此转换如图所示 here. Alternatively, you can just use the solution posted here 手动将数据转换为灰度。
我正在努力学习 Pygame,我想从简单的事情开始。我只是坚持从图像中消除 U 和 V 通道以获得灰度图像。
cam = pygame.camera.Camera(self.clist[0], self.size, "YUV")
有什么方法可以做到?
如果你可以使用PIL/pillow库,你可以将pygame图像转换成PIL图像,在那里进行灰度转换,然后转换回来。此转换如图所示 here. Alternatively, you can just use the solution posted here 手动将数据转换为灰度。