﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3AErwin94%2FKeying</id>
	<title>利用者:Erwin94/Keying - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3AErwin94%2FKeying"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Erwin94/Keying&amp;action=history"/>
	<updated>2026-09-22T05:42:28Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Erwin94/Keying&amp;diff=140383&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Erwin94/Keying&amp;diff=140383&amp;oldid=prev"/>
		<updated>2018-06-28T20:53:13Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 20:53時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Erwin94/Keying&amp;diff=140382&amp;oldid=prev</id>
		<title>2013年2月18日 (月) 12:48にwiki&gt;Erwin94による</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Erwin94/Keying&amp;diff=140382&amp;oldid=prev"/>
		<updated>2013-02-18T12:48:16Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Color Keying ===&lt;br /&gt;
&lt;br /&gt;
This page tries do give a brief introduction to color keying using the G-R/B difference process. The scene, that was used in&lt;br /&gt;
the examples, can be downloaded here: [[File:Keying_intro.blend]].&lt;br /&gt;
&lt;br /&gt;
Let's start with a simple test case, a perfect greenscreen (i.e. exactly 0,255,0). For the rest of this&lt;br /&gt;
page we will assume a green key color, everything works exactly the same for blue though.&lt;br /&gt;
&lt;br /&gt;
[[File:Key_00_source.png|640px]]&lt;br /&gt;
&lt;br /&gt;
The basic idea of difference keying is, that we want to use the fact that the green&lt;br /&gt;
channel is larger than the red or blue channel for green colors. Therefore let's try&lt;br /&gt;
subtracting the red channel from the green channel:&lt;br /&gt;
&lt;br /&gt;
[[File:Key_02.png|640px]]&lt;br /&gt;
&lt;br /&gt;
This results in this image:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_03.png|640px]]&lt;br /&gt;
&lt;br /&gt;
For the blue channel we get something slightly different. Some areas are better, while others are worse:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_04.png|640px]]&lt;br /&gt;
&lt;br /&gt;
To get the best of both results, we can mix the red and blue channel together before&lt;br /&gt;
subtracting:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_05.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Note that we have introduced two factors for the mixing. These will be configurable parameters&lt;br /&gt;
for the keying operation and will have to be set depending on the input image. For example, lowering&lt;br /&gt;
the red mix factor will help make the edges of red foreground objects better if they are too hard.&lt;br /&gt;
&lt;br /&gt;
For our case 0.5/0.6 seems like a good compromise and results in the following image:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_06.png|640px]]&lt;br /&gt;
&lt;br /&gt;
This already looks like a pretty decent key, so let's make it a bit harder (and more realistic) by introducing a&lt;br /&gt;
non-uniform green background:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_07.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Simply testing this with our keyer results in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_08.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Note that we still have a clean separation between foreground and background, but our background has&lt;br /&gt;
become very uneven and it won't be easy to use this key as it is now.&lt;br /&gt;
&lt;br /&gt;
Here we are going to cheat a little bit and assume you had the foresight while shooting your greenscreen&lt;br /&gt;
footage to also get a clean plate of the greenscreen without any foreground objects infront of it. For a lot of&lt;br /&gt;
real world examples you won't have this and there are ways to recreate it, but we won't cover those here.&lt;br /&gt;
The composite nodes &amp;quot;Keying Screen&amp;quot; and &amp;quot;Inpaint&amp;quot; will help a lot in those cases.&lt;br /&gt;
&lt;br /&gt;
This is what it looks like for our scene:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_09.png|640px]]&lt;br /&gt;
&lt;br /&gt;
So how does this help us? Let's try running it through our keyer:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_10.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Ah, so in the background areas this leads to exactly the same gradient as our key with foreground objects.&lt;br /&gt;
&lt;br /&gt;
We want those areas to be solid white again though, so let's divide the two keys:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_11.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Now our key looks good again:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_12.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Since we are repeating ourselves a bit here, we clean the tree a little bit by creating a nodegroup:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_13.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Our keyer now looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_14.png|640px]]&lt;br /&gt;
&lt;br /&gt;
So, let's try making it more difficult again. This time we add an object to the foreground that is closer to&lt;br /&gt;
the key color, but should not be transparent.&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_15.png|640px]]&lt;br /&gt;
&lt;br /&gt;
This results in the following key:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_15b.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Here, things start to get a little fuzzy. There are different ways to improve the key further, our&lt;br /&gt;
choice here is mostly for its simplicity and because it is still rather general.&lt;br /&gt;
&lt;br /&gt;
Since we now have a reference for the screen color, we know that any difference from it is likely&lt;br /&gt;
to be due to a foreground object. We can simply subtract the screen red and blue channels from&lt;br /&gt;
the corresponding image channels. This gives us a luminance key, i.e. everything with brighter red&lt;br /&gt;
or blue than the screen red or blue will become opaque. We use the maximum of both differences to&lt;br /&gt;
merge the keys:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_16.png|640px]]&lt;br /&gt;
&lt;br /&gt;
This part of the key looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_17.png|640px]]&lt;br /&gt;
&lt;br /&gt;
To merge this with our real key, we first invert our previous key, because we had a key value of 1 for the background&lt;br /&gt;
before, while we want alpha to be 1 for the foreground instead.&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_18.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Cleaning up our node tree again, we create a group from all nodes.&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_19.png|640px]]&lt;br /&gt;
&lt;br /&gt;
This leads to a nice reusable keying node.&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_20.png|640px]]&lt;br /&gt;
&lt;br /&gt;
So how is this newly calculated alpha channel used? We can try simply setting the alpha&lt;br /&gt;
of our image and converting it to a premultiplied image (which is what the compositor should&lt;br /&gt;
output).&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_21.png|640px]]&lt;br /&gt;
&lt;br /&gt;
This results in green fringes though:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_22.png|640px]]&lt;br /&gt;
&lt;br /&gt;
To understand what we have to do instead, we can take a look at how an image with alpha is composited&lt;br /&gt;
over another image. If A is our (premultiplied) foreground color, B is our background then the composited&lt;br /&gt;
output color C is: C = A + (1-alpha) * B. In this equation we already know C, alpha and B for the composite&lt;br /&gt;
of our foreground over the greenscreen background. So we can calculate A = C - (1-alpha) * B:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_23.png|640px]]&lt;br /&gt;
&lt;br /&gt;
This leads to the following result:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_24.png|640px]]&lt;br /&gt;
&lt;br /&gt;
Composited over a different background it looks like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Keying_26.png|640px]]&lt;br /&gt;
&lt;br /&gt;
This already looks pretty good, but this is only the start of a good key for real world footage.&lt;br /&gt;
Usually you will need a garbage mask to define which areas are always going to be transparent&lt;br /&gt;
and a core matte to define areas that should be opaque. But this difference key works exceptionally well&lt;br /&gt;
on edges, if set to the right red and blue weights. Sometimes different edges in an image need different&lt;br /&gt;
weights, then the method should be to have two or more of these keyers and merge the results based on&lt;br /&gt;
a selection mask (sometimes a hue key works well as a selection, sometimes a painted mask is easier).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Happy keying!&lt;/div&gt;</summary>
		<author><name>wiki&gt;Erwin94</name></author>
		
	</entry>
</feed>