Hello, I’m thomjiji

This website is a mix of my blog, my learning journey, and what I’m up to recently ^^.

3x3 Matrix for Camera Matching  [draft]

前言 使用 3x3 矩阵来做摄影机的匹配不是一个新技术了。很久之前看过这个叫作 Paradox 的人(他 day job 似乎是干广电的一个工程师、技术人员吧)做的一个视频,其中讲解了他是如何对 Fuji 的一台什么相机拍摄的 Log 素材和 iPhone 拍摄的 Log 素材进行匹配的,分享了详细的过程。 首先需要两台相机,源相机(source)和目标相机(target),在同一个照明环境下,拍摄同一张色卡。然后得到两条素材中色卡的值,计算两张色卡的差值,得到一个校正矩阵。将该校正矩阵应用到源相机(source)拍摄的素材上,就能实现与目标相机(target)的匹配。 他的过程需要用到达芬奇、colour-science.org 的 colour Python 库。我知道 Nuke 有一个 gizmo 叫作 mmColorTarget,可以不需要用到 colour,然后全部在 Nuke 里完成。在此将步骤简要记录: 测试图像 手边没有不同摄影机拍摄色卡的测试图,所幸 CML 有分享一组: https://www.cinematography.net/edited-pages/ACES.html 第一张是 ARRI Alexa,第二、三张是 Sony F55 和 Sony F65,都是 RAW。这作为我们的这个匹配测试的测试图正正好。 步骤 将两张图裁切到色卡填充满整个画面,色彩空间转换到一个统一的广色域(最好大到能够承载摄影机原始色域,例如 DWG 或 ACES AP0)。我们这里选择 ACES,传递函数选择 Linear 线性。输出 EXR,ACES Linear。 开启一个 Python 虚拟环境 .venv,安装这两个 python 包:colour 和 colour_checker_detection: python -m venv .venv source .venv/bin/activate pip install colour colour_checker 运行脚本: from colour import matrix_colour_correction, read_image from colour_checker_detection import detect_colour_checkers_segmentation source_filename = "/path/to/source/f65-sony-rv.mxf.chart.exr" target_filename = "/path/to/target/alexa-raw.ari.chart.exr" source = detect_colour_checkers_segmentation(read_image(source_filename))[0] target = detect_colour_checkers_segmentation(read_image(target_filename))[0] matrix = matrix_colour_correction(source, target) print(matrix) 得到一个 matrix 像这样: [[ 1.87196901 0.06371339 -0.08137244] [-0.02488484 1.9985176 -0.00450315] [ 0.03458153 -0.06038139 1.77408664]] 将这个 matrix 的 9 个值复制到 Nuke 的 ColorMatrix 节点,把节点加载给源 source 素材。简单点可以首先复制一个 ColorMatrix 节点到文本编辑器: set cut_paste_input [stack 0] version 16.0 v4 push $cut_paste_input ColorMatrix { matrix { {1 0 0} {0 1 0} {0 0 1} } name ColorMatrix1 note_font Helvetica selected true xpos -483 ypos 1283 } 把刚输出的那串 matrix 复制到上面的 matrix 那里,把 [] 用 {} 替换: set cut_paste_input [stack 0] version 16.0 v4 push $cut_paste_input ColorMatrix { matrix { { 1.87196901 0.06371339 -0.08137244} {-0.02488484 1.9985176 -0.00450315} { 0.03458153 -0.06038139 1.77408664} } name ColorMatrix1 note_font Helvetica selected true xpos -483 ypos 1283 }

2025-08-24

Color Science Things

关于广泛的“色彩科学”这一话题,以下是我零星的来源和笔记。这里权当做一个记录,同时帮助我厘清思路: Troy James Sobotka Picture Formation Definition Troy’s Mastodon about picture formation Question #6: What the F*ck is a Transfer Function? Apelles and the Birth of Illusionism: Ancient lessons in painting spatial depth Jed Smith Output Transform Tone Scale: All about tonescale functions: MM, Naka-Rushton, Sigmoid, Daniele, etc. Per-Channel Display Transform with Wider Rendering Gamut: ARRI K1S1 implemented in Nuke node 经典的 Tone Mapping 函数 (Reinhard function):open display transform wiki > tonescale > hyperbola 这个函数在 Thatcher Freeman 的这个 DCTL 教学视频得到验证,他在视频中用的也是这个函数,可见这个函数确实很普遍,很 basic。 Self-crafted Log curve - XLog 这个 Log 曲线的图像可视化(Desmos):https://www.desmos.com/calculator/9pgjgo1gq4 Google Colab 里对这个 Log 曲线的数学推导和由来的记录,有很多讲解性的描述:https://colab.research.google.com/drive/1NwjaD0NzNMzQeNQqZECj33PdcYGkeBM4 Sigmoid function https://discuss.pixls.us/t/blender-agx-in-darktable-proof-of-concept/48697/526 https://colab.research.google.com/drive/1CjDunkNCuhWIoWox_reDist6fTEJIim2 关于 Nuke Grade node 里的 Gamma 实际上不是纯 Gamma 函数,而是在像素值超过 1 之后使用的是一个线性函数 The Math of Color Grading in Nuke I can understand scene-linear, but what is display-linear? magic numbers OpenDRT: scene-linear 0.18 (mid grey) => display-linear 0.11 scene-linear 0.09 => display-linear 0.04 DaVinci: scene-linear 0.18 (mid grey) => display-linear 0.17 scene-linear 0.09 => display-linear 0.09 ...

2025-08-20

Demystify Saturation

Understanding HSVL Within the Nuke Context Saturation is independent of Hue or Luminance and is an indicator of the intensity of a colour. Highly saturated colours appear “stronger” and by increasing Saturation we are “revealing” more of the Hue present in the color, for example, being “more red”, “more blue”, etc. This is because, while zero Saturation (i.e. grey) indicates that all the three channels have the same value (R=G=B) and low Saturation implies that the three channels are closely aligned, high Saturation signifies a strong disparity in the values of the three channels. Increasing Saturation pulls the values in the channels further apart, thus increasing the dominant Hue, while reducing Saturation pulls the values from the channels closer together. ...

2025-08-19

Demystify HLG  [draft]

ITU-R BT.2390-7 (07-2019) 10 Mapping of SDR content into HLG and PQ 标准动态范围(SDR)内容可以通过直接映射或反向色调映射(也叫“向上转换”)的方式,被整合进 HDR 格式的节目当中。 一种映射方式是将 SDR 内容放进 HDR 容器,这类似于将 BT.709 色度编码的内容装进 BT.2020 容器。这种做法的目的是:在 HDR 显示设备上尽可能还原 SDR 内容原本的“观感”。 相较之下,“反向色调映射”(inverse tone mapping,或称“向上转换”)的目标是扩大亮度范围,充分利用 HDR 显示设备的亮度能力,从而模拟出 HDR 内容的视觉效果。本节所讲的就是这种映射方式的技术方法。 根据具体应用场景,SDR 的映射方式可分为两种: 显示参考映射(Display-referred mapping):用于在 HDR(BT.2100)显示设备上,保留 SDR(BT.709 或 BT.2020)显示设备上的色彩和相对亮度关系。典型例子是将调色完成的 SDR 片段嵌入 HDR 节目中。 场景参考映射(Scene-referred mapping):适用于素材直接来自 SDR 摄像机的场景,目标是让画面尽量贴近 HDR(BT.2100)摄像机的色彩和亮度表现。这通常出现在直播制作中 SDR 和 HDR 摄像机混用的场合。 ITU-R BT.2390-12 (12-2025) 2 Television system architechture 2.1 The relationship between the OETF, the EOTF and the OOTF OETF: the opto-electronic transfer function, which converts linear scene light into the video signal, typically within a camera. EOTF: electronic-opto transfer function, which converts the video signal into the linear light output of the display. OOTF: opto-optical transfer function, which has the role of applying the ‘rendering intent’. In television systems the displayed light is not linearly related to the light captured by the camera. Instead an overall non-linearity is applied, the OOTF. ...

2025-08-07

Nuke Learning Resources

Download Nuke Software https://www.foundry.com/products/nuke/download Tcl Expression and Python in Nuke Tcl Functions in Text Node - GATIMEDIA Expressions & Tcl Tips - GATIMEDIA Python & TCL Scripts & Tricks - Sacha Djordjevic Expressions 101 - Written Tutorials - Nukepedia Unlock HDR Preview in Nuke (Apple EDR) Working with HDR Images - Nuke User Guide Other Resources https://benmcewan.com/blog/ Useful Articles Analysing the grade node from a mathematical perspective Understanding HSVL Within The Nuke Context A free suite of Nuke tools & scripts Q100319: How to use colorspaces in Nuke? Q100330: Generating chromaticity diagrams

2025-07-12

I fixed Rime and Neovide

TL;DR 问题:Rime 的自动切换到英文输入法的设置对 macOS 上的 Neovide 不生效! 原因:我一般是从 Terminal 启动 Neovide,这样其实调用的是 Homebrew 叫作 formula 的那个程序:/opt/homebrew/bin/neovide。而我们在 Rime 的配置文件 squirrel.yaml 设置的开启默认英文 ascii_mode: true 是给 Neovide 的 GUI app 的!那它自然就不生效了。 解决方案:给 Neovide 设置一个 alias,让它指向 Neovide GUI app 的可执行文件 /Applications/Neovide.app/Contents/MacOS/neovide。像我在 Fish shell 的 ~/.config/fish/config.fish 就是这样设置: alias neovide "/Applications/Neovide.app/Contents/MacOS/neovide" 这样你在 Terminal 输入 neovide 就不会调用那个 formula /opt/homebrew/bin/neovide,而是 Neovide GUI app 的可执行文件。Rime 的默认英文的设置也就正常生效了。 前情提要、问题浮现 Neovide 是一个我前阵子发现的宝藏 app,它让 neovim 拥有 vscode 一般的顺滑操控和鼠标动画。我第一次知道这个 app 的那天晚上,下班一回到家,等不及迅速安装配置好了,然后就被惊到。这个动画的顺畅程度跟 vscode 真的有过之而无不及。那天晚上真是惊叹不已,要知道 neovim 在 Terminal 里的体验你是绝对不会奢求它有多好的 animation 的。即便 LazyVim 的 snacks 插件有通过一个 Animate 的模块做了一点点让 neovim 稍微顺滑一点的努力,但远不及 Neovide 这个顺滑。Neovide 属于你用了就回不去了的那种。 ...

2025-05-04

Tips and tricks

Firefox 的 Profile 文件夹可以在这里获取:Firefox 左上角菜单栏 > Help > More Troubleshooting Information > Application Basics > Profile Folder. 在这个 Profile folder 里创建一个叫做 user.js 的文件,就可以实现导出 Firefox 的全局用户设置(修改过的 Firefox 的默认设置)。 所有在 about:config 里修改的设置都在一个叫做 prefs.js 的文件里。=> Prefs.js file 我的 Firefox 用户设置(about:config): mousewheel.with_control.action: 3 Reference: https://support.mozilla.org/en-US/questions/1197798 Change author name in commit message: git config --global user.name <name> git config --global user.email <email> 安装 LazyVim 之后,LSP 的下载会遇到一些网络问题,比如每次都是 pyright 由于一些网络原因安装失败:set -Ux https_proxy 127.0.0.1:7890 和 set -Ux http_proxy 127.0.0.1:7890 都不好使,使用 sing-box 也不行。这时只需要取消系统代理就可以成功联网安装。 ...

2025-01-08

Create dummy directories using Rsync

Use rsync to create dummy dirs: rsync -avPih --include '*/' --exclude '*' videos/ ~/Desktop/videos-dummy/ Here’s a breakdown of the command: -avPih: These flags stand for: -a: Archive mode, which preserves permissions, timestamps, symbolic links, etc. -v: Verbose, which provides detailed output. -P: Combines –progress and –partial, showing progress during transfer and allowing for partial transfers to be resumed. -i: Output a change-summary for all updates. -h: Output numbers in a human-readable format. --include '*/': Includes all directories (and subdirectories) in the transfer. --exclude '*': Excludes all files.

2024-06-25

Best practice for grading stack in Baselight

Colour Online: Developing Digital Images > Best Practice Stack Start at 59:04:

2024-03-31

Setup Rime on Fedora Asahi Remix

Install fcitx5 and fcitx5-rime via sudo dnf install fcitx5-rime fcitx5. Go to System Setting > Input Devices > Virtual Keyboard, select “Fcitx 5”. Edit environment file via: sudo vi /etc/environment. Add the following content, reference: INPUT_METHOD=fcitx XMODIFIERS=@im=fcitx Open Input Method Selector > Use fcitx5 > Log out. Clone 雾凇拼音 repo into ~/.local/share/fcitx5/, rename it to rime: $ mv rime-ice rime Restart fcitx5 in the lower right corner of your Desktop. ...

2023-12-30