<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Wyaaaattwho’s Blog</title>
        <link>https://www.wyaaaattwho.xyz/</link>
        <description>He Wanted The Kingdom Of God On Earth</description>
        <lastBuildDate>Thu, 02 Apr 2026 15:01:24 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2026, wyaaaattwho</copyright>
        <item>
            <title><![CDATA[入门强化学习 Easy Reinforcement Learning]]></title>
            <link>https://www.wyaaaattwho.xyz/article/RL</link>
            <guid>https://www.wyaaaattwho.xyz/article/RL</guid>
            <pubDate>Fri, 22 Nov 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-1452c5ab8184801298d1fd98eb76fd76"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-1452c5ab818481e6ba91c1f407127c3f"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🔥">🔥</span></div><div class="notion-callout-text">强化学习（Reinforcement Learning, RL）是一种模仿人类学习方式的机器学习方法，它通过“试错”的交互过程，从环境中获得反馈信号（奖励或惩罚），逐步优化决策策略。无论是围棋中击败人类顶尖棋手的 AlphaGo，还是帮助机器人实现灵活运动的智能控制系统，强化学习都展示出了极大的潜力和应用价值。<div class="notion-text notion-block-1452c5ab818480a7a515d7fd8e36fb3b">本博客旨在为强化学习初学者提供一条清晰、易懂的入门路径，持续更新中。</div></div></div><a class="notion-page-link notion-block-1452c5ab81848074b7ffebba096903b0" href="/1452c5ab81848074b7ffebba096903b0"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="1️⃣">1️⃣</span></div><span class="notion-page-title-text">Imitation: Supervised Learning of Behaviors</span></span></a><a class="notion-page-link notion-block-14b2c5ab818480068ac3c96e8133bff7" href="/14b2c5ab818480068ac3c96e8133bff7"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="2️⃣">2️⃣</span></div><span class="notion-page-title-text">Reintroduction to Reinforcement Learning</span></span></a><a class="notion-page-link notion-block-1a62c5ab818480799765c738b4a551ce" href="/1a62c5ab818480799765c738b4a551ce"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="3️⃣">3️⃣</span></div><span class="notion-page-title-text">Policy Gradients</span></span></a><a class="notion-page-link notion-block-1b22c5ab818480f08da0ea3820632732" href="/1b22c5ab818480f08da0ea3820632732"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="4️⃣">4️⃣</span></div><span class="notion-page-title-text">Actor-Critic Algorithms</span></span></a><a class="notion-page-link notion-block-2622c5ab81848059b607f66725ee7886" href="/2622c5ab81848059b607f66725ee7886"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="5️⃣">5️⃣</span></div><span class="notion-page-title-text">Value Function Methods</span></span></a><a class="notion-page-link notion-block-2622c5ab818480c29fe7e00760cae143" href="/2622c5ab818480c29fe7e00760cae143"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="6️⃣">6️⃣</span></div><span class="notion-page-title-text">Deep RL with Q-Functions </span></span></a><a class="notion-page-link notion-block-3262c5ab81848035910ac2266a8c0e5f" href="/3262c5ab81848035910ac2266a8c0e5f"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="7️⃣">7️⃣</span></div><span class="notion-page-title-text">Advanced Policy Gradient</span></span></a></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ControlNet Breakdown]]></title>
            <link>https://www.wyaaaattwho.xyz/article/ISP/ControlNet</link>
            <guid>https://www.wyaaaattwho.xyz/article/ISP/ControlNet</guid>
            <pubDate>Mon, 17 Mar 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-1b92c5ab818480b2b386f4fb9a5f5c14"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-table-of-contents notion-gray notion-block-1b92c5ab8184801ba513c7e6fa425717"><a href="#1b92c5ab818480079f47f7c1945053c2" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Modules</span></a><a href="#1b92c5ab81848053b25af9e4a304a947" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">UNet</span></a><a href="#1b92c5ab8184801baed2ffd1ea1bd2f8" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">ControlNet</span></a><a href="#1b92c5ab8184806faad7e5e7cd5ebc61" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">DDIMSampler</span></a><a href="#1b92c5ab818480a6b4a5d6b76d9b0543" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Models</span></a><a href="#1b92c5ab818480b09f0def614d629a09" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">DDPM</span></a><a href="#1b92c5ab818480e4913fedd895b2bb2b" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">LDM</span></a><a href="#1b92c5ab81848056b10ae99b7c3ce398" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">ControledLDM</span></a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b92c5ab818480079f47f7c1945053c2" data-id="1b92c5ab818480079f47f7c1945053c2"><span><div id="1b92c5ab818480079f47f7c1945053c2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b92c5ab818480079f47f7c1945053c2" title="Modules"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Modules</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b92c5ab81848053b25af9e4a304a947" data-id="1b92c5ab81848053b25af9e4a304a947"><span><div id="1b92c5ab81848053b25af9e4a304a947" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b92c5ab81848053b25af9e4a304a947" title="UNet"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">UNet</span></span></h4><div class="notion-text notion-block-1b92c5ab81848046942cf67a5c9eab78"><b>1️⃣ UNetModel 代码结构解析（</b>in <code class="notion-inline-code">ldm/modules/openaimodel.py</code><b>）</b></div><div class="notion-text notion-block-1b92c5ab81848075bcebffddef561a75">UNetModel 是一个标准的 <b>U-Net 结构</b>，包含：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848030a9e0cc0766741ea1"><li><b>编码器（input_blocks）</b></li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848036af14fbeecff5f8c9"><li><b>瓶颈层（middle_block）</b></li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184806991f4d0a0b702c0ff"><li><b>解码器（output_blocks）</b></li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848006bb1fea0a6ea05afa"><li><b>最终输出层（self.out）</b></li></ul><div class="notion-text notion-block-1b92c5ab818480918f33cad0685e8537"><b>📌 主要流程</b></div><div class="notion-text notion-block-1b92c5ab8184808ba4ded4107383ad9e">1.	<b>input_blocks（编码器）</b>：<div class="notion-text-children"><div class="notion-text notion-block-1b92c5ab818480a4bd08e4a8e82f6b67">通过多个 ResBlock（残差块） 和 Downsample 逐层提取特征</div><div class="notion-text notion-block-1b92c5ab818480158b8cd39549c5f543">attention_resolutions 控制是否加入注意力机制</div><div class="notion-text notion-block-1b92c5ab818480b59533f30036e76939"><b>特征 h 被存入 hs</b>，用于后续跳跃连接</div></div></div><div class="notion-text notion-block-1b92c5ab818480beb1b6e4a3cc944aff">2.	<b>middle_block（瓶颈层）</b>：<div class="notion-text-children"><div class="notion-text notion-block-1b92c5ab818480868918e517800de03d">通过 ResBlock + AttentionBlock 进一步处理特征</div></div></div><div class="notion-text notion-block-1b92c5ab818480f69090c115390c4c8c">3.	<b>output_blocks（解码器）</b>：<div class="notion-text-children"><div class="notion-text notion-block-1b92c5ab818480948621eeb7d324c155">通过 Upsample 层恢复分辨率</div><div class="notion-text notion-block-1b92c5ab81848068b7bceeea8cbcbb6a"><b>核心：与 hs 进行跳跃连接（skip connection）</b></div><div class="notion-text notion-block-1b92c5ab818480c4b7b6d9d4de997576"><b>如果有注意力机制，加入 AttentionBlock</b></div></div></div><div class="notion-text notion-block-1b92c5ab81848032832beb2ff5a7f381">4.	<b>self.out（最终输出层）</b><div class="notion-text-children"><div class="notion-text notion-block-1b92c5ab8184802089ccc978439f2720">归一化 + SiLU 激活</div><div class="notion-text notion-block-1b92c5ab818480daafd3c85bbaefc193">通过 conv_nd 生成最终输出</div></div></div><hr class="notion-hr notion-block-1b92c5ab8184805c993af14cb6188f47"/><div class="notion-text notion-block-1b92c5ab8184803cbed4f0be1315ab57"><b>2️⃣ ControlledUnetModel 代码解析</b></div><div class="notion-text notion-block-1b92c5ab818480f6a802f928c657455e">ControlledUnetModel 继承 UNetModel，并 <b>增加了 control 变量</b>，用于外部引导 U-Net 处理特定任务。</div><div class="notion-text notion-block-1b92c5ab818480a6b1c7f6d154b6b6bd"><b>📌 主要改进点</b></div><div class="notion-text notion-block-1b92c5ab8184802bab99fcab82416b96">1.	<b>编码器部分</b>（input_blocks）<div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184801abb6ece251b55373a"><li><b>加速优化</b>：使用 torch.no_grad()，避免计算梯度，提高推理速度</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480468cb8f3246d285086"><li>hs.append(h)：存储编码器输出，用于跳跃连接</li></ul></div></div><div class="notion-text notion-block-1b92c5ab818480b68ad4e6fcef200687">2.	<b>中间层（middle_block）</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184805ebcb3f4839a24bd79"><li><b>control 的第一次作用</b>：如果提供了 control，则 <b>在 middle_block 之后</b> 进行相加 h += control.pop()</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480569b82f845c57fa5c5"><li>这里 control.pop() 代表 <b>取出控制变量的最后一层</b></li></ul></div></div><div class="notion-text notion-block-1b92c5ab818480ad9637caec98836ce3">3.	<b>解码器部分（output_blocks）</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184801091adefc7fbc5c0f5"><li><b>加入 control 的方式</b></li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480e0975dec10f3c1b138"><li><b>如果 only_mid_control=True</b>，则 control <b>仅在 middle_block 作用</b>，后续解码过程正常<b>否则，在解码过程中不断加入 control.pop()</b></li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480cd808ad0d31fd21281"><li><code class="notion-inline-code">h = torch.cat([h, hs.pop() + control.pop()], dim=1)</code></li><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480cd808ad0d31fd21281"><li>h 是当前特征图</li><li>hs.pop() 是来自编码器的跳跃连接</li><li>control.pop() 是控制信号（用于影响解码过程）</li></ul></ul></div></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b92c5ab8184801baed2ffd1ea1bd2f8" data-id="1b92c5ab8184801baed2ffd1ea1bd2f8"><span><div id="1b92c5ab8184801baed2ffd1ea1bd2f8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b92c5ab8184801baed2ffd1ea1bd2f8" title="ControlNet"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">ControlNet</span></span></h4><div class="notion-text notion-block-1b92c5ab818480e2b292c6a00db6a8e5"><b>ControlNet 解析</b></div><div class="notion-text notion-block-1b92c5ab8184809a8a55eeff70c20318">ControlNet 是一种改进的 <b>U-Net</b> 结构，它通过<b>引入额外的“控制”信息</b>（如 hint 输入）来 <b>引导</b> 神经网络的生成过程，使其能够更加精准地遵循某些约束或先验信息。在扩散模型（Diffusion Models）或图像生成任务中，ControlNet 可以用于特定任务，如边缘检测、深度信息控制、姿态引导等。</div><hr class="notion-hr notion-block-1b92c5ab818480b38a5eeeb7f275202e"/><div class="notion-row notion-block-1b92c5ab81848049ad62e4478d75a6e6"><div class="notion-column notion-block-1b92c5ab818480fba0a3e3f29fa63d92" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><div class="notion-text notion-block-1b92c5ab81848051865cf3bff66f9627"><b>🔹 ControlNet 相较于标准 U-Net 的主要改进</b></div><div class="notion-text notion-block-1b92c5ab818480738788e94c8e2ec080"><b>1️⃣ 额外的 hint 信息输入</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184808a8a5ed7b647b8ea15"><li>传统的 U-Net 主要依赖输入 x 进行图像生成，而 ControlNet <b>额外引入 hint 作为辅助信息</b>，提供某种先验引导。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480ed8aebda37f0641d8f"><li>hint 通过 <b>input_hint_block</b> 进行处理，这个模块是一个深度卷积网络（CNN），它将 hint 逐步下采样并映射到 model_channels 维度，使其与主 U-Net 结构兼容。</li></ul><div class="notion-text notion-block-1b92c5ab8184803693d8d9d9cf746edb"><b>2️⃣ zero_convs 额外控制分支</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848001a912ff2b2d0583d2"><li>zero_convs 是一系列 <b>零初始化卷积层</b>，用于让 ControlNet 直接在各个层级学习额外的偏差信息。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184800aae67cef32f07a15c"><li>这意味着 ControlNet 不是直接干预主 U-Net 的计算，而是以 <b>残差（Residual）</b> 方式调整输出，这样可以在保持预训练 U-Net 结构的同时，让 ControlNet 提供新的信息。</li></ul></div><div class="notion-spacer"></div><div class="notion-column notion-block-1b92c5ab818480d5998bd895e445e15f" style="width:calc((100% - (1 * min(32px, 4vw))) * 0.5)"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b92c5ab8184803986eddb8f01a2aeb8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A0b000a3c-e556-4211-b69a-366d1dd049c5%3Aimage.png?table=block&amp;id=1b92c5ab-8184-8039-86ed-db8f01a2aeb8&amp;t=1b92c5ab-8184-8039-86ed-db8f01a2aeb8" alt="notion image" loading="lazy" decoding="async"/></div></figure></div><div class="notion-spacer"></div></div><div class="notion-text notion-block-1b92c5ab81848033be71f08b2608ec86"><b>3️⃣ 编码器 input_blocks 中引入 guided_hint</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184800c8517fd28c1803b79"><li>在前向传播过程中，ControlNet <b>逐层融合 hint 信息</b>：</li><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184800c8517fd28c1803b79"><div class="notion-text notion-block-1b92c5ab818480939aeddb54e14fb1ca">1.	hint 经过 input_hint_block 处理后，变成 guided_hint</div><div class="notion-text notion-block-1b92c5ab818480b99da6c22fa48d8a61">2.	在编码阶段的 <b>第一层 input_blocks</b>，guided_hint 直接加到 h 上，使得 ControlNet 受 hint 影响</div><div class="notion-text notion-block-1b92c5ab8184804eb0d8e860e392c426">3.	后续层不会重复加 guided_hint</div></ul></ul><hr class="notion-hr notion-block-1b92c5ab81848000820fec1aff27b172"/><div class="notion-text notion-block-1b92c5ab8184802ab3d0ca79ad1280a2"><b>🔹 代码解析</b></div><div class="notion-text notion-block-1b92c5ab8184805e971fde6bdc8a55e5"><b>1️⃣ __init__ 构造函数</b></div><div class="notion-text notion-block-1b92c5ab8184802d8b19e566d07da793"><b>💡 新增的 hint 处理模块</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848038a6afc08486885953"><li>这个 input_hint_block 负责 <b>处理 hint 数据</b>，它是一个深度卷积网络：</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184802cad7bed0b3be34f58"><li><b>从 hint_channels 开始</b>，逐步增加通道数，并进行三次 <b>下采样 (stride=2)</b>，最终与 U-Net 主网络的 model_channels 维度匹配。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480a489c1ec31bb5b6b10"><li>这样可以确保 hint 信息可以直接用于调整 U-Net 的隐藏层特征。</li></ul><hr class="notion-hr notion-block-1b92c5ab81848083bb0ee6eb9bbbf643"/><div class="notion-text notion-block-1b92c5ab81848063b9c9d1a3d06f5b10"><b>2️⃣ forward() 计算流程</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184803f8869cb70f779af38"><li>这个 forward() 接受 <b>4 个主要输入</b>：</li></ul><div class="notion-text notion-block-1b92c5ab818480aa92e1f399f4c76366">1.	x - 原始图像</div><div class="notion-text notion-block-1b92c5ab818480d3bebceb4e9af38203">2.	hint - 额外的控制信号</div><div class="notion-text notion-block-1b92c5ab81848078870add192ab54ad3">3.	timesteps - 扩散模型的时间步</div><div class="notion-text notion-block-1b92c5ab818480aab4e0f21c952a0537">4.	context - 额外的上下文信息（如文本）</div><div class="notion-text notion-block-1b92c5ab818480e580a6c0fe5ea24c2b"><b>💡 计算时间嵌入</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848037b3a4d9d07096b4cc"><li>时间步 timesteps 先经过 timestep_embedding() 变换，再经过 self.time_embed 提取时间特征。</li></ul><div class="notion-text notion-block-1b92c5ab818480afb98cef729c9b3b5d"><b>💡 处理 hint 额外信息</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480e9a0abfc0628e2ce07"><li>hint 经过 input_hint_block 处理，生成 guided_hint，它将在 ControlNet 结构中 <b>融合到 U-Net 的编码过程中</b>。</li></ul><div class="notion-text notion-block-1b92c5ab818480a3b5f7f5f8b7c8f4e1"><b>💡 编码时融合 guided_hint</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184807b8942d6c8a5d4f9e3"><li>逐层遍历 input_blocks 进行编码：</li><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184807b8942d6c8a5d4f9e3"><li>在 <b>第一层</b>（guided_hint 仍然存在）</li><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184809fac3bf52013c8e256"><li>计算 h = module(h, emb, context)（标准 U-Net 计算）</li><li><b>直接 h += guided_hint，融合额外控制信息</b></li><li>然后 guided_hint = None，确保后续层 <b>不会</b> 继续加 hint</li></ul></ul></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848096a879f1a25692d70c"><li>其他层正常执行 h = module(h, emb, context)。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480d8b1e2c856c384809c"/><div class="notion-text notion-block-1b92c5ab81848005a00fd5bee8636b02"><b>3️⃣ middle_block 处理</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480508b3edc68be5de407"><li>在 <b>瓶颈层 middle_block 继续处理</b>，并存入 outs 作为最终控制信号。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480098faecf42a72636c8"/><div class="notion-text notion-block-1b92c5ab8184803c9936e4bddc2703a2"><b>🔹 ControlNet 主要作用</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480ff828ef9cf221ecb97"><li><b>与 UNet 主要区别：</b></li><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480ff828ef9cf221ecb97"><li>ControlNet <b>增加了 hint 作为额外控制信号</b>，用于引导扩散过程。</li><li><b>额外的 zero_convs 让 ControlNet 以残差方式调整特征</b>，不会破坏 U-Net 原始权重。</li><li><b>只在编码器 input_blocks 第一层添加 guided_hint</b>，避免后续层过度干预。</li></ul></ul><hr class="notion-hr notion-block-1b92c5ab818480bfbe7af5f5badda4e1"/><div class="notion-text notion-block-1b92c5ab818480888fddc270ed8ba138"><b>🔹 ControlNet VS ControlledUnetModel</b></div><table class="notion-simple-table notion-block-1b92c5ab818480f19aecf5e75bda06ee"><tbody><tr class="notion-simple-table-row notion-block-1b92c5ab818480ffb330cd396538b2f0"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>模型</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>核心机制</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>是否使用 hint</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>影响位置</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>作用</b></div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab818480d2b6cad55547c5c0cb"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>UNetModel</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">经典 U-Net</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">❌</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">仅依赖输入 x</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab8184809f96a2d5fabdf59bfe"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>ControlledUnetModel</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">允许 control 影响解码</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ (可选)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">仅影响 output_blocks</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">受控扩散模型，风格迁移</div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab8184801fa654d42d99c51d23"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>ControlNet</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">hint 直接影响编码器</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">✅ (必须)</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>仅影响 input_blocks 第一层</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">条件生成（草图，深度图）</div></td></tr></tbody></table><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b92c5ab8184806faad7e5e7cd5ebc61" data-id="1b92c5ab8184806faad7e5e7cd5ebc61"><span><div id="1b92c5ab8184806faad7e5e7cd5ebc61" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b92c5ab8184806faad7e5e7cd5ebc61" title="DDIMSampler"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">DDIMSampler</span></span></h4><div class="notion-text notion-block-1b92c5ab818480a4b221f42c516c8e12">DDIMSampler 主要用于 <b>扩散模型（Diffusion Model）</b> 的<b>高效采样</b>，采用 <b>DDIM (Denoising Diffusion Implicit Models)</b> 进行<b>降噪</b>，相比于传统 <b>DDPM (Denoising Diffusion Probabilistic Model)</b> 具有更快的采样速度，同时可以调整 eta 来控制生成样本的多样性。</div><hr class="notion-hr notion-block-1b92c5ab8184801cb261d91f00d313da"/><div class="notion-text notion-block-1b92c5ab818480ea8013d232dea98054"><b>🔹 DDIMSampler 主要结构</b></div><div class="notion-text notion-block-1b92c5ab818480dca2acc15eaa870e18"><b>1️⃣ 初始化</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848027b9bad9c7d9dc172f"><li>绑定 <b>扩散模型 model</b>，并读取 <b>总时间步长</b> ddpm_num_timesteps。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480de99f5d1df2497f3fb"><li>schedule=&quot;linear&quot; 代表时间步（timestep）的调度方式。</li></ul><hr class="notion-hr notion-block-1b92c5ab81848055bf33de968886afd4"/><div class="notion-text notion-block-1b92c5ab81848056bad8ea0e420c1925"><b>2️⃣ 预计算采样公式</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480489c32e5d85617549f"><li>该函数预计算 <b>DDIM 采样所需的时间步</b>、方差、累计 α (alphas_cumprod) 等参数。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184801c9368e755adb6e3fc"><li>ddim_eta=0.0 对应 <b>确定性采样</b>（即 DDIM 采样）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848057b351c117af9a412f"><li>ddim_eta&gt;0.0 时会引入 <b>随机性</b>（向 DDPM 采样靠近）。</li></ul><div class="notion-text notion-block-1b92c5ab818480e3b5dbc27198593cb6"><b>关键参数</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848042b788e9a948f66118"><li>计算 <b>累计噪声方差</b> sqrt_one_minus_alphas_cumprod，用于后续 <b>从噪声恢复图像</b>。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480a3a76ec2531d93f669"/><div class="notion-text notion-block-1b92c5ab818480459ee4e4ad411acb15"><b>3️⃣ 主要采样流程</b></div><div class="notion-text notion-block-1b92c5ab818480f28808e16a8dc5df04"><b>🟢 sample() 入口</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848022968eca641794bb50"><li>S: 采样步数（通常 S &lt;&lt; self.ddpm_num_timesteps，即少量步数生成高质量图像）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848040856ec5cdb87a665e"><li>conditioning: 控制信号（如文本、深度图等）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480eeb434eb33bcdd7098"><li>x_T: 初始噪声（如果 None，默认 torch.randn(shape)）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480a1ba5ed11a526da5ab"><li>unconditional_guidance_scale: 文本控制权重（如 CLIP 指导）。</li></ul><div class="notion-text notion-block-1b92c5ab818480c49ed7f01c07b9988e"><b>🟢 ddim_sampling() 采样核心</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848092816ddd3dc0bd6200"><li>x_T=None 时，使用<b>随机噪声</b> torch.randn(shape, device=device) 作为初始图像。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480009babedc443a308bf"><li><b>时间步 timesteps 递减</b>（由 T 逐步减少到 0）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480e0a4ccf3f91d1d4e17"><li>self.p_sample_ddim() 进行<b>逐步去噪</b>。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480a78c23e00d95153bc2"/><div class="notion-text notion-block-1b92c5ab818480b7ada4d1a97fe731fa"><b>4️⃣ 单步降噪 p_sample_ddim()</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848080990afa976418cc2d"><li>计算<b>预测噪声 </b>：</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184804f8c3fe5ed05975ef5"><li>计算去噪后的 x_0：</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480e08288e5b2ed66f5a1"><li>计算<b>下一步 x_prev</b>：</li></ul><div class="notion-text notion-block-1b92c5ab81848001a101e563feec613f">其中：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184803dbf9bf75abd57d553"><li>dir_xt = (1. - a_prev - sigma_t**2).sqrt() * e_t <b>计算噪声方向</b>。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480e48be7ece230254c6d"><li>noise = sigma_t * noise_like(...) <b>加权随机噪声</b>（当 eta=0 时无噪声）。</li></ul><div class="notion-text notion-block-1b92c5ab8184803d92ddcc6db37d365e"><b>eta 影响采样方程</b></div><div class="notion-text notion-block-1b92c5ab8184806db194d508480dd8e4">在 <b>DDIM 采样公式</b> 中：</div><div class="notion-text notion-block-1b92c5ab8184809babe4e30b05606ccb">其中：</div><div class="notion-text notion-block-1b92c5ab818480f1bfa2e35186985152"> 表示噪声尺度，<b>由 eta 控制</b>：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848043a7e5d3e65b458835"><li>当 eta=0.0 时，<!-- -->，完全确定性采样。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480f59674c76f387b647f"><li>当 eta&gt;0.0 时，<!-- -->，加入随机噪声 <!-- -->，增加多样性。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480ab9f12d4d0dde88706"/><div class="notion-text notion-block-1b92c5ab818480b0951cf57dbd3eb0ab"><b>🔹 DDIMSampler 的作用</b></div><div class="notion-text notion-block-1b92c5ab818480b9b130c6d9361044a1">1.	<b>更快的采样</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480aba055c65019c84763"><li>S &lt;&lt; T，可使用 <b>10~50</b> 步采样，而 DDPM 需要 <b>1000+ 步</b>。</li></ul><div class="notion-text notion-block-1b92c5ab818480f899c8f510e48d548c">2.	<b>可调控的生成</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480d3ae65c3c5ff58a359"><li>eta=0.0：完全<b>确定性采样</b>（一致的结果）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848086a818f423245eff21"><li>eta&gt;0.0：增加<b>随机性</b>（提升多样性）。</li></ul><div class="notion-text notion-block-1b92c5ab8184805d9c67fb25aaf6d5ba">3.	<b>支持文本引导（Guidance）</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480feb726e6385468c3c9"><li>unconditional_guidance_scale 控制文本影响程度。</li></ul><hr class="notion-hr notion-block-1b92c5ab8184804b8ce7ed860e0d2c6f"/><div class="notion-text notion-block-1b92c5ab818480918ba2c20541f538d8"><b>🔹 结论</b></div><div class="notion-text notion-block-1b92c5ab818480deb664ff69ffd9085a">✅ <b>DDIM 采样器</b>是 <b>扩散模型中高效的采样方法</b>，可以大幅提升推理速度，并允许调整多样性，使得 <b>扩散模型生成更加灵活高效</b>。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b92c5ab818480a6b4a5d6b76d9b0543" data-id="1b92c5ab818480a6b4a5d6b76d9b0543"><span><div id="1b92c5ab818480a6b4a5d6b76d9b0543" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b92c5ab818480a6b4a5d6b76d9b0543" title="Models"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Models</span></span></h3><div class="notion-text notion-block-1b92c5ab81848027a0b1c9840a586d28">ControlNet里面模型的继承思路是DDPM→ LDM→其他。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b92c5ab818480b09f0def614d629a09" data-id="1b92c5ab818480b09f0def614d629a09"><span><div id="1b92c5ab818480b09f0def614d629a09" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b92c5ab818480b09f0def614d629a09" title="DDPM"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">DDPM</span></span></h4><div class="notion-text notion-block-1b92c5ab81848084980cd421230ed1a5"><b>DDPM (Denoising Diffusion Probabilistic Models) 解析</b></div><div class="notion-text notion-block-1b92c5ab818480c4b917dc5a3b67b3f2"><b>DDPM（去噪扩散概率模型）</b>，它是一种基于扩散过程的生成模型。DDPM 通过向数据添加噪声进行训练，然后通过学习逆过程去噪，从随机噪声生成清晰的图像。</div><hr class="notion-hr notion-block-1b92c5ab818480b5bf51fecbf7d36fa5"/><div class="notion-text notion-block-1b92c5ab818480bf8d16cf04a6357f90"><b>代码核心结构</b></div><div class="notion-text notion-block-1b92c5ab81848084a1abdab28e9edf12"><b>1️⃣ 初始化 (__init__)</b></div><div class="notion-text notion-block-1b92c5ab8184803bba30eaaad73f1804"><b>作用</b>：初始化 DDPM 关键参数，并定义模型结构。</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848028b7f9ede39a55fd54"><li>unet_config：U-Net 结构的配置文件，扩散模型通常基于 U-Net 进行训练。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480f39bc9f6ed1cfc16cc"><li>timesteps=1000：扩散过程的时间步数（T），表示扩散链的长度。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480709113d25947d43b3e"><li>beta_schedule=&quot;linear&quot;：用于控制扩散过程的噪声增加方式，常见的有线性 (linear) 或余弦 (cosine) 。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848099befed350ab3166ce"><li>loss_type=&quot;l2&quot;：损失函数选择，默认为 <b>L2损失（均方误差 MSE）</b>。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848046b892ef1bfa5f2152"><li>parameterization=&quot;eps&quot;：指示模型的预测目标：</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184800cbb3ccf2112928548"><li>&quot;eps&quot;：预测加噪的噪声 ε（最常用）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480efafafd51f85c3fc67"><li>&quot;x0&quot;：直接预测无噪声图像 x₀ 。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480518dccec4566b2629c"><li>&quot;v&quot;：预测 x₀ 和 ε 的加权组合。</li></ul><hr class="notion-hr notion-block-1b92c5ab81848014bff1e1846b0e5a38"/><div class="notion-text notion-block-1b92c5ab818480738ea2dc693ebb2113"><b>2️⃣ 噪声调度 (register_schedule)</b></div><div class="notion-text notion-block-1b92c5ab81848024b567fa59e496f3d1"><b>作用</b>：定义噪声的扩散调度，即 β 和 α 的计算方式。</div><div class="notion-text notion-block-1b92c5ab8184801d8aa7c46e71ae293a">关键变量：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848044b3d2f6202deff4f7"><li>betas：表示每个时间步添加的噪声量（βₜ）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480818ffae00ba1f8181b"><li>alphas = 1 - betas：表示保持原始数据的部分。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480469519da98b4df731a"><li>alphas_cumprod = np.cumprod(alphas, axis=0)：累乘所有 αₜ，用于计算 q(x_t | x_0) 的均值。</li></ul><div class="notion-text notion-block-1b92c5ab818480cebaebed7ce0319bd4">这些变量决定了扩散过程的噪声模式，使模型能够从噪声数据中恢复出原始数据。</div><hr class="notion-hr notion-block-1b92c5ab818480afa8eecd0054b099b4"/><div class="notion-text notion-block-1b92c5ab818480ec9adec70a23fd9fb0"><b>3️⃣ 前向传播 (forward)</b></div><div class="notion-text notion-block-1b92c5ab8184802dbfecf7ad38dea8a1"><b>作用</b>：计算训练过程中的损失。</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184805eb16fef0102d20610"><li>t = torch.randint(0, self.num_timesteps, (x.shape[0],))</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848075b492c34e751e88a2"><li>这行代码随机选择 t，表示在扩散链中某个时间步对图像 x 进行加噪。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184808e8a17f3c1300d90b0"><li>self.p_losses(x, t, *args, **kwargs)：</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848036acc9d1d1e1a93508"><li>计算训练损失，核心方法如下：</li></ul><div class="notion-text notion-block-1b92c5ab818480fba382efaae455dd1f">其中：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184803eb804c8f63f9d01d1"><li>x_noisy = self.q_sample(x_start, t, noise)：生成加噪后的数据 x_t。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184801abdbcf942e1ebbe0a"><li>model_out = self.model(x_noisy, t)：让 U-Net 预测噪声（或 x0）。</li></ul><div class="notion-text notion-block-1b92c5ab818480cca5f0c9cf77629e80"><b>计算损失</b></div><div class="notion-text notion-block-1b92c5ab81848073a230f0f4b743621c">如果 parameterization == &quot;eps&quot;，那么 model_out 代表的是噪声 ε，损失函数就是：</div><div class="notion-text notion-block-1b92c5ab81848017b500d43e117f3123">计算 L2 Loss：</div><hr class="notion-hr notion-block-1b92c5ab818480eba0befcdb689e44f1"/><div class="notion-text notion-block-1b92c5ab818480c1a0b2c5479f98490c"><b>4️⃣ 前向扩散过程 (q_sample)</b></div><div class="notion-text notion-block-1b92c5ab8184808b85e9c16dbf45b5a4"><b>作用</b>：在训练过程中，把真实数据 x_0 逐步加噪，生成 x_t。</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848059a162d3fec8fad06d"><li><code class="notion-inline-code">x_t = sqrt(alpha_cumprod) * x_0 + sqrt(1 - alpha_cumprod) * noise</code></li><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848059a162d3fec8fad06d"><div class="notion-text notion-block-1b92c5ab8184805f8485ff2706d67f57">这个公式来自于 <b>前向扩散公式</b>：</div></ul></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184806a8d1ed93b93550ed4"><li>sqrt(alphas_cumprod) 控制 x_0 贡献的部分</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184803dbd9ee53e6072e848"><li>sqrt(1 - alphas_cumprod) 控制噪声的比例。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480b3b1aaf9f27901c41c"/><div class="notion-text notion-block-1b92c5ab8184808cbd98d3df06f06798"><b>5️⃣ 反向去噪 (p_sample)</b></div><div class="notion-text notion-block-1b92c5ab818480f7b4fbd2dc31939783"><b>作用</b>：在推理阶段，通过去噪逐步恢复数据。</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184809c9aa1c35cbb6b3c66"><li>model_mean：当前 x_t 估计出的均值 μ_t。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184804aa035fc81afc2d212"><li>model_log_variance：估计出的方差 Σ_t。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480a3aa5dfc72b3519288"><li>noise：采样的高斯噪声。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184800f9d24d6917c61bcb4"><li>计算：</li><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184800f9d24d6917c61bcb4"></ul></ul><div class="notion-text notion-block-1b92c5ab818480118ec8cc46ca752196">其中：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184807199b4e72701241afb"><li>μ_t = model_mean</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480e78ebbe3f238141115"><li>σ_t = exp(0.5 * model_log_variance)</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184803c8a57e6986e590206"><li>ε = noise</li></ul><hr class="notion-hr notion-block-1b92c5ab8184802d9060f74ade722af7"/><div class="notion-text notion-block-1b92c5ab8184803c8860fa6d967bfa6d"><b>6️⃣ 图像生成 (p_sample_loop)</b></div><div class="notion-text notion-block-1b92c5ab81848061ae0ec8a69bf09034"><b>作用</b>：从纯噪声开始，通过多步去噪生成样本。</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848042bdb6d9c953d21ebd"><li><b>输入</b>：随机噪声 img = torch.randn(shape, device=device)。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184806ebb0ee956496f06b5"><li><b>去噪</b>：逐步从 x_T 逆扩散到 x_0。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480669ca9eb1daa3952b2"><li><b>返回</b>：最终去噪后的 img。</li></ul><hr class="notion-hr notion-block-1b92c5ab8184800b803fd59511c82941"/><div class="notion-text notion-block-1b92c5ab8184808e86d3d42a46f806be"><b>总结</b></div><div class="notion-text notion-block-1b92c5ab818480feb671ebea31a2ad3d">📌 <b>DDPM 的核心流程</b></div><div class="notion-text notion-block-1b92c5ab818480e29970f37c648e14b1">1.	<b>训练阶段</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184802fb52df95bdc4b7154"><li>从 x_0 开始，逐步加噪 x_t = sqrt(alphas_cumprod) * x_0 + sqrt(1 - alphas_cumprod) * noise。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480ed905ceb52e6800bd6"><li>让 U-Net 学习 <!-- -->，即预测 x_0 或 ε。</li></ul></div></div><div class="notion-text notion-block-1b92c5ab818480f99001c6a819ec4c46">2.	<b>推理阶段</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480469580c43040e0ba25"><li>从 x_T（纯噪声）开始，逆扩散回 x_0。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480d98e09e4437997a33c"><li>逐步去噪 x_t = model_mean + sigma * noise，最终生成清晰图像。</li></ul></div></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b92c5ab818480e4913fedd895b2bb2b" data-id="1b92c5ab818480e4913fedd895b2bb2b"><span><div id="1b92c5ab818480e4913fedd895b2bb2b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b92c5ab818480e4913fedd895b2bb2b" title="LDM"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">LDM</span></span></h4><div class="notion-text notion-block-1b92c5ab818480389bfcedf3341cbfa8">LatentDiffusion 继承自 DDPM（Denoising Diffusion Probabilistic Models），是 <b>稳定扩散模型（Stable Diffusion）</b> 及类似框架的核心。它结合了扩散模型与 <b>VAE（变分自编码器）</b>，在潜空间（latent space）中进行扩散，从而降低计算成本并提高生成质量。</div><hr class="notion-hr notion-block-1b92c5ab818480419e4ee8b480cd2959"/><div class="notion-text notion-block-1b92c5ab818480fabcdcc8291c1330b8"><b>📌 1. 核心思想</b></div><div class="notion-text notion-block-1b92c5ab81848089bb7cc7d7c9a81650">与标准 DDPM 直接在像素空间进行扩散不同，LatentDiffusion：</div><div class="notion-text notion-block-1b92c5ab818480188cc5e7a45dcd2c54">1.	<b>首先使用 VAE（Autoencoder）将图像编码到潜变量 z</b>，然后在潜变量上进行扩散。</div><div class="notion-text notion-block-1b92c5ab818480c397e0e6c1f65f7676">2.	<b>扩散过程</b> 仍然遵循 DDPM 逻辑，但在 <b>更低维的潜空间</b> 中进行，减少计算复杂度。</div><div class="notion-text notion-block-1b92c5ab818480f485b9fa55a38e287a">3.	<b>反扩散后，VAE 将 z 解码回图像</b>，生成最终结果。</div><blockquote class="notion-quote notion-red notion-block-1b92c5ab8184809aac58d4a0bafe246a"><div>这个和Dreamer是一个思路</div></blockquote><hr class="notion-hr notion-block-1b92c5ab818480f2a401e49bb4d5bb07"/><div class="notion-text notion-block-1b92c5ab818480e4aa70c96110fae6a1"><b>📌 2. 代码结构</b></div><div class="notion-text notion-block-1b92c5ab81848079b82ed774773d2b42"><b>① 初始化 (__init__)</b></div><div class="notion-text notion-block-1b92c5ab818480bfa4cfc1bfb7b95559"><b>主要参数：</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184809f878deaf3e91b05de"><li>first_stage_config：定义 <b>VAE 编码器/解码器</b> 的参数。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480f1b643da0746a5033a"><li>cond_stage_config：定义 <b>条件模型（文本/图像等）</b> 的参数。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480f0b9caf12a7d1bf57a"><li>num_timesteps_cond：定义 <b>条件调度</b> 的时间步数。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480efbea8df4e8dc30290"><li>scale_factor：用于缩放潜变量 z，控制图像的动态范围。</li></ul><div class="notion-text notion-block-1b92c5ab818480349727c70f385271d5"><b>初始化过程中：</b></div><div class="notion-text notion-block-1b92c5ab81848020bb93ef2931b8ecd8">1.	<b>加载 DDPM 的扩散调度</b>。</div><div class="notion-text notion-block-1b92c5ab818480738715ffcee613aaa5">2.	<b>创建 VAE (first_stage_model) 和条件模型 (cond_stage_model)</b>。</div><div class="notion-text notion-block-1b92c5ab818480328c03f50455996ea3">3.	<b>设置 conditioning_key</b>，确定 U-Net 采用 <b>拼接 (concat) 还是 交叉注意力 (cross-attention)</b> 作为条件方式。</div><hr class="notion-hr notion-block-1b92c5ab818480608660c67e47700b7c"/><div class="notion-text notion-block-1b92c5ab81848097ad25e9ee4a5969e9"><b>② 训练前预处理</b></div><div class="notion-text notion-block-1b92c5ab8184803197d6c494093e1d1a"><b>作用：</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184805c9b54dfc4d6671b5f"><li>在 <b>第一个训练 batch</b> 之前，如果 scale_by_std=True，则：</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848029b252f752f7faf9dc"><li>计算 z 的标准差，并 <b>动态缩放</b> scale_factor 以标准化分布。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480adbfa2d4583d62c891"/><div class="notion-text notion-block-1b92c5ab8184808d9076dba323c4e95b"><b>③ VAE 编码 &amp; 解码</b></div><div class="notion-text notion-block-1b92c5ab8184803e8627d1a2e4054b2e"><b>作用：</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184803f9296c5e586b221fc"><li>encode_first_stage(x)：将 x 通过 <b>VAE 编码</b> 得到 z。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480dc958fc1f4e4e83a9e"><li>decode_first_stage(z)：将 z <b>解码回图像</b>，最终生成。</li></ul><hr class="notion-hr notion-block-1b92c5ab8184806bb1dded0fe425aa92"/><div class="notion-text notion-block-1b92c5ab8184803896e5faf80420e4f5"><b>④ 训练输入 (get_input)</b></div><div class="notion-text notion-block-1b92c5ab818480d08532c6da7fd79d83"><b>作用：</b></div><div class="notion-text notion-block-1b92c5ab818480e8b529cdb64784ea3e">1.	<b>获取 x 并编码为 z</b>。</div><div class="notion-text notion-block-1b92c5ab81848027b939eb24e5c16a5c">2.	<b>获取条件信息 c</b>：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848035a451ca6a884d5edf"><li>若 conditioning_key = &quot;crossattn&quot;，则使用文本编码 c_crossattn。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480c4b8bfdb26574a6e46"><li>若 conditioning_key = &quot;concat&quot;，则使用额外的图像 c_concat 作为拼接条件。</li></ul><hr class="notion-hr notion-block-1b92c5ab81848078a153e82e8c55fab5"/><div class="notion-text notion-block-1b92c5ab81848093861df1281505ecbc"><b>⑤ 计算损失 (p_losses)</b></div><div class="notion-text notion-block-1b92c5ab81848047838ce6f332369f96"><b>扩散过程：</b></div><div class="notion-text notion-block-1b92c5ab818480c2a05ee004a3df424b">1.	<b>从 x_start 生成 x_noisy</b>，模拟 t 时刻的噪声图像。</div><div class="notion-text notion-block-1b92c5ab81848075a743cf90054eef2f">2.	<b>U-Net 预测 ε 或 x0</b>，从 x_noisy 还原干净图像。</div><div class="notion-text notion-block-1b92c5ab818480c4a3dbcfc9730e1fe1">3.	<b>计算损失</b>：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480dbba94fe31966805b9"><li>如果 parameterization = &quot;eps&quot;，则 <b>预测噪声 ε</b>，损失函数为 MSE(ε_pred, ε)。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184800f811ef149ccc167be"><li>如果 parameterization = &quot;x0&quot;，则 <b>直接预测 x0</b>，损失为 MSE(x0_pred, x0)。</li></ul><hr class="notion-hr notion-block-1b92c5ab8184805e92d5c25aef6ef74d"/><div class="notion-text notion-block-1b92c5ab8184802ea801c1215943241a"><b>⑥ 采样 (p_sample_loop &amp; sample)</b></div><div class="notion-text notion-block-1b92c5ab81848087b85cd6ddbb54b72c"><b>作用</b>：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848020b940fd3015465e05"><li>通过 p_sample_loop() <b>从纯噪声 x_T 逆扩散回 x_0</b>，最终生成图像。</li></ul><hr class="notion-hr notion-block-1b92c5ab8184809ab3d5d9e3d0f9ddac"/><div class="notion-text notion-block-1b92c5ab81848094a820eff8ff1caad0"><b>⑦ 采样过程 (p_sample)</b></div><div class="notion-text notion-block-1b92c5ab818480679e09d6f0505eb25b"><b>核心方程</b>：</div><div class="notion-text notion-block-1b92c5ab81848069b985d89c280b25a2">其中：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184801f94bac02e0eef0ea9"><li>μ_t 由 model_mean 计算。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184804ca369c58ca93a64e2"><li>σ_t 由 model_log_variance 计算。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184800293d0de9420c453ae"><li>ε 为高斯噪声。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480c9838dcee1bd199ce5"/><div class="notion-text notion-block-1b92c5ab818480a3997ee0dd46f23610"><b>⑧ 额外特性</b></div><div class="notion-text notion-block-1b92c5ab818480ccaf46e942db6eda22"><b>💡 1. 无条件采样 (get_unconditional_conditioning)</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480d5a57bfd88f1ec5a1c"><li>用于 <b>classifier-free guidance</b>（无分类标签引导）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480e98540fbfa83ca6012"><li>生成 <b>空白条件</b> 以提高采样质量。</li></ul><div class="notion-text notion-block-1b92c5ab818480ea950ac510c925cee6"><b>💡 2. 进阶采样 (progressive_denoising)</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184804e9f18eb23f59237c3"><li>逐步去噪并 <b>记录中间状态</b>，可用于可视化整个扩散过程。</li></ul><hr class="notion-hr notion-block-1b92c5ab81848031bbc5fc15927c06dd"/><div class="notion-text notion-block-1b92c5ab818480f99588dec29690e7d2"><b>📌 3. 总结</b></div><div class="notion-text notion-block-1b92c5ab818480de8bc2c72f3f3ae5fa">💡 LatentDiffusion（LDM） 结合了 <b>扩散模型（DDPM）+ VAE（变分自编码器）+ 条件输入（文本/图像）</b>：</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480b1a583ee58e3ec66c1"><li><b>通过 VAE 降维</b>：在潜变量 z 上运行扩散，提高效率。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184807997e6f9e5b708ee49"><li><b>U-Net 预测 ε 或 x0</b>：指导采样过程。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480239a37ea29aeb862aa"><li><b>支持文本 &amp; 图像条件</b>：</li><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480239a37ea29aeb862aa"><li>c_crossattn（文本条件）</li><li>c_concat（额外图像条件）</li></ul></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480ab8facf3f212712066"><li><b>最终生成高质量图像</b>。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480098b4cf27a9635b464"/><div class="notion-text notion-block-1b92c5ab818480549559dcc65871062b">✅ <b>LDM 是 Stable Diffusion 的核心框架！</b> 🚀</div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184803b824df3f05ab5f4aa"><li><b>比 DDPM 更高效</b>（在潜变量上运行）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848021beb9c5ec704a6ac6"><li><b>支持文本-图像扩散</b>（如 Stable Diffusion）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480e8bbe8d2277c3879c0"><li><b>采样方式丰富</b>（DDIM、progressive_denoising）。</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b92c5ab81848056b10ae99b7c3ce398" data-id="1b92c5ab81848056b10ae99b7c3ce398"><span><div id="1b92c5ab81848056b10ae99b7c3ce398" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b92c5ab81848056b10ae99b7c3ce398" title="ControledLDM"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">ControledLDM</span></span></h4><div class="notion-text notion-block-1b92c5ab818480de8179fa50ebeb2aa8">ControlLDM 是一个基于 <b>Latent Diffusion Model (LDM)</b> 的 <b>受控扩散模型</b>，它在标准 LDM 基础上加入了 <b>ControlNet 控制机制</b>，用于<b>在扩散过程中施加额外的引导（control hints）</b>，以便更好地控制生成图像的结构和内容。</div><hr class="notion-hr notion-block-1b92c5ab818480879726f1fec6212ce9"/><div class="notion-text notion-block-1b92c5ab818480da91aaec6c813e8f75"><b>🔹 ControlLDM 的主要改进</b></div><div class="notion-text notion-block-1b92c5ab8184804a8dc2e4380c93087d">1.	<b>加入 ControlNet</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480608678ddf7239341cf"><li>额外增加 control_model，用于处理控制信息（例如边缘检测、深度图等）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480b18636ca7736bde4be"><li>通过 control_key 指定输入数据中的控制信息字段。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480668f54c4714fbf276b"><li>only_mid_control 控制是否仅在中间层施加控制。</li></ul></div></div><div class="notion-text notion-block-1b92c5ab81848081b69bc38821ef692e">2.	<b>自定义输入处理</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480fc81ebd1268209ed27"><li>在 get_input 方法中，额外提取 <b>control hints</b>（如边缘检测、深度信息）。</li><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480fc81ebd1268209ed27"><li>这些控制数据被转换为 <b>通道优先格式（b c h w）</b>，并送入 ControlNet。</li></ul></ul></div></div><div class="notion-text notion-block-1b92c5ab81848085b482fb64fb54f0d9">3.	<b>修改 apply_model 方法</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184805e8adfcecb7b11afb0"><li>apply_model 负责模型前向传播。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848032bb52dfe63ce1f7ee"><li>ControlNet 生成 <b>控制向量</b> 并施加到 diffusion_model 之中。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480499955cc7ae116135c"><li>计算方式：</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848071bc4efbc24945f381"><li>这样，<b>ControlNet 影响 LDM 的采样过程</b>，使得生成结果更符合控制信息。</li></ul></div></div><div class="notion-text notion-block-1b92c5ab81848073913cc98e366f3f00">4.	<b>日志记录 log_images</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab81848084b298ea29fe7d15cd"><li>记录<b>重建图像</b>、<b>控制条件</b>、<b>去噪过程</b>等信息，以便可视化 LDM 的行为。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184801c9ee6fd86d990ccb2"><li>计算 <b>unconditional guidance</b>，用于 CFG 采样（Classifier-Free Guidance）。</li></ul></div></div><div class="notion-text notion-block-1b92c5ab818480b9889bee33b72d3808">5.	<b>优化器 configure_optimizers</b><div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480688e95dcd9a9b39640"><li>只优化 control_model，保持 LDM 其他部分不变（sd_locked 控制是否锁定 Stable Diffusion 组件）。</li></ul><ul class="notion-list notion-list-disc notion-block-1b92c5ab818480738607fe664703d8d3"><li>使用 AdamW 进行优化。</li></ul></div></div><div class="notion-text notion-block-1b92c5ab818480f1b3bbd2d66ae5d762">6.	<b>低显存模式 low_vram_shift</b></div><ul class="notion-list notion-list-disc notion-block-1b92c5ab8184801a8593fec2b1e122c9"><li><b>在推理时释放部分显存</b>，将不必要的组件移到 CPU，提高大模型的可用性。</li></ul><hr class="notion-hr notion-block-1b92c5ab818480abb3efdba0250c73fc"/><div class="notion-text notion-block-1b92c5ab8184809198e0f4740aa3c68a"><b>🔹 代码解析</b></div><table class="notion-simple-table notion-block-1b92c5ab8184806cacdfd4da8d6466ab"><tbody><tr class="notion-simple-table-row notion-block-1b92c5ab818480ff9191e4a702fd0b90"><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>组件</b></div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><b>作用</b></div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab81848071b3e7e9906281c792"><td class="" style="width:120px"><div class="notion-simple-table-cell">control_model</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">额外的 ControlNet，提供额外的控制信号</div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab818480389276d4feb9c32395"><td class="" style="width:120px"><div class="notion-simple-table-cell">get_input</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">解析输入，并提取 control 作为额外的条件</div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab818480eaa8fdf362ea63dc8f"><td class="" style="width:120px"><div class="notion-simple-table-cell">apply_model</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">结合 ControlNet 的输出，影响扩散模型</div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab81848061a66efe152cf30c30"><td class="" style="width:120px"><div class="notion-simple-table-cell">log_images</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">记录生成过程中的各个阶段，便于调试</div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab818480399512e4b9c5e887fe"><td class="" style="width:120px"><div class="notion-simple-table-cell">configure_optimizers</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">只优化 ControlNet，不影响 LDM 主体</div></td></tr><tr class="notion-simple-table-row notion-block-1b92c5ab81848044b44ee6cc982c95f4"><td class="" style="width:120px"><div class="notion-simple-table-cell">low_vram_shift</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">在推理时减少显存占用，提高效率</div></td></tr></tbody></table></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[数据结构与算法]]></title>
            <link>https://www.wyaaaattwho.xyz/article/DSA</link>
            <guid>https://www.wyaaaattwho.xyz/article/DSA</guid>
            <pubDate>Fri, 27 Dec 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-1692c5ab81848049831dcfb348ba6398"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><a class="notion-page-link notion-block-1692c5ab81848096a58ef99991dcd9eb" href="/1692c5ab81848096a58ef99991dcd9eb"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="1️⃣">1️⃣</span></div><span class="notion-page-title-text">绪论</span></span></a><a class="notion-page-link notion-block-1692c5ab8184803a912fe2677479859e" href="/1692c5ab8184803a912fe2677479859e"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="2️⃣">2️⃣</span></div><span class="notion-page-title-text">线性表 </span></span></a><a class="notion-page-link notion-block-1692c5ab8184800384f4ecc5979243d9" href="/1692c5ab8184800384f4ecc5979243d9"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="3️⃣">3️⃣</span></div><span class="notion-page-title-text"><b>栈和队列</b></span></span></a><a class="notion-page-link notion-block-1692c5ab818480f79464c1c983f78022" href="/1692c5ab818480f79464c1c983f78022"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="4️⃣">4️⃣</span></div><span class="notion-page-title-text">数组，串和广义表</span></span></a><a class="notion-page-link notion-block-1692c5ab81848002beead8fd06f900fd" href="/1692c5ab81848002beead8fd06f900fd"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="5️⃣">5️⃣</span></div><span class="notion-page-title-text">树和二叉树</span></span></a><a class="notion-page-link notion-block-1692c5ab818480378eabc5caf2a2bdad" href="/1692c5ab818480378eabc5caf2a2bdad"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="6️⃣">6️⃣</span></div><span class="notion-page-title-text">集合和字典</span></span></a><a class="notion-page-link notion-block-1692c5ab818480f59ecad217d0214dbb" href="/1692c5ab818480f59ecad217d0214dbb"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="7️⃣">7️⃣</span></div><span class="notion-page-title-text">搜索结构</span></span></a><a class="notion-page-link notion-block-1692c5ab81848083928bf5354899d452" href="/1692c5ab81848083928bf5354899d452"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="8️⃣">8️⃣</span></div><span class="notion-page-title-text">图</span></span></a><a class="notion-page-link notion-block-1692c5ab8184807cba84d2941ac7ad4d" href="/1692c5ab8184807cba84d2941ac7ad4d"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="9️⃣">9️⃣</span></div><span class="notion-page-title-text">排序</span></span></a><a class="notion-page-link notion-block-1692c5ab818480aa8982f6bd1da1e457" href="/1692c5ab818480aa8982f6bd1da1e457"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🔟">🔟</span></div><span class="notion-page-title-text"><b>多级索引结构</b></span></span></a><a class="notion-page-link notion-block-1692c5ab8184801992b9e1d1ca688fb8" href="/1692c5ab8184801992b9e1d1ca688fb8"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="👾">👾</span></div><span class="notion-page-title-text">算法部分</span></span></a></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convex optimization]]></title>
            <link>https://www.wyaaaattwho.xyz/article/convex</link>
            <guid>https://www.wyaaaattwho.xyz/article/convex</guid>
            <pubDate>Fri, 22 Nov 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-1462c5ab8184802a96c4de9de2548e95"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><a class="notion-page-link notion-block-1462c5ab8184811bbe50d3630830c49a" href="/1462c5ab8184811bbe50d3630830c49a"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="1️⃣">1️⃣</span></div><span class="notion-page-title-text">Intro</span></span></a><a class="notion-page-link notion-block-1462c5ab818481a984c4d97dd0fa3ba1" href="/1462c5ab818481a984c4d97dd0fa3ba1"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="2️⃣">2️⃣</span></div><span class="notion-page-title-text">Convex sets</span></span></a><a class="notion-page-link notion-block-1462c5ab81848173adf9e7e8780959c9" href="/1462c5ab81848173adf9e7e8780959c9"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="3️⃣">3️⃣</span></div><span class="notion-page-title-text">Convex function</span></span></a><a class="notion-page-link notion-block-1462c5ab818481fa8c5cd6148eb1ba35" href="/1462c5ab818481fa8c5cd6148eb1ba35"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="4️⃣">4️⃣</span></div><span class="notion-page-title-text">Convex optimization problems</span></span></a><a class="notion-page-link notion-block-1692c5ab818480a5af2ee52bdf2f560e" href="/1692c5ab818480a5af2ee52bdf2f560e"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="5️⃣">5️⃣</span></div><span class="notion-page-title-text">Duality</span></span></a></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ 简明机器学习 Easy Machine Learning]]></title>
            <link>https://www.wyaaaattwho.xyz/article/ML</link>
            <guid>https://www.wyaaaattwho.xyz/article/ML</guid>
            <pubDate>Fri, 02 Aug 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-a2d01c7924c74c139be9b5337a1c7a19"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-1442c5ab81848039b3c2f61b202fda5d">Easy Machine Learning guide！</div><div class="notion-text notion-block-1442c5ab818480d191fded59559462cb">This is a simplified machine learning guidebook written entirely by myself. The initial idea was to find a path to learn machine learning independently, as our school doesn’t offer any useful courses on the subject. Later, I realized I could write down what I’d learned as a blog for my friends and others to read, which also serves as a way to review the material myself.</div><div class="notion-text notion-block-1442c5ab81848002be91f90dbac37a11">The blog is primarily based on lectures from Stanford’s CS229 and Machine Learning by Zhi-Hua Zhou. I removed some outdated or irrelevant content and added insights from blogs I’ve read. I typed this all in Notion myself, so there might be some typo and so on, please let me know if you get one.</div><div class="notion-text notion-block-1442c5ab818480439554f43d635dbec9">这里是简明机器学习系列博客。鉴于现在国内大多数本科课程大多无法应对大家就业和实际使用的需求，直接看《机器学习》或者《统计学习方法》又难免比较难以入门，特参考CS229和周，李两位老师的书写出了这个博客，希望你能喜欢。对于《机器学习》一书中部分现在看来过于冷门的算法，我几乎全部砍掉了，感觉实在用处不大。</div><div class="notion-table-of-contents notion-gray notion-block-ee2c0d87c79e4902b1e59c2149371a2d"><a href="#1472c5ab8184805085dafbcb1f60a299" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Mathematic Preparations</span></a><a href="#1472c5ab818480259a80e67eebeb9b68" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Supervised Learning</span></a><a href="#1472c5ab81848085b06dfef82084cc74" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Deep Learning</span></a><a href="#1472c5ab818480989e80fbc34884e9cd" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Regulations and Generalization</span></a><a href="#1472c5ab8184805d9cf3d2d10e23777a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Unsupervised Learning</span></a><a href="#1472c5ab81848014a516d556352a05bc" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Reinforcement Learning</span></a></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1472c5ab8184805085dafbcb1f60a299" data-id="1472c5ab8184805085dafbcb1f60a299"><span><div id="1472c5ab8184805085dafbcb1f60a299" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1472c5ab8184805085dafbcb1f60a299" title="Mathematic Preparations"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Mathematic Preparations</span></span></h2><a class="notion-page-link notion-block-1472c5ab8184807c83effa3bb5b4e8d7" href="/1472c5ab8184807c83effa3bb5b4e8d7"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="✊">✊</span></div><span class="notion-page-title-text">Mathematic preparations</span></span></a><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1472c5ab818480259a80e67eebeb9b68" data-id="1472c5ab818480259a80e67eebeb9b68"><span><div id="1472c5ab818480259a80e67eebeb9b68" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1472c5ab818480259a80e67eebeb9b68" title="Supervised Learning"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Supervised Learning</span></span></h2><a class="notion-page-link notion-block-1472c5ab818480a4890cd3fd3eb5d6dc" href="/1472c5ab818480a4890cd3fd3eb5d6dc"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🫥">🫥</span></div><span class="notion-page-title-text">Linear regression</span></span></a><a class="notion-page-link notion-block-1472c5ab81848065a861cbecec7dd871" href="/1472c5ab81848065a861cbecec7dd871"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="📔">📔</span></div><span class="notion-page-title-text">Classification and logistic regression</span></span></a><a class="notion-page-link notion-block-1472c5ab8184807da525d81bb4057158" href="/1472c5ab8184807da525d81bb4057158"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🧞">🧞</span></div><span class="notion-page-title-text">Generalized linear models</span></span></a><a class="notion-page-link notion-block-1472c5ab818480cd8fa4da38de25aeb2" href="/1472c5ab818480cd8fa4da38de25aeb2"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🌲">🌲</span></div><span class="notion-page-title-text">Decision trees and Ensemble learning</span></span></a><a class="notion-page-link notion-block-1472c5ab818480f0a713d289d861de53" href="/1472c5ab818480f0a713d289d861de53"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🧬">🧬</span></div><span class="notion-page-title-text">Generative learning algorithm</span></span></a><a class="notion-page-link notion-block-1472c5ab8184809b81c0e13ca5f44571" href="/1472c5ab8184809b81c0e13ca5f44571"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🍩">🍩</span></div><span class="notion-page-title-text">Kernel method</span></span></a><a class="notion-page-link notion-block-1472c5ab81848033a193eb9c773f678b" href="/1472c5ab81848033a193eb9c773f678b"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🎰">🎰</span></div><span class="notion-page-title-text">Support vector machines</span></span></a><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1472c5ab81848085b06dfef82084cc74" data-id="1472c5ab81848085b06dfef82084cc74"><span><div id="1472c5ab81848085b06dfef82084cc74" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1472c5ab81848085b06dfef82084cc74" title="Deep Learning"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Deep Learning</span></span></h2><a class="notion-page-link notion-block-1472c5ab81848036a02de598115e72d3" href="/1472c5ab81848036a02de598115e72d3"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🧠">🧠</span></div><span class="notion-page-title-text">Deep learning</span></span></a><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1472c5ab818480989e80fbc34884e9cd" data-id="1472c5ab818480989e80fbc34884e9cd"><span><div id="1472c5ab818480989e80fbc34884e9cd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1472c5ab818480989e80fbc34884e9cd" title="Regulations and Generalization"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Regulations and Generalization</span></span></h2><a class="notion-page-link notion-block-1472c5ab81848085a939d74a7d1e662c" href="/1472c5ab81848085a939d74a7d1e662c"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🎟️">🎟️</span></div><span class="notion-page-title-text">Bias-Variance Tradeoff and so more</span></span></a><a class="notion-page-link notion-block-1472c5ab818480b9b109f20371ebe303" href="/1472c5ab818480b9b109f20371ebe303"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="📉">📉</span></div><span class="notion-page-title-text">The double descent phenomenon and so more</span></span></a><a class="notion-page-link notion-block-1472c5ab818480c3873ffbe6fc6dee35" href="/1472c5ab818480c3873ffbe6fc6dee35"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="®️">®️</span></div><span class="notion-page-title-text">Regularization and model selection </span></span></a><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1472c5ab8184805d9cf3d2d10e23777a" data-id="1472c5ab8184805d9cf3d2d10e23777a"><span><div id="1472c5ab8184805d9cf3d2d10e23777a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1472c5ab8184805d9cf3d2d10e23777a" title="Unsupervised Learning"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Unsupervised Learning</span></span></h2><a class="notion-page-link notion-block-1472c5ab8184807babebe51cf2711712" href="/1472c5ab8184807babebe51cf2711712"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🧩">🧩</span></div><span class="notion-page-title-text">Clustering algorithms</span></span></a><a class="notion-page-link notion-block-1472c5ab818480b2ab6cc1f13304e097" href="/1472c5ab818480b2ab6cc1f13304e097"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="⚗️">⚗️</span></div><span class="notion-page-title-text">EM algorithms</span></span></a><a class="notion-page-link notion-block-1472c5ab8184803c8758c7cd5535cd28" href="/1472c5ab8184803c8758c7cd5535cd28"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🍿">🍿</span></div><span class="notion-page-title-text">PCA and ICA</span></span></a><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1472c5ab81848014a516d556352a05bc" data-id="1472c5ab81848014a516d556352a05bc"><span><div id="1472c5ab81848014a516d556352a05bc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1472c5ab81848014a516d556352a05bc" title="Reinforcement Learning"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Reinforcement Learning</span></span></h2><a class="notion-page-link notion-block-1472c5ab81848014a42cd6a077e7ae33" href="/1472c5ab81848014a42cd6a077e7ae33"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🦾">🦾</span></div><span class="notion-page-title-text">Reinforcement learning</span></span></a><a class="notion-page-link notion-block-1472c5ab81848013a194ffd731d24f15" href="/1472c5ab81848013a194ffd731d24f15"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🧀">🧀</span></div><span class="notion-page-title-text">LQR, DDP and LQG</span></span></a><a class="notion-page-link notion-block-1472c5ab818480508deff0bbf81daf33" href="/1472c5ab818480508deff0bbf81daf33"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="📐">📐</span></div><span class="notion-page-title-text">Policy Gradient (REINFORCE)</span></span></a><hr class="notion-hr notion-block-13e2c5ab81848077beb3ef0ae2bf26c2"/><a class="notion-page-link notion-block-13e2c5ab81848005b984eb1878882dba" href="/13e2c5ab81848005b984eb1878882dba"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-title-icon notion-page-icon" role="img" aria-label="🧑‍💻">🧑‍💻</span></div><span class="notion-page-title-text">Practice code </span></span></a></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ISP技术入门 AI+ISP ]]></title>
            <link>https://www.wyaaaattwho.xyz/article/ISP</link>
            <guid>https://www.wyaaaattwho.xyz/article/ISP</guid>
            <pubDate>Fri, 02 Aug 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-full-width notion-block-c7cf3e7690a549079057cf7d0767464c"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-row"><a target="_blank" rel="noopener noreferrer" class="notion-bookmark notion-block-9bbbdb2e2b7a4ad7a333febda106fb18" href="http://www.cse.yorku.ca/~mbrown/"><div><div class="notion-bookmark-title">Dr. Michael S. Brown, Professor, EECS, York University, Canada</div><div class="notion-bookmark-description">Michael S. Brown, Professor, School of Computing (SoC), National University of Singapore (NUS), York University, Canada, York, Toronto</div><div class="notion-bookmark-link"><div class="notion-bookmark-link-text">http://www.cse.yorku.ca/~mbrown/</div></div></div></a></div><div class="notion-table-of-contents notion-gray notion-block-1c8e87723e7d4c37863f18ba265294d7"><a href="#e15c47f186c34865a4555b5ce6728c7a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">Color tutorials</span></a><a href="#d5c7d571e91746688b4971a1544dfbd4" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Color and color spaces</span></a><a href="#bbef5f0e18f64bee88df4823a96350ea" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Spectral power distribution (SPD)</span></a><a href="#19f8ad295ff1472dbcffc6b41c272184" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Tristimulus color theory</span></a><a href="#0f80887632174ce7b3b157a2f5a0bd7d" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Radiometry vs. photometry/colorimetry</span></a><a href="#b10b93d8a84f4bbda77140bd61d1941a" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Luminance-chromaticity space (CIE xyY)</span></a><a href="#72a0bd436bb94b4592b5e7473adc154d" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Color constancy and color temperature</span></a><a href="#93d075cc89b34d06ab155d10a66df819" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Color constancy</span></a><a href="#5d3444ccac264967bc72d484b6a5f896" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Color temperature</span></a><a href="#5bd051b6a5524e8bb448bab810764a4c" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Color model versus color space</span></a><a href="#ce352cb920a340d281e1ba13df428603" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:0">In-camera rending pipeline</span></a><a href="#42f64dccb7b6408f928d11542a584d56" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Camera</span></a><a href="#63a0f5782f9a46c6abad7a12ddd37fdb" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Image signal processor (ISP)</span></a><a href="#6251f1d760804922897dd4ab63dad41c" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Camera sensor</span></a><a href="#b28e4930fe7241219d899ed27669b2d5" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">ISO gain and raw-image processing</span></a><a href="#18dcbe02322d408199ce7d2e0b03e817" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">ISO signal amplification (gain)</span></a><a href="#e9709c16cb194785a0137bebd7da2c69" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Black light subtraction</span></a><a href="#012d2d30fc314a07a0853a8b74a7525f" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Defective pixel mask</span></a><a href="#7669084f8ae3402ba54b068b198f03fb" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Flat-field correction</span></a><a href="#ac5d1f4ec0aa4a50afd0a30ef4a660ac" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">RGB demoasicing</span></a><a href="#3b855efa72774fd2a7a8b8f188f06ecb" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">CFA/Bayer pattern demosaicing</span></a><a href="#da3ff403c35e441b8f8f49db3b0917bf" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Noise reduction (NR)</span></a><a href="#5ce80169db3845fdb8c1aca1a3ed3232" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">White-balance &amp; color space transform(CIE XYZ)</span></a><a href="#562a3ea8cd7547cd916391635ec843b0" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Color mapping/colorimetric stage</span></a><a href="#d71678e049824eda81633e05ccccf320" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">AWB</span></a><a href="#e0abe37830b64c36827c568dad48b189" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Color space transform</span></a><a href="#dd8a6e49b7e7405a916407bcd7894170" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Color manipulation (Photo-finishing)</span></a><a href="#39068c8599c447f9935534b8c06f0e56" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Image rescaling (or up-scaling)</span></a><a href="#ef2bf997973d4b1f9c1e1c1246b08d77" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Mapping to output color space</span></a><a href="#478100f7ca0f4477b854b7cede19013f" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">JPEG/HEIC compression</span></a><a href="#b8a49fc1517245b0a811a31f321ef405" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:24px">Save to file</span></a><a href="#f596e9542ee746fc8c8a91b0db809c58" class="notion-table-of-contents-item"><span class="notion-table-of-contents-item-body" style="display:inline-block;margin-left:48px">Circular buffer for ZSL(Zero Shutter Lag) and multi-frame processing</span></a></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-e15c47f186c34865a4555b5ce6728c7a" data-id="e15c47f186c34865a4555b5ce6728c7a"><span><div id="e15c47f186c34865a4555b5ce6728c7a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e15c47f186c34865a4555b5ce6728c7a" title="Color tutorials"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color tutorials</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-d5c7d571e91746688b4971a1544dfbd4" data-id="d5c7d571e91746688b4971a1544dfbd4"><span><div id="d5c7d571e91746688b4971a1544dfbd4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d5c7d571e91746688b4971a1544dfbd4" title="Color and color spaces"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color and color spaces</span></span></h3><div class="notion-text notion-block-e1e04456f8b4492d9dabb157782e935a">The most common color space is <em><span class="notion-blue">CIE XYZ</span></em>, but before we get into that, we first need a more basic view of how we perceive the colors.</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-bbef5f0e18f64bee88df4823a96350ea" data-id="bbef5f0e18f64bee88df4823a96350ea"><span><div id="bbef5f0e18f64bee88df4823a96350ea" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bbef5f0e18f64bee88df4823a96350ea" title="Spectral power distribution (SPD)"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Spectral power distribution (SPD)</span></span></h4><div class="notion-text notion-block-89939fce965c4ffe9075a75036b4d18d">Every color (visible spectrum) has a special combined wavelength, this can be described by a spectral power distribution (SPD) shown below. The SPD plot shows the relative amount of each wavelength reflected over the visible spectrum.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b1321944904e41bc9aba139a1f5f7cf4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F90c61da6-d0be-4ba9-bd8f-810204b8ec53%2FUntitled.png?table=block&amp;id=b1321944-904e-41bc-9aba-139a1f5f7cf4&amp;t=b1321944-904e-41bc-9aba-139a1f5f7cf4&amp;width=528&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-8669d5aeb6ca423c97e35974f058f44f">Due to the accumulation effect of the cones, two different SPDs can be perceived as the same color (such SPDs are called “<em><span class="notion-blue">metamers</span></em>”).</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-19f8ad295ff1472dbcffc6b41c272184" data-id="19f8ad295ff1472dbcffc6b41c272184"><span><div id="19f8ad295ff1472dbcffc6b41c272184" class="notion-header-anchor"></div><a class="notion-hash-link" href="#19f8ad295ff1472dbcffc6b41c272184" title="Tristimulus color theory"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Tristimulus color theory</span></span></h4><div class="notion-text notion-block-da44040f307f4e048835f000b42eaa03">People found that all color could be expressed as a linear combination of three primary color. <em><span class="notion-blue">Grassman’s Law</span></em> states that a source color can be matched by a linear combination of three independent “primaries”.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a2316a4c80394b4c9740f14430a6df49"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F63ccf310-68d5-4b2c-9c19-37bfceac2266%2FUntitled.png?table=block&amp;id=a2316a4c-8039-4b4c-9740-f14430a6df49&amp;t=a2316a4c-8039-4b4c-9740-f14430a6df49&amp;width=898.0078125&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-0f80887632174ce7b3b157a2f5a0bd7d" data-id="0f80887632174ce7b3b157a2f5a0bd7d"><span><div id="0f80887632174ce7b3b157a2f5a0bd7d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0f80887632174ce7b3b157a2f5a0bd7d" title="Radiometry vs. photometry/colorimetry"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Radiometry vs. photometry/colorimetry</span></span></h4><div class="notion-text notion-block-002128809f014cab8e01d067b016ac41">Radiometry<div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-7e25faa3c9db41daafd56ef000e7de13"><li>Quantitative measurements of radiant energy.</li></ul><ul class="notion-list notion-list-disc notion-block-907b1367ef114ccf98d832afc78aa66e"><li>Often shown as spectral power distributions (SPD).</li></ul><ul class="notion-list notion-list-disc notion-block-1a33ae6617154aae97c3dbf7284ad63f"><li>Measures light coming from a source (radiance) or light falling on a surface (irradiance).</li></ul></div></div><div class="notion-text notion-block-fee343c7394246989d274b4647fff220">Photometry/ colorimetry (a psychophysical)<div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-c0f8bc4321f24689aebcc026b9824be5"><li>Quantitative measurement of perceived radiant energy based on human’s sensitivity tolight.</li></ul><ul class="notion-list notion-list-disc notion-block-3f6b28fec76240d98fe13d7733f3f091"><li>Perceived in terms of “brightness” (photometry) and color (colorimetry).</li></ul></div></div><div class="notion-text notion-block-9e895f112e8f4058ab3980a9cdd8d200">Now we face the problem to bridging up the gap between the radiometry and  photometry/colorimetry. How can we do that? Well in <em><span class="notion-blue">the flicker experiments, </span></em>we are finally able to measure how we perceive different color of different SPD byb their brightness.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-3897e05643e94f5dae29a2a92789122f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:320px"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fd04bec1d-5ca0-42b7-a47c-4e9bf945f7b2%2F48dd98b2-c5eb-4509-b187-86b940a8ac7e.png?table=block&amp;id=3897e056-43e9-4f5d-ae29-a2a92789122f&amp;t=3897e056-43e9-4f5d-ae29-a2a92789122f&amp;width=633.6633663366337&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-b4b199edb58b4a6b87f950de0e15614a">We invert the result, and we shall get what is called <em><span class="notion-blue">CIE (1924) Photopic luminosity function</span></em></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-67184020556046deb3b394740738c757"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F11dce00a-14fd-496c-b628-75c97b0066b6%2FUntitled.png?table=block&amp;id=67184020-5560-46de-b3b3-94740738c757&amp;t=67184020-5560-46de-b3b3-94740738c757&amp;width=898.0078125&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-85b6663a36e84818980de88073c65187">The Luminosity Function (written as y(λ) or V(λ)) shows the eye’s sensitivity to radiant energy into luminous energy (or perceived radiant energy) based on human experiments (flicker fusion test).</div><div class="notion-text notion-block-76d7820bcc1f4be7ae3cca17ba7782d6">And finally, we can define a quantity to measure the perceived brightness of different light. That is</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9a13c75c5e784db9a6d3f5519d53a5a7"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F9d14d661-a248-4868-b85b-e238af3e0ad2%2FUntitled.png?table=block&amp;id=9a13c75c-5e78-4db9-a6d3-f5519d53a5a7&amp;t=9a13c75c-5e78-4db9-a6d3-f5519d53a5a7&amp;width=835.9877319335938&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-f3e898c78c7d42eea2618f95a0ff4b48">And now let’s figure how to go from radiometry to colorimetry. Based on tristimulus color theory, colorimetry attempts to quantify all visible colors in terms of a standard set of primaries. So by hiring “standard observers”, we can easily carry out experiments and thus set up a measurement for our purpose.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-947772f83c2f47abac2102b9b6e797be"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:314px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F897fc206-a5be-4a14-a81e-b87bb0b157ed%2FUntitled.png?table=block&amp;id=947772f8-3c2f-47ab-ac21-02b9b6e797be&amp;t=947772f8-3c2f-47ab-ac21-02b9b6e797be&amp;width=314&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-96879e8c42aa41f78f4eba1f67e6d952">Noticeable that there are negative values in, we can apply an linear transformation to avoid this. </div><div class="notion-text notion-block-4617d79da84b436883a24adf237d7990">In 1931, the CIE met and approved defining a new canonical basis, termed XYZ that would be derived from Wright-Guild’s CIE RGB data.</div><ul class="notion-list notion-list-disc notion-block-acea1c349c0d4aacaa35af13b098e82c"><li>Properties desired in this conversion:</li><ul class="notion-list notion-list-disc notion-block-acea1c349c0d4aacaa35af13b098e82c"><li>Positive values only</li><li>Pure white light (flat SPD) to lie at X=1/3, Y=1/3, Z=1/3</li><li>Y would be the luminosity function (V(λ))</li></ul></ul><ul class="notion-list notion-list-disc notion-block-93bd40e633a64d38bdc56d0c107e72b2"><li>Quite a bit of freedom in selecting the XYZ basis</li><ul class="notion-list notion-list-disc notion-block-93bd40e633a64d38bdc56d0c107e72b2"><li>In the end, the adopted transform was:</li><ul class="notion-list notion-list-disc notion-block-90ad0ad915494708bcbe93faa605e01a"><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-24af2af97cb143349430a4d235439c66"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:480px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F277573d4-7a77-43f8-b957-c65ccfd9b4dc%2FUntitled.png?table=block&amp;id=24af2af9-7cb1-4334-9430-a4d235439c66&amp;t=24af2af9-7cb1-4334-9430-a4d235439c66&amp;width=480&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure></ul></ul></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a6b39cba2a074d37b18054f9a6f8f74e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:816px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fe39b7fa3-7b2d-424c-92de-88c405701665%2FUntitled.png?table=block&amp;id=a6b39cba-2a07-4d37-b180-54f9a6f8f74e&amp;t=a6b39cba-2a07-4d37-b180-54f9a6f8f74e&amp;width=816&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-df9080226fa94be6a431a7b44dc4449f">To transfer from SPD to CIE 1931 XYZ we have to carry out three integrates respectively</div><div class="notion-text notion-block-d172e6cc46be4209bf0d12d62b99eded">CIE 1931 XYZ is one of the most common color space we gonna mention later.</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-b10b93d8a84f4bbda77140bd61d1941a" data-id="b10b93d8a84f4bbda77140bd61d1941a"><span><div id="b10b93d8a84f4bbda77140bd61d1941a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b10b93d8a84f4bbda77140bd61d1941a" title="Luminance-chromaticity space (CIE xyY)"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Luminance-chromaticity space (CIE xyY)</span></span></h4><div class="notion-text notion-block-0d2db0c2b00e4a06a9f13cdabc7971b1">Sometimes it is useful to discuss color in terms of luminance (perceived brightness) and chromaticity (we can think of as the hue-saturation combined). CIE xyY space is used for this purpose.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-98aa2445f4c4438b86ba3a2757f5adbf"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F556e5b1f-f966-414c-b818-f01cdd378bf1%2FUntitled.png?table=block&amp;id=98aa2445-f4c4-438b-86ba-3a2757f5adbf&amp;t=98aa2445-f4c4-438b-86ba-3a2757f5adbf&amp;width=898.0078125&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-89d1407b2f4d4d6983df6c04cefd9c83">A few things you need to know about this image:</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-72a0bd436bb94b4592b5e7473adc154d" data-id="72a0bd436bb94b4592b5e7473adc154d"><span><div id="72a0bd436bb94b4592b5e7473adc154d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#72a0bd436bb94b4592b5e7473adc154d" title="Color constancy and color temperature"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color constancy and color temperature</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-93d075cc89b34d06ab155d10a66df819" data-id="93d075cc89b34d06ab155d10a66df819"><span><div id="93d075cc89b34d06ab155d10a66df819" class="notion-header-anchor"></div><a class="notion-hash-link" href="#93d075cc89b34d06ab155d10a66df819" title="Color constancy"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color constancy</span></span></h4><div class="notion-text notion-block-28432571de614e7cb0f0c021b7600b63">Our visual system has an amazing ability to compensate for environmental illumination such that objects are perceived as the same color. </div><div class="notion-text notion-block-20d06ccb0e0648bbb148cc72019ed003"><em><span class="notion-blue">Color constancy (chromatic adaptation)</span></em> is the ability of the human visual system to adapt to scene illumination. This ability is not perfect, but it works fairly well. Image sensors do not have this ability! We will discuss this in part 2 . . this is related to the camera’s white-balance module.</div><div class="notion-text notion-block-212969b93ecc49278cbd40db55c55ee2">We can use <em><span class="notion-blue">The Von Kries transform </span></em>to discribe this kind of adaptation</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-0b97154251f8463f8b59bd8791c01a14"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:768px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F8d986504-6f79-4aa6-b2ec-c1b9713bdf4e%2FUntitled.png?table=block&amp;id=0b971542-51f8-463f-8b59-bd8791c01a14&amp;t=0b971542-51f8-463f-8b59-bd8791c01a14&amp;width=768&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-b7722ffe83c34e29aa9bfbc06a65c7a8">And it’s noticeable that people always adapts printed media rather than emissive media. </div><div class="notion-text notion-block-75b104c8c82d43d6a1e02dd585c4e8bd">All we have discussed about indicates that</div><ul class="notion-list notion-list-disc notion-block-80507e0a4c824d1cabab16bc860b5444"><li>Color is intimately connected to scene illumination.</li></ul><ul class="notion-list notion-list-disc notion-block-8053b5e3fde143ccaf5194732b69d731"><li>Even for emissive displays, we have to consider (or make assumptions) about the illumination in the viewing environment of the display.</li></ul><ul class="notion-list notion-list-disc notion-block-5c8d80d0b2e042768d1d65948043f738"><li>Keep this in mind because it will play a role when we define color spaces used to encode our images.</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-5d3444ccac264967bc72d484b6a5f896" data-id="5d3444ccac264967bc72d484b6a5f896"><span><div id="5d3444ccac264967bc72d484b6a5f896" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5d3444ccac264967bc72d484b6a5f896" title="Color temperature"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color temperature</span></span></h4><div class="notion-text notion-block-2548bc4e8d404b5389afa5b63ec99df9">To better describe color of different illuminant, we introduce <em><span class="notion-blue">color temperature.  </span></em>In the photography and display communities, an illumination’s “color” is described using a <em><span class="notion-blue">correlated color temperature (CCT)</span></em>. This is an excellent example of where metamers are used.</div><div class="notion-text notion-block-d5fc76b8469548d185fae8690f45e5b9">As mentioned, illuminants are often described by their “color temperature.” This mapping is based on <span class="notion-blue">theoretical blackbody radiators</span> that produce SPDs for a given temperature expressed in Kelvin (K). We map light sources (both real and synthetic) to their closest color temperature.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-8f1cfb2325bf4acbb918286e00b800cd"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fc1883069-6add-41a2-bae0-26f26033d961%2FUntitled.png?table=block&amp;id=8f1cfb23-25bf-4acb-b918-286e00b800cd&amp;t=8f1cfb23-25bf-4acb-b918-286e00b800cd&amp;width=835.9933471679688&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d5d91ea953dc4053a705ff9f7cf101d8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fcb6c0a77-1fb6-4e18-98f3-539825739d7d%2FUntitled.png?table=block&amp;id=d5d91ea9-53dc-4053-a705-ff9f7cf101d8&amp;t=d5d91ea9-53dc-4053-a705-ff9f7cf101d8&amp;width=810.5022583007812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-4b182571a0e146fea901f4072e220a23">We can plot visible SPDs in CIE xy chromaticity</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b711e4074ad24e23974a875b36ed38ff"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:576px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F6b87ba11-0afa-4596-bccb-59b64f3bcaa7%2FUntitled.png?table=block&amp;id=b711e407-4ad2-4e23-974a-875b36ed38ff&amp;t=b711e407-4ad2-4e23-974a-875b36ed38ff&amp;width=576&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-8c7a9cfa815344029a535b4da19fec07">How to check the CCT of a given illuminant is simple, just do as the following steps:</div><ul class="notion-list notion-list-disc notion-block-8d5db391d9ee420ab6d63291410bd2ac"><li>Find the light sources SPD mapping to CIE XYZ using the CIE 1931 mapping functions.</li></ul><ul class="notion-list notion-list-disc notion-block-7d4f85bea7b246b0b730e374cb333f0a"><li>Project the CIE xyY value to the Planckian locus line.</li></ul><div class="notion-text notion-block-809b165acaa24c64acd63a893df9844a">An example of an OLED light is here</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-e6d0c144a08e42fdbde9ecbbc11b1034"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:816px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fc1eddbdc-632c-4c7b-9807-9b0a949d6601%2FUntitled.png?table=block&amp;id=e6d0c144-a08e-42fd-bde9-ecbbc11b1034&amp;t=e6d0c144-a08e-42fd-bde9-ecbbc11b1034&amp;width=816&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-0804c288f0f14266a8926077568df0ea">Where the projection falls is the Correlated Color Temperature (CCT) of this light source. So, in this example, the OLED light source is roughly 4500K.
While we often say &quot;color temperature&quot;, we should say &quot;correlated color temperature.” The concept is not always related to the physical temperature of the light source, but its correlation with the black body radiator&#x27;s color temperature.</div><div class="notion-text notion-block-9b74a34420e548b3b2bb658fc7a8c4bb">After we defined the CCT, we can easily define <em><span class="notion-blue">the White point.  </span></em>A white point is a color defined in CIE xyY that we want to be considered “white” (or achromatic/neutral). This is essentially an illuminant’s SPD in terms of CIE XYZ/CIE xyY. Think of it as CIE Yxy value of a white piece of paper under some illumination.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-f4bd63fa55e1481c8af8ca5eb98dd303"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:314px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F2b83d5eb-907f-4319-a814-beea5e621ec4%2FUntitled.png?table=block&amp;id=f4bd63fa-55e1-481c-8af8-ca5eb98dd303&amp;t=f4bd63fa-55e1-481c-8af8-ca5eb98dd303&amp;width=314&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-callout notion-gray_background_co notion-block-fa3a59ac4e984c17abc221034c02d90b"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🚨">🚨</span></div><div class="notion-callout-text">Summary<div class="notion-text notion-block-ac9feb00c17942878541267bf7cb9a3e">Color constancy is our ability to adapt to illumination in the scene.</div><div class="notion-text notion-block-4131dfe21dfc4a128f5547f14e5685f1">Correlated Color Temperature (CCT) — or just color temperature — is a system used to describe scene illumination.</div><div class="notion-text notion-block-a1222a1abb214dac94d1441f057defd9">Note: we must factor in the scene illumination when capturing and displaying color images.</div></div></div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-5bd051b6a5524e8bb448bab810764a4c" data-id="5bd051b6a5524e8bb448bab810764a4c"><span><div id="5bd051b6a5524e8bb448bab810764a4c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5bd051b6a5524e8bb448bab810764a4c" title="Color model versus color space"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color model versus color space</span></span></h3><div class="notion-text notion-block-160348cecef94072971ca9a61cbb12c3">A color model is a mathematical system for describing a color as a tuple of numbers (RGB, HSV, HSL, more. . . )</div><div class="notion-text notion-block-d66b61448c7440d48fae0189963fb911">A color space is a specific range of colors within a color model. The range of color (gamut) can be expressed in CIE XYZ. Color spaces typically also define the viewing environment and, therefore, the “white point” of the space</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-36f17f59335843ad8f146f2c683fae37"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F454aa50d-ef28-49f0-a6f3-111ec537c40b%2FUntitled.png?table=block&amp;id=36f17f59-3358-43ad-8f14-6f2c683fae37&amp;t=36f17f59-3358-43ad-8f14-6f2c683fae37&amp;width=835.9989013671875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-cc50797b41c74964a62e980f398bb0aa">We must understood that no specific color model can fully cover up the CIE XYZ, but just part of it, and we must realize that different definition of white point define a different color model, which implies the existence of  a vast range different color models.</div><div class="notion-text notion-block-3202674e44be44d0bfd735334b88296c">In 1996, Microsoft and HP defined a set of “standard” RGB primaries. R=CIE xyY (0.64, 0.33, 0.2126) G=CIE xyY (0.30, 0.60, 0.7153) B=CIE xyY (0.15, 0.06, 0.0721). This was considered an RGB space achievable by most devices at the time. The white point was set to the D65 illuminant. This is an important to note. It means sRGB has built in the assumed viewing condition (6500K daylight).</div><div class="notion-text notion-block-8a9e1c6c6673420d8c370b0058dbfcc2">A matrix decides the transformation from CIE XYZ to the sRGB, which is</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ac5415504f2e45269bc709a7d6e1c21b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F8ef7b4a3-cc3f-4beb-8d43-77e97426e1f2%2FUntitled.png?table=block&amp;id=ac541550-4f2e-4526-9bc7-09a7d6e1c21b&amp;t=ac541550-4f2e-4526-9bc7-09a7d6e1c21b&amp;width=624&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-d3f4167a821d4edc931590cfaec494b4">Before introducing someting new, let’s grab a look at <em><span class="notion-blue">Stevens&#x27; power law</span></em></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b9bc8c79934b48429185bdcb7d6ed016"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:768px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fae072605-e589-410c-ab0c-e840b36c90e3%2FUntitled.png?table=block&amp;id=b9bc8c79-934b-4842-9185-bdcb7d6ed016&amp;t=b9bc8c79-934b-4842-9185-bdcb7d6ed016&amp;width=768&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-5e5bc83d9c624d27b9ec47a85dbf4904">That tells us, if we want our color seemed more natural, we need it to be in-linear, that’s why we have our <em><span class="notion-blue">gamma curve</span></em></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-408fec5a98574befac177b0c1b63001f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:672px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F3cbd5b53-766a-420b-af60-c065c93531b8%2FUntitled.png?table=block&amp;id=408fec5a-9857-4bef-ac17-7b0c1b63001f&amp;t=408fec5a-9857-4bef-ac17-7b0c1b63001f&amp;width=672&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-f57809349a3c4e14a48dbe203e0a94f1">The actual formula is a bit complicated, but effectively this is gamma (<!-- -->) where I’ is the output intensity and I is the linear sRGB ranged 0-1, with a small linear transfer for linearized sRGB values close to 0 (not shown in this plot). This is known as <em><span class="notion-blue">“perceptual encoding”</span></em> and is intended to allocate more bits based on our nonlinear response to radiant power.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-6024f83462094291b50c29e66d67e5b1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F6763587e-eb92-4dd5-bb0f-8f4456ebe49c%2FUntitled.png?table=block&amp;id=6024f834-6209-4291-b50c-29e66d67e5b1&amp;t=6024f834-6209-4291-b50c-29e66d67e5b1&amp;width=624&amp;cache=v2" alt="A huge difference between linear and in-linear sRGB " loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">A huge difference between linear and in-linear sRGB </figcaption></div></figure><div class="notion-text notion-block-12912d5ed84e495a8aede21e558b1825">Generally speaking, the relation is like a clan of color spaces</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b056149d9a3942048e75b402941f00a1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:768px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F71c8297c-9bbe-441f-9f9b-f6508e31f370%2FUntitled.png?table=block&amp;id=b056149d-9a39-4204-8e75-b402941f00a1&amp;t=b056149d-9a39-4204-8e75-b402941f00a1&amp;width=768&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-6d176277b7c3422da6457d4c10887841">At last we introduce a little more common color spaces.</div><ul class="notion-list notion-list-disc notion-block-e99acc697132481281a365284f6054bc"><li>CIE Lab</li><ul class="notion-list notion-list-disc notion-block-e99acc697132481281a365284f6054bc"><div class="notion-text notion-block-47e91db8bc2841148386f7459f9568c6">CIE Lab transforms CIE to a new space where color (and brightness) differences are more uniform.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-7e32ce2ad77641a9a63a1f84dc4a2634"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:286px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fd7d5295d-58bb-4ea6-86c6-f1acdc936ced%2FUntitled.png?table=block&amp;id=7e32ce2a-d776-41a9-a63a-1f84dc4a2634&amp;t=7e32ce2a-d776-41a9-a63a-1f84dc4a2634&amp;width=286&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-bd807b75244842ab89fb2434576e7175"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:286px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Ff313ecad-4700-42ae-8294-875b95127ad0%2FUntitled.png?table=block&amp;id=bd807b75-2448-42ab-89fb-2434576e7175&amp;t=bd807b75-2448-42ab-89fb-2434576e7175&amp;width=286&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-8e061ae5dccc4e189f641cf6ca1a13ff">And in CIE Lab it’s safe to define <em><span class="notion-blue">Color error metric – CIE 2000 Delta E (ΔE)</span></em><em>. </em>Delta E is a color metric based on L<em>ab space. Since L</em>ab is more uniformly perceptual, distances (e.g., Euclidean distance) in L*ab have more meaning than in CIE XYZ. Delta E values have an interpretation as follows.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-35c754f02c49411dac334f282ebbc24c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:432px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F3b0e7b48-dcd7-484a-afa0-59d69e3be294%2FUntitled.png?table=block&amp;id=35c754f0-2c49-411d-ac33-4f282ebbc24c&amp;t=35c754f0-2c49-411d-ac33-4f282ebbc24c&amp;width=432&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure></ul></ul><ul class="notion-list notion-list-disc notion-block-a4b05296e0b84fa0a093d30ba234b6c7"><li>Others to be aware of</li><ul class="notion-list notion-list-disc notion-block-a4b05296e0b84fa0a093d30ba234b6c7"><li>Adobe RGB</li><ul class="notion-list notion-list-disc notion-block-fbbad2a9545649caa9e568e78f9f435a"><li>Medium gamut color space</li><li>Used for photo-editing</li></ul><li>Display P3</li><ul class="notion-list notion-list-disc notion-block-64f7e78660894d51bb87101b36e3735c"><li>Medium gamut color space</li><li>Used by Apple devices to accommodate better display technology</li><li>Similar to Adobe RGB</li></ul><li>ProPhoto (ROMM)</li><ul class="notion-list notion-list-disc notion-block-8bc675a1f16d4d01ab7018de19255304"><li>Developed by Kodak</li><li>Intended to encode a wide range of colors and dynamic range</li></ul></ul></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d3ce13dc01d44b898581daca4cba521b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:768px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fc74035b5-8e49-4d1c-b56e-bcf6c2d14af1%2FUntitled.png?table=block&amp;id=d3ce13dc-01d4-4b89-8581-daca4cba521b&amp;t=d3ce13dc-01d4-4b89-8581-daca4cba521b&amp;width=768&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-ce352cb920a340d281e1ba13df428603" data-id="ce352cb920a340d281e1ba13df428603"><span><div id="ce352cb920a340d281e1ba13df428603" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ce352cb920a340d281e1ba13df428603" title="In-camera rending pipeline"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">In-camera rending pipeline</span></span></h2><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-022e8908269c4fb59b6a0a06f1ba4ae0"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F27c5f0a6-6d07-4004-8b60-f139e36f03cd%2FUntitled.png?table=block&amp;id=022e8908-269c-4fb5-9b6a-0a06f1ba4ae0&amp;t=022e8908-269c-4fb5-9b6a-0a06f1ba4ae0&amp;width=624&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-42f64dccb7b6408f928d11542a584d56" data-id="42f64dccb7b6408f928d11542a584d56"><span><div id="42f64dccb7b6408f928d11542a584d56" class="notion-header-anchor"></div><a class="notion-hash-link" href="#42f64dccb7b6408f928d11542a584d56" title="Camera"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Camera</span></span></h3><div class="notion-text notion-block-95bfb5293a134cc1a6cc586e2b7b9a29">The image directly captured from the camera’s sensor needs to be processed. We can call this process “rendering,” as the goal is to render a digital image suitable for viewing.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c246d34c363b4a98b409452134f7f203"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F1e2c9f03-e088-437c-9fb2-0c51831d39c3%2FUntitled.png?table=block&amp;id=c246d34c-363b-4a98-b409-452134f7f203&amp;t=c246d34c-363b-4a98-b409-452134f7f203&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-63a0f5782f9a46c6abad7a12ddd37fdb" data-id="63a0f5782f9a46c6abad7a12ddd37fdb"><span><div id="63a0f5782f9a46c6abad7a12ddd37fdb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#63a0f5782f9a46c6abad7a12ddd37fdb" title="Image signal processor (ISP)"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Image signal processor (ISP)</span></span></h3><div class="notion-text notion-block-8eba4b85e3854d90ab7627c462195208">An ISP is dedicated hardware that renders the sensor image to produce the final output.</div><div class="notion-text notion-block-82700671507043c5b850c9572a256569">Companies such as Qualcomm, HiSilicon, Intel (and more) sell ISP chips (often as part of a System on a Chip – SoC). Companies can customize the ISP. Many ISPs now have neural processing units (NPUs).</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-6251f1d760804922897dd4ab63dad41c" data-id="6251f1d760804922897dd4ab63dad41c"><span><div id="6251f1d760804922897dd4ab63dad41c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6251f1d760804922897dd4ab63dad41c" title="Camera sensor"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Camera sensor</span></span></h3><div class="notion-text notion-block-5cd9d9e4c63a4458bb31a2edb38279a0">Almost all consumer camera sensors are based on <em><span class="notion-blue">complementary metaloxide-semiconductor (CMOS)</span></em> technology.
We generally describe sensors in terms of number of pixels and size. The larger the sensor, the better the noise performance as more light can fall on each pixel. <span class="notion-blue">Smart phones have small sensors!</span></div><div class="notion-text notion-block-929b9ae4c63640889d81fd900d8a925d">Camera uses a certain pattern of sensors to catch photons.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-57978af7691d4b35a5eaa081930260a7"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F9892a6c9-f2b4-4060-9590-51982723b120%2FUntitled.png?table=block&amp;id=57978af7-691d-4b35-a5ea-a081930260a7&amp;t=57978af7-691d-4b35-a5ea-a081930260a7&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-26d6dd71d89f461bbd2b29b220f932ef"><em><span class="notion-blue">The color filter array (CFA)</span></em> on the camera filters the light into three sensor-specific RGB primaries.</div><div class="notion-text notion-block-881947caaca54222983b55400d3a00e3">Remember: physical world is measured by radiometric spectral power distributions. Your camera sensor RGB filter is sensitive to different regions of the incoming SPD. Raw-RGB represents the physical world&#x27;s SPD &quot;projected&quot; onto the sensor&#x27;s spectral filters.</div><div class="notion-text notion-block-2344c47a960944a3acc16999b63093a6">Note that Sensors are linear to irradiance, if you double the amount of light hitting a sensor&#x27;s pixel, the digital value output of that pixel will double.</div><div class="notion-text notion-block-b875cc7cdb784c0490c299b893340b0b">Digital value I is a linear function of irradiate i and exposure t.</div><div class="notion-callout notion-gray_background_co notion-block-96d408d5c8d141a6aa89f6069baa3518"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🚨">🚨</span></div><div class="notion-callout-text">IMPORTANT: raw-RGB sensor images are not in a standard color space.<figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-6d886e0e168d4c0ba851c34c8eec3f36"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:528px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fb5b112ad-7cc7-48ad-ae2a-af29760c9d78%2FUntitled.png?table=block&amp;id=6d886e0e-168d-4c0b-a851-c34c8eec3f36&amp;t=6d886e0e-168d-4c0b-a851-c34c8eec3f36&amp;width=528&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-77c802462c8646388358e6c3d5765f80">So if you try to display a raw-RGB pic it would be weird(like what you see before in your “pixeliser” )</div></div></div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-b28e4930fe7241219d899ed27669b2d5" data-id="b28e4930fe7241219d899ed27669b2d5"><span><div id="b28e4930fe7241219d899ed27669b2d5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b28e4930fe7241219d899ed27669b2d5" title="ISO gain and raw-image processing"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">ISO gain and raw-image processing</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-18dcbe02322d408199ce7d2e0b03e817" data-id="18dcbe02322d408199ce7d2e0b03e817"><span><div id="18dcbe02322d408199ce7d2e0b03e817" class="notion-header-anchor"></div><a class="notion-hash-link" href="#18dcbe02322d408199ce7d2e0b03e817" title="ISO signal amplification (gain)"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">ISO signal amplification (gain)</span></span></h4><div class="notion-text notion-block-d40e9a268daf4bd1a338c01d7410f755">Imaging sensor signal is <em><span class="notion-blue">amplified and digitized</span></em>. Amplification to assist A/D conversion. You need to get the voltage to the range required for the desired digital output. This gain is used to accommodate camera ISO settings. Gain to signal applied on the sensor. Note that gaining the signal also gains image noise.</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-e9709c16cb194785a0137bebd7da2c69" data-id="e9709c16cb194785a0137bebd7da2c69"><span><div id="e9709c16cb194785a0137bebd7da2c69" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e9709c16cb194785a0137bebd7da2c69" title="Black light subtraction"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Black light subtraction</span></span></h4><div class="notion-text notion-block-609e910bdcdb4fc6b7b1d78bc1d25c90">And let’s talk about the pixel intensity. We often talk about a pixel&#x27;s intensity, however, a pixel&#x27;s numerical value has no unit.</div><div class="notion-text notion-block-5615fc136c694bc8998019d76ba61eed">The digital value of a pixel is based on several factors.</div><ul class="notion-list notion-list-disc notion-block-5bd4109536fc497ebe8bdb8aeb6f3c49"><li>Exposure (which is a function of both shutter speed and exposure)</li></ul><ul class="notion-list notion-list-disc notion-block-739d503e5c0e4deead56e96a3ab9b00f"><li>Gain (ISO setting on the camera)</li></ul><ul class="notion-list notion-list-disc notion-block-843118477e5949aaa37bb49e273ed7c3"><li>Camera hardware that digitizes the signal.</li></ul><div class="notion-text notion-block-a3937ee56f32488cbae103fa4e5b9fba">That’s why we use relative digital values in the image and not the absolute digital values.</div><div class="notion-text notion-block-1ce7d9dce56e495693b32a174d192bd6">Sensor values for pixels with “no light” should be zero. However, this is not the case due to sensor noise, the black level often changes as the sensor heats up. This can be corrected by capturing a set of pixels that do not see light. Place a dark shield around the sensor. <em><span class="notion-blue">Subtract the level from the “black” pixels.</span></em></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-587feadb7bfd46bbab8bfc09c480f4ce"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:624px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F542fade1-902d-408f-b7fc-d4abf13c52ff%2FUntitled.png?table=block&amp;id=587feadb-7bfd-46bb-ab8b-fc09c480f4ce&amp;t=587feadb-7bfd-46bb-ab8b-fc09c480f4ce&amp;width=624&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-012d2d30fc314a07a0853a8b74a7525f" data-id="012d2d30fc314a07a0853a8b74a7525f"><span><div id="012d2d30fc314a07a0853a8b74a7525f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#012d2d30fc314a07a0853a8b74a7525f" title="Defective pixel mask"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Defective pixel mask</span></span></h4><div class="notion-text notion-block-9045df8cc7ab4bd4ae35464b346f1235">In CMOS (complementary metal-oxide-semiconductor) image sensors, defective pixels are a common issue. Here’s a breakdown of the process you mentioned for <em><span class="notion-blue">handling defective pixels</span></em>:</div><div class="notion-text notion-block-cb5c49ec1da0404a8efd62d648172f6f">1.	<b>Dead Pixel Masks</b>: Dead pixel masks are used to identify and manage defective pixels in CMOS sensors. These masks are pre-calibrated at the factory to ensure that the sensor performs optimally when deployed.</div><div class="notion-text notion-block-e477f8a78b9040f9873bd6f654409443">2.	<b>Dark Current Calibration</b>: Dark current refers to the small amount of current that flows through a pixel even when it is not exposed to light. To create a dead pixel mask, a “dark current” calibration is performed. This involves taking an image of the sensor with no light exposure, effectively capturing the dark current levels.</div><div class="notion-text notion-block-0c3c132d61af45079a9ee373374db8c9">3.	<b>Recording Values</b>: During the dark current calibration, the sensor’s output is recorded. Pixels that report values significantly different from their neighbors are identified as defective or bad.</div><div class="notion-text notion-block-447682914f924d938919bfea1381ec13">4.	<b>Creating the Mask</b>: The recorded values are used to create a mask that identifies which pixels are defective. This mask is essentially a map that indicates which pixels should be considered faulty.</div><div class="notion-text notion-block-0753b0b19f304f9cb462379cbb62eef8">5.	<b>Interpolating Bad Pixels</b>: After creating the mask, any data from defective pixels are interpolated. This means that the values from these bad pixels are replaced with values calculated based on neighboring pixels. This interpolation helps to ensure that the image sensor’s output remains accurate and usable despite the presence of defective pixels.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c45252b5d8594882a63348e453597e15"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:314px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F43227961-333a-4e18-954b-247fe5d2650e%2FUntitled.png?table=block&amp;id=c45252b5-d859-4882-a633-48e453597e15&amp;t=c45252b5-d859-4882-a633-48e453597e15&amp;width=314&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-7669084f8ae3402ba54b068b198f03fb" data-id="7669084f8ae3402ba54b068b198f03fb"><span><div id="7669084f8ae3402ba54b068b198f03fb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7669084f8ae3402ba54b068b198f03fb" title="Flat-field correction"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Flat-field correction</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-0f2e461354f140f99f16610b81c912c9"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fb1622e01-5535-4caf-b233-a592a23a6b19%2FUntitled.png?table=block&amp;id=0f2e4613-54f1-40f9-9f16-610b81c912c9&amp;t=0f2e4613-54f1-40f9-9f16-610b81c912c9&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-ac5d1f4ec0aa4a50afd0a30ef4a660ac" data-id="ac5d1f4ec0aa4a50afd0a30ef4a660ac"><span><div id="ac5d1f4ec0aa4a50afd0a30ef4a660ac" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ac5d1f4ec0aa4a50afd0a30ef4a660ac" title="RGB demoasicing"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">RGB demoasicing</span></span></h3><div class="notion-text notion-block-7bc56426e3574c4494ffcf2d1b5fe4ec">You’ve already know some part of this</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-3b855efa72774fd2a7a8b8f188f06ecb" data-id="3b855efa72774fd2a7a8b8f188f06ecb"><span><div id="3b855efa72774fd2a7a8b8f188f06ecb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3b855efa72774fd2a7a8b8f188f06ecb" title="CFA/Bayer pattern demosaicing"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">CFA/Bayer pattern demosaicing</span></span></h4><div class="notion-text notion-block-e737f73513814d05abcd91d211a8dde9">Color filter array (CFA) pattern placed over pixel sensors. We want an RGB value at each pixel, so we need to perform interpolation.</div><div class="notion-text notion-block-e8e2f6a2e0d448029ee38e559523f160">Most simply, we just simply interpolation with average values, yet it’s more intuitive that if we use a weight mask.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-3a789768643c44cd97d4012d966515b1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fbceef26c-5bbc-4297-9b8c-6c690914e2b3%2FUntitled.png?table=block&amp;id=3a789768-643c-44cd-97d4-012d966515b1&amp;t=3a789768-643c-44cd-97d4-012d966515b1&amp;width=2234&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2b8d378ae3a54587a6a6451032bf98e7">There are newer CFAs such as Quad/Tetra (2x2) and Nona (3x3), they aer common on smart phones.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ed522b4b8cfb487b9f29934b38272052"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F41429d67-d9d6-4c35-9295-43c916ad9efe%2FUntitled.png?table=block&amp;id=ed522b4b-8cfb-487b-9f29-934b38272052&amp;t=ed522b4b-8cfb-487b-9f29-934b38272052&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-da3ff403c35e441b8f8f49db3b0917bf" data-id="da3ff403c35e441b8f8f49db3b0917bf"><span><div id="da3ff403c35e441b8f8f49db3b0917bf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#da3ff403c35e441b8f8f49db3b0917bf" title="Noise reduction (NR)"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Noise reduction (NR)</span></span></h3><div class="notion-text notion-block-8af2efc53cab46d3bd0fce05e3cb87ee">Most cameras apply additional NR after A/D conversion </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c50e525913b3409b897dc719764c7848"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F1fe0d180-ffeb-4129-9123-e82838a2c562%2FUntitled.png?table=block&amp;id=c50e5259-13b3-409b-897d-c719764c7848&amp;t=c50e5259-13b3-409b-897d-c719764c7848&amp;width=827.0051879882812&amp;cache=v2" alt="Analog-to-Digital Converte（ADC）" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">Analog-to-Digital Converte（ADC）</figcaption></div></figure><div class="notion-text notion-block-c833bae9ff7a4db7917d5c4b3078733d">Two main sources of image noise:</div><ol start="1" class="notion-list notion-list-numbered notion-block-79024456e11d4aeebe82d7ee13adcdee" style="list-style-type:decimal"><li>The quantum nature of light (photon noise/shot noise); unrelated to the imaging sensor. Follows a
Poisson distribution.</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-dac9a79f107545c887e4d832974b71ad" style="list-style-type:decimal"><li>Electronic sources associated with the imaging sensor circuitry (dark current and dark noise).
Often follows a Normal distribution.</li></ol><div class="notion-text notion-block-d3def8d45eab48a1a515ca347dcde71e">Gain factor g amplifies noise. </div><div class="notion-text notion-block-3f46cb06e54d41f9939f5ea2b10ff1f1">Blur the image based on the ISO setting (higher ISO = more blur). Blurring will reduce noise, but also remove detail. Add image detail back for regions that have a high signal. We can even boost some parts of the signal to enhance detail (i.e. &quot;sharpening&quot;)</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ab9f2f8772994de9993a88478ee374b6"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fe7043a92-0adf-4289-b3bd-dfcbaff02fbe%2FUntitled.png?table=block&amp;id=ab9f2f87-7299-4de9-993a-88478ee374b6&amp;t=ab9f2f87-7299-4de9-993a-88478ee374b6&amp;width=810.4910888671875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-5ce80169db3845fdb8c1aca1a3ed3232" data-id="5ce80169db3845fdb8c1aca1a3ed3232"><span><div id="5ce80169db3845fdb8c1aca1a3ed3232" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5ce80169db3845fdb8c1aca1a3ed3232" title="White-balance &amp; color space transform(CIE XYZ)"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">White-balance &amp; color space transform(CIE XYZ)</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-562a3ea8cd7547cd916391635ec843b0" data-id="562a3ea8cd7547cd916391635ec843b0"><span><div id="562a3ea8cd7547cd916391635ec843b0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#562a3ea8cd7547cd916391635ec843b0" title="Color mapping/colorimetric stage"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color mapping/colorimetric stage</span></span></h4><div class="notion-text notion-block-ab3f76c8ec13403bb6273d28eb7814a8">This step in the IPS converts the sensor raw-RGB values to a device-independent color space. It’s a two step procedure, first apply a white-balance correction to the raw-RGB values, then map the white-balanced raw-RGB values to CIE XYZ.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c91545b40a4743dfb24cf14a7cd5acbe"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:314px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F455ca93d-3035-477c-a36a-a626a6664c38%2FUntitled.png?table=block&amp;id=c91545b4-0a47-43df-b24c-f14a7cd5acbe&amp;t=c91545b4-0a47-43df-b24c-f14a7cd5acbe&amp;width=314&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-02994a1876b44b0499936324e9b0e375">How do white balance (computational color constancy) work? We have a special matrix</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b2f57602df6340efb4affe50025282e3"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F20b3ae0e-a229-43ee-a0e4-15fd7588790e%2FUntitled.png?table=block&amp;id=b2f57602-df63-40ef-b4af-fe50025282e3&amp;t=b2f57602-df63-40ef-b4af-fe50025282e3&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-3d7f34b429884974bec56f23bd82c8e7">Users can manually set the white balance, otherwise auto white balance (AWB) is performed. In computer vision, we often refer to AWB as &quot;illumination estimation&quot;. Since the hard part is trying to determine what the illumination in the scene is. AWB is not easy and this remains an open research problem.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-dd467600fbc14eb1800070f34bdb7976"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F3f87b103-bd5f-496d-bfeb-aef757a0aba4%2FUntitled.png?table=block&amp;id=dd467600-fbc1-4eb1-8000-70f34bdb7976&amp;t=dd467600-fbc1-4eb1-8000-70f34bdb7976&amp;width=827.0051879882812&amp;cache=v2" alt="WB manual" loading="lazy" decoding="async"/><figcaption class="notion-asset-caption">WB manual</figcaption></div></figure><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-d71678e049824eda81633e05ccccf320" data-id="d71678e049824eda81633e05ccccf320"><span><div id="d71678e049824eda81633e05ccccf320" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d71678e049824eda81633e05ccccf320" title="AWB"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">AWB</span></span></h4><div class="notion-text notion-block-4abf2b748d5047ad87215943a4d7e374">Given an arbitrary raw-RGB image, determine what is the camera&#x27;s response to the illumination. The idea is that something that is white* is a natural reflector of the scene&#x27;s illuminations SPD.
So, if we can identify what is &quot;white&quot; in the raw-RGB image, we are observing the sensor&#x27;s RGB response to the illumination.</div><div class="notion-text notion-block-61272f31c3be449da78701228446c58e">First we introduce <em><span class="notion-blue">&quot;Gray world&quot; algorithm.</span></em></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c6d38af0c8f34f6385005edda749416f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fb47d6cd9-afc2-46f6-ba19-8ad9d9cc5112%2FUntitled.png?table=block&amp;id=c6d38af0-c8f3-4f63-8500-5edda749416f&amp;t=c6d38af0-c8f3-4f63-8500-5edda749416f&amp;width=810.4910888671875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-65d53d5cc52e44438cc8d129226d0f9c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F4d16a8cb-72f0-4839-8377-ee12d072d063%2FUntitled.png?table=block&amp;id=65d53d5c-c52e-4443-8cc8-d129226d0f9c&amp;t=65d53d5c-c52e-4443-8cc8-d129226d0f9c&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-b9e1f6a0fbce4ad8937cf9c33cdf20ee">Also we have <em><span class="notion-blue">&quot;White patch&quot; algorithm.</span></em></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-bbf8485fcc5d466eb002134fbd4307bf"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fd0950b91-c08e-480c-a097-82dc001028fa%2FUntitled.png?table=block&amp;id=bbf8485f-cc5d-466e-b002-134fbd4307bf&amp;t=bbf8485f-cc5d-466e-b002-134fbd4307bf&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-101f86d4477844f18ef3ae3f05aee326"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fa69944f3-7bb0-4fe7-a06a-deaa757d7d9c%2FUntitled.png?table=block&amp;id=101f86d4-4778-44f1-8ef3-ae3f05aee326&amp;t=101f86d4-4778-44f1-8ef3-ae3f05aee326&amp;width=810.4910888671875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-callout notion-gray_background_co notion-block-e556ec240e9141558293fdcad19dc8a5"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🚨">🚨</span></div><div class="notion-callout-text">you can actually think of two different pool NN in PyTorch</div></div><div class="notion-text notion-block-ea71a1c2743a4c06b5e3df15b52fc649">Gray world and white patch are very basic algorithms. These both tend to fail when the image is dominated by large regions of a single color (e.g. a sky image).</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-e0abe37830b64c36827c568dad48b189" data-id="e0abe37830b64c36827c568dad48b189"><span><div id="e0abe37830b64c36827c568dad48b189" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e0abe37830b64c36827c568dad48b189" title="Color space transform"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color space transform</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b7762d1a76be479d92261c844e3c0c2d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:314px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fc82ef28f-23d3-4405-b0c7-bdf8de20b6a2%2FUntitled.png?table=block&amp;id=b7762d1a-76be-479d-9226-1c844e3c0c2d&amp;t=b7762d1a-76be-479d-9226-1c844e3c0c2d&amp;width=314&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-19eb7cd5fbad4e5c98937a2595bc91df"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:314px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F3e1d1a0e-b987-4b29-ab7a-ba8ae4e731ce%2FUntitled.png?table=block&amp;id=19eb7cd5-fbad-4e5c-9893-7a2595bc91df&amp;t=19eb7cd5-fbad-4e5c-9893-7a2595bc91df&amp;width=314&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d44a1bd873734c76861d0681244efcc4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:314px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fcb901e4d-723e-4f3a-ad64-ebd2b78731e1%2FUntitled.png?table=block&amp;id=d44a1bd8-7373-4c76-861d-0681244efcc4&amp;t=d44a1bd8-7373-4c76-861d-0681244efcc4&amp;width=314&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-dd8a6e49b7e7405a916407bcd7894170" data-id="dd8a6e49b7e7405a916407bcd7894170"><span><div id="dd8a6e49b7e7405a916407bcd7894170" class="notion-header-anchor"></div><a class="notion-hash-link" href="#dd8a6e49b7e7405a916407bcd7894170" title="Color manipulation (Photo-finishing)"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Color manipulation (Photo-finishing)</span></span></h3><div class="notion-text notion-block-ed571600e18448059ba417c463b4bf03">This is the stage where a camera applies its &quot;secret sauce&quot; to make the images look good.</div><ul class="notion-list notion-list-disc notion-block-d16b03d783c74691b612609031930202"><li>This procedure is called by many names:</li><ul class="notion-list notion-list-disc notion-block-d16b03d783c74691b612609031930202"><li>Color manipulation</li><li>Photo-finishing</li><li>Color rendering or selective color rendering</li><li>Yuv processing engine</li></ul></ul><ul class="notion-list notion-list-disc notion-block-ac24b0772f2945839453ad45e4d04c4d"><li>DSLR will often allow the user to select various photo-finishing styles.</li></ul><ul class="notion-list notion-list-disc notion-block-ba9038cd9441462e89328d12207ce68d"><li>Smartphones often compute this per-image.</li></ul><ul class="notion-list notion-list-disc notion-block-390b2a22afc143f0a966bbdd2c21eb7c"><li>Photo-finishing may also tied to geographical regions!</li></ul><div class="notion-text notion-block-0c7dcd4231034b8598ca2a8ede80a015">Color manipulation can be implemented using a 3D look up table (LUT) and a 1D LUT tone-curve.
The 3D LUT table acts like a 3D function: 𝑓 (𝑅, 𝐺, 𝐵) → 𝑅′, 𝐺′, 𝐵′
The 1D LUT table is applied per channel: g (𝑅) → 𝑅′, 𝑔 (𝐺) → 𝐺′, 𝑔 (𝐵) → 𝐵′
The 3D and 1D LUT can change based on picture style</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-06db2fb8cc444ba4a79fb546e939fe03"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Feb2872eb-6600-4b83-b7be-a287770482d2%2FUntitled.png?table=block&amp;id=06db2fb8-cc44-4ba4-a79f-b546e939fe03&amp;t=06db2fb8-cc44-4ba4-a79f-b546e939fe03&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-abe6f75bedee4fa794d96e32783dbee0">There’s also <em><span class="notion-blue">Local tone mapping (LTM) </span></em>compared to the <em><span class="notion-blue">Global tone mapping (GTM)</span></em></div><div class="notion-callout notion-gray_background_co notion-block-8f44cb09cc9b4a74967f25fb2be73ed0"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🚨">🚨</span></div><div class="notion-callout-text">On many cameras, esp smartphones, a local tone map is applied as part of the photo-finishing. This helps bring out highlights in the image.</div></div><div class="notion-text notion-block-3ec118f20d4a43089aae3131c66c32e6"><em><span class="notion-blue">Selective color manipulation, </span></em>&quot;Select&quot; colors can be manipulated, especially skin tone, sometimes called preferred color correction (PCC)</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-39068c8599c447f9935534b8c06f0e56" data-id="39068c8599c447f9935534b8c06f0e56"><span><div id="39068c8599c447f9935534b8c06f0e56" class="notion-header-anchor"></div><a class="notion-hash-link" href="#39068c8599c447f9935534b8c06f0e56" title="Image rescaling (or up-scaling)"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Image rescaling (or up-scaling)</span></span></h3><div class="notion-text notion-block-f9f1abd3afeb4a619bf349a430144f33"><em><span class="notion-blue">Re-scaling image and sRGB conversion</span></em>,  often, the entire image is processed by the ISP and then rescaled for the view-finder or to fit the requested output resolution.</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-5338501f01c64714945260d04876c3c4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F41afd88a-5887-4722-b21e-75fb4dbac2f4%2FUntitled.png?table=block&amp;id=5338501f-01c6-4714-9452-60d04876c3c4&amp;t=5338501f-01c6-4714-9452-60d04876c3c4&amp;width=835.9933471679688&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-ef2bf997973d4b1f9c1e1c1246b08d77" data-id="ef2bf997973d4b1f9c1e1c1246b08d77"><span><div id="ef2bf997973d4b1f9c1e1c1246b08d77" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ef2bf997973d4b1f9c1e1c1246b08d77" title="Mapping to output color space"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Mapping to output color space</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b9c5a1ce25404f568ab5cc5c69bf669e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Fe3bd6199-6761-4fee-bad8-50b33e3e74f9%2FUntitled.png?table=block&amp;id=b9c5a1ce-2540-4f56-8ab5-cc5c69bf669e&amp;t=b9c5a1ce-2540-4f56-8ab5-cc5c69bf669e&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-478100f7ca0f4477b854b7cede19013f" data-id="478100f7ca0f4477b854b7cede19013f"><span><div id="478100f7ca0f4477b854b7cede19013f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#478100f7ca0f4477b854b7cede19013f" title="JPEG/HEIC compression"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">JPEG/HEIC compression</span></span></h3><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-cfc47b178a964175ba44c6ae8e39c3a7"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2Feb183718-3413-4271-a3a7-610c51646a2f%2FUntitled.png?table=block&amp;id=cfc47b17-8a96-4175-ba44-c6ae8e39c3a7&amp;t=cfc47b17-8a96-4175-ba44-c6ae8e39c3a7&amp;width=827.0051879882812&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-ded5f5a4265443e1b28b92e079774492">The amount of quantization applied on the DCT coefficients amounts to a “quality” factor.</div><ul class="notion-list notion-list-disc notion-block-dc327a2fdaca43bc9376afaecaf9d7ee"><li>More quantization = better compression (smaller file size)</li></ul><ul class="notion-list notion-list-disc notion-block-dbde64ac361448b0ac7398462525f823"><li>More quantization = lower quality</li></ul><div class="notion-callout notion-gray_background_co notion-block-2f93c1f233074258a7c281b260780439"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🚨">🚨</span></div><div class="notion-callout-text">Note that both sRGB and JPEG are being slowly replaced</div></div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-b8a49fc1517245b0a811a31f321ef405" data-id="b8a49fc1517245b0a811a31f321ef405"><span><div id="b8a49fc1517245b0a811a31f321ef405" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b8a49fc1517245b0a811a31f321ef405" title="Save to file"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Save to file</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-f596e9542ee746fc8c8a91b0db809c58" data-id="f596e9542ee746fc8c8a91b0db809c58"><span><div id="f596e9542ee746fc8c8a91b0db809c58" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f596e9542ee746fc8c8a91b0db809c58" title="Circular buffer for ZSL(Zero Shutter Lag) and multi-frame processing"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Circular buffer for ZSL(Zero Shutter Lag) and multi-frame processing</span></span></h4><ul class="notion-list notion-list-disc notion-block-8e4f7dcd0f6b4011aa6f88da5d877d99"><li>Many ISPs store the last few RAW images in memory (i.e., a circular buffer).</li></ul><ul class="notion-list notion-list-disc notion-block-dcbd1e8a4f334b6f89da68a9ed41c1c8"><li>These images can be used for many purposes (image stabilization, temporal noise reduction, etc.).</li></ul><ul class="notion-list notion-list-disc notion-block-6a32d242be6a4231a8aeb4e51ac0ee4e"><li>Another purpose is to ensure “Zero Shutter Lag” (ZSL).</li><ul class="notion-list notion-list-disc notion-block-6a32d242be6a4231a8aeb4e51ac0ee4e"><li>There is often a delay between when a person presses the “capture” and the camera capturing the image. This is called “shutter lag”.</li><li>So, a previous image in the buffer can saved instead.</li></ul></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-f5d85c0274474f7b9ba5a5c06b0ed755"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F30eab5b6-8676-4623-a9a8-731bda975747%2FUntitled.png?table=block&amp;id=f5d85c02-7447-4f7b-9ba5-a5c06b0ed755&amp;t=f5d85c02-7447-4f7b-9ba5-a5c06b0ed755&amp;width=835.9877319335938&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-e0ce17b657b2402981208e4a22f44196"> </div><div class="notion-callout notion-gray_background_co notion-block-28f73b430d7f48c9a493b5c2e9510956"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🚨">🚨</span></div><div class="notion-callout-text">Again, it is important to stress that the exact steps mentioned in these notes only serve as a guide to what takes place in a camera</div></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-785758f6851b4e92a44a2cfde6eed444"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbcc83a06-70e2-4332-93f9-b89147e2a6bd%2F8c177b9f-ddbe-4314-ba8e-ba3337dff1ae%2FUntitled.png?table=block&amp;id=785758f6-851b-4e92-a44a-2cfde6eed444&amp;t=785758f6-851b-4e92-a44a-2cfde6eed444&amp;width=2050&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>