简体   繁体   English

Manim / Cairo:颜色差异

[英]Manim / Cairo : color discrepancies

I have some discrepancies in terms of brightness, saturation and hue when using a jpg picture in Manim.在 Manim 中使用 jpg 图片时,我在亮度、饱和度和色调方面存在一些差异。

I have a picture which color profile/space is Adobe RGB.我有一张颜色配置文件/空间是 Adobe RGB 的图片。 I create it, edit it and save it that way.我创建它,编辑它并以这种方式保存它。 All of my apps previewing the picture are more, or less consistent with the original (enough to be acceptable).我所有预览图片的应用程序都或多或少与原始图像一致(足以接受)。 Including a movie export test from After effects.包括来自 After Effects 的电影导出测试。 Even the image previewer of VS Code shows the image correctly.甚至 VS Code 的图像预览器也能正确显示图像。 But when I render it with Manim, it's no good.但是当我用 Manim 渲染它时,它就不好了。 Way too bright, oversaturated with a slight shift in hue and as if it was downgraded in terms of quality (some subtle but weird color artifacts are showing).太亮了,过度饱和,色调略有变化,就好像它在质量方面被降级了(出现了一些微妙但奇怪的颜色伪影)。 You can tell something is off.你可以说有些东西是关闭的。

Granted, the picture I try to use is an abstract background with subtle gradients of color and light but still.当然,我尝试使用的图片是抽象背景,颜色和光线有细微的渐变,但仍然如此。 The overall difference and loss in quality are sufficiently there not to be acceptable.质量上的整体差异和损失足以让人无法接受。 I know that managing color spaces and profiles is a bit tricky and is an art in and on itself but the problem here is that the image is consistent everywhere so far but in Manim's rendered MP4 file.我知道管理色彩空间和配置文件有点棘手,它本身就是一门艺术,但这里的问题是,到目前为止,图像在任何地方都是一致的,但在 Manim 渲染的 MP4 文件中。

The only thing I've seen in the doc related to color spaces is this parameter "image_mode".我在文档中看到的与颜色空间相关的唯一内容是这个参数“image_mode”。 I tried to set it both to RGB and RGBA (only two options available) in the Manim script but it doesn't change anything.我尝试在 Manim 脚本中将其设置为 RGB 和 RGBA(只有两个选项可用),但它没有改变任何东西。

I suspect it's a feature that is more related to the renderer (Cairo) or the MP4 export parameters than Manim itself or maybe it downgrades jpg to gif/png before it renders the picture in Mp4?我怀疑这是一个与渲染器(Cairo)或 MP4 导出参数比 Manim 本身更相关的功能,或者它可能在将图片渲染为 Mp4 之前将 jpg 降级为 gif/png? I don't know and I don't know what to do with that anyway since I don't know how to parameter any of this within Manim itself.我不知道,我也不知道该怎么做,因为我不知道如何在 Manim 本身中对这些进行参数化。 I can't see any parameters that allow to edit any of this in the doc.我在文档中看不到任何允许编辑其中任何内容的参数。 Maybe a plugin could add some functionalities or something?也许一个插件可以添加一些功能或什么?

Any help would be appreciated.任何帮助,将不胜感激。

PS: the picture is 4k and I render it in 4k in Manim, so it should be a pixel to pixel match. PS:图片是4k的,我在Manim中渲染成4k的,所以应该是像素到像素的匹配。

Here is my Manim script:这是我的 Manim 脚本:

from manim import *

class Graph(Scene):

    def construct(self):

        bg = ImageMobject("media/background/13.jpg")
    
        self.add(bg)
        self.wait()

And here are the relevant parts of my manim.cfg这是我的 manim.cfg 的相关部分

[CLI]
write_to_movie = True
format = mp4
save_last_frame = False
write_all = False
save_pngs = False
save_as_gif = False
preview = False
background_color = #212021
background_opacity = 1
renderer = cairo
use_webgl_renderer = False
webgl_renderer_path = 
use_opengl_renderer = False
enable_gui = False
gui_location = 0,0
fullscreen = False
window_size = default
window_monitor = 0
force_window = False
use_projection_fill_shaders = False
use_projection_stroke_shaders = False
movie_file_extension = .mp4
frame_rate = 60
frame_size = 3664,1980
pixel_height = 1980
pixel_width = 3664
max_files_cached = 100
flush_cache = True
disable_caching = True
disable_caching_warning = False
enable_wireframe = False
dry_run = False
tex_template = 
plugins = 

TL;DR: Some random pointers, but no answer to the question. TL;DR:一些随机指针,但没有回答问题。

I have no clue about manim, so I just went searching for "JPEG" in its source code.我对manim一无所知,所以我只是在其源代码中搜索“JPEG”。 That brought me to https://github.com/3b1b/manim/blob/3c7a38660af41478e1561073a5319b23fb6b7787/docs/source/documentation/custom_config.rst#L59 which says这让我想到了https://github.com/3b1b/manim/blob/3c7a38660af41478e1561073a5319b23fb6b7787/docs/source/documentation/custom_config.rst#L59

The directory for storing raster images to be used in the code (including.jpg, .jpeg, .png and.gif), which will be read by ImageMobject.存放代码中使用的光栅图像的目录(包括.jpg、.jpeg、.png和.gif),ImageMobject将读取该目录。

Okay, what's ImageMobject ?好的,什么是ImageMobject Another search found the place where it loads images and apparently this just uses the Python library PIL to call PIL.Image.open : https://github.com/3b1b/manim/blob/669182944da040c227ccfd018250ee2bbc49649d/manimlib/mobject/types/image_mobject.py#L31 Another search found the place where it loads images and apparently this just uses the Python library PIL to call PIL.Image.open : https://github.com/3b1b/manim/blob/669182944da040c227ccfd018250ee2bbc49649d/manimlib/mobject/types/image_mobject. py#L31

Okay, so does this support color profiles?好的,这是否支持颜色配置文件? I don't know.我不知道。 What does this question even mean?这个问题甚至意味着什么? You are loading some color image that contains a color profile and it ends up being part of a movie... Should the movie now use that color profile?您正在加载一些包含颜色配置文件的彩色图像,它最终成为电影的一部分……电影现在应该使用该颜色配置文件吗?

Another random pointer that I found is PIL/Pillow decode icc profile information but that didn't really help.我发现的另一个随机指针是PIL/Pillow decode icc profile information ,但这并没有真正的帮助。 All I can say is: The manim code that I found doesn't do anything fancy with color profiles.我只能说:我发现的manim代码并没有对颜色配置文件做任何花哨的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM