encode - 将图像转换为 YUV 格式(不同类型:BT.601 或 BT.709)并以原始格式保存
问题描述
是否有可以将给定图像(jpg)转换为 YUV 格式并将其保存为原始数据的工具?
我尝试了 Python PIL,但找不到如何做到这一点。
感谢您的任何想法。
解决方案
您可以使用安装在大多数 Linux 发行版上并且可用于 macOS 和 Windows的ImageMagick来做到这一点。只需在终端中,您就可以运行:
convert input.jpg -depth 8 -colorspace Rec601YCbCr yuv:result.bin
或者,对于Rec709YCbCr
,您可以使用:
convert input.jpg -depth 8 -colorspace Rec709YCbCr yuv:result.bin
这是该过程的一个小示例并对其进行反转:
# Create a gradient image, magenta-green, save as JPEG
convert -size 1024x768 gradient:magenta-lime input.jpg
# Convert to YUV, saving as raw YUV in "image.bin"
convert input.jpg -depth 8 -colorspace Rec601YCbCr yuv:image.bin
# Convert back from raw YUV back to JPEG to check
convert -size 1024x768 -depth 8 YUV:image.bin -set colorspace Rec601YCbCr -colorspace RGB result.jpg
推荐阅读
- html - 如果未显示,请保留 div 的位置
- c# - 如何检查 Firebird 数据库的 nbak 状态
- javascript - 使用 Typescript 或 NodeJS 发出 HTTP 请求
- c# - 是否可以使用更多条件过滤 IIS 工作进程?
- node.js - 在非 icognito 中启动浏览器以保留登录
- c - 如何从ELF文件中反汇编的.text部分中的行到源代码中的相应行
- python-3.x - 从一个屏幕访问另一个屏幕的 Kivy 按钮不起作用
- angular - 如何在 Angular8 中动态实现 google hreflang?
- r - RStudio 错误地显示括号警告
- javascript - 单击隐藏的单选按钮在Angular 9中不起作用