<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.avisynth.nl/index.php?action=history&amp;feed=atom&amp;title=MaskTools%2FDEdgeMask</id>
	<title>MaskTools/DEdgeMask - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.avisynth.nl/index.php?action=history&amp;feed=atom&amp;title=MaskTools%2FDEdgeMask"/>
	<link rel="alternate" type="text/html" href="http://www.avisynth.nl/index.php?title=MaskTools/DEdgeMask&amp;action=history"/>
	<updated>2026-09-01T07:55:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>http://www.avisynth.nl/index.php?title=MaskTools/DEdgeMask&amp;diff=161&amp;oldid=prev</id>
		<title>Admin: 1 revision</title>
		<link rel="alternate" type="text/html" href="http://www.avisynth.nl/index.php?title=MaskTools/DEdgeMask&amp;diff=161&amp;oldid=prev"/>
		<updated>2013-05-09T15:01:59Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{FilterCat|External_filters|Other_filters|Support_filters}}&lt;br /&gt;
&lt;br /&gt;
{{Func2Def|DEdgeMask (clip[, int &amp;quot;thY1&amp;quot;[, int &amp;quot;thY2&amp;quot;[, int &amp;quot;thC1&amp;quot;[, int &amp;quot;thC2&amp;quot;[, string &amp;quot;matrix&amp;quot;[, float &amp;quot;divisor&amp;quot;[, bool &amp;quot;setdivisor&amp;quot;[, bool &amp;quot;vmode&amp;quot;]]]]]]]])&lt;br /&gt;
|DEdgeMask2 (clip source, clip low_thres, clip high_thres[, string &amp;quot;matrix&amp;quot;[, float &amp;quot;divisor&amp;quot;[, bool &amp;quot;setdivisor&amp;quot;[, bool &amp;quot;vmode&amp;quot;]]]])}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Plugin&amp;#039;&amp;#039;&amp;#039;: [[MaskTools]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DEdgeMask&amp;#039;&amp;#039;&amp;#039; creates an edge mask of the picture. The edge-finding algorithm uses a convolution kernel, and the result of the convolution is then thresholded with &amp;lt;tt&amp;gt;thY1&amp;lt;/tt&amp;gt; and  &amp;lt;tt&amp;gt;thY2&amp;lt;/tt&amp;gt; (luma) and &amp;lt;tt&amp;gt;thC1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;thC2&amp;lt;/tt&amp;gt; (chroma). The thresholding happens like that (r is the result of the convolution):&lt;br /&gt;
&lt;br /&gt;
* r &amp;lt;= th1 gives 0.&lt;br /&gt;
* th1 &amp;lt; r &amp;lt;= th2 gives r.&lt;br /&gt;
* th2 &amp;lt; r gives 255.&lt;br /&gt;
&lt;br /&gt;
In order to create a binary mask, you just have to set th1=th2.&lt;br /&gt;
&lt;br /&gt;
The choice of the convolution kernel is done with &amp;lt;tt&amp;gt;matrix&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;matrix&amp;lt;/tt&amp;gt; must be a 3 by 3 matrix, whose coefficients are integers, separated by a single space. Hence, the strings &amp;quot;-1 -1 -1 -1 8 -1 -1 -1 -1&amp;quot; and &amp;quot;0 -1 0 -1 0 1 0 1 0&amp;quot; will respectively give the kernels &amp;quot;laplace&amp;quot; and &amp;quot;sobel&amp;quot; of the filter [[MaskTools/EdgeMask|EdgeMask]].&lt;br /&gt;
&lt;br /&gt;
As coefficients must be integers, &amp;lt;tt&amp;gt;divisor&amp;lt;/tt&amp;gt; is used to refine the result of the convolution. This result will simply be divided by &amp;lt;tt&amp;gt;divisor&amp;lt;/tt&amp;gt;. If &amp;lt;tt&amp;gt;divisor&amp;lt;/tt&amp;gt; isn&amp;#039;t defined, it is defaulted to the sum of the positive coefficients of the matrix, thus allowing a classic normalization. It can be either a float or an integer, the later being the faster.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;setdivisor&amp;lt;/tt&amp;gt; is present only for backward compatibility. Do not use it.&lt;br /&gt;
&lt;br /&gt;
Finally &amp;lt;tt&amp;gt;vmode&amp;lt;/tt&amp;gt; allows to output a mask centered to 128 instead of zero. &lt;br /&gt;
&lt;br /&gt;
Defaults are:&lt;br /&gt;
* &amp;lt;tt&amp;gt;thY1&amp;lt;/tt&amp;gt; = 0, &amp;lt;tt&amp;gt;thY2&amp;lt;/tt&amp;gt; = 20, &lt;br /&gt;
* &amp;lt;tt&amp;gt;thC1&amp;lt;/tt&amp;gt; = 0, &amp;lt;tt&amp;gt;thC2&amp;lt;/tt&amp;gt; = 20, &lt;br /&gt;
* &amp;lt;tt&amp;gt;matrix&amp;lt;/tt&amp;gt; = &amp;quot;-1 -1 -1 -1 8 -1 -1 -1 -1&amp;quot; &lt;br /&gt;
* &amp;lt;tt&amp;gt;vmode&amp;lt;/tt&amp;gt; = false.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;DEdgeMask2&amp;#039;&amp;#039;&amp;#039; basically works like DEdgeMask, except that instead of 2 low / high thresholds, it takes 2 other clips. Each clip contains local thresholds for each pixel. &lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s say you want adaptive thresholds taking local contrast into account. Well, local min &amp;amp; max can be obtained through [[MaskTools/Inpand|inpand()]] and [[MaskTools/Expand|expand()]]. Difference can be made with [[MaskTools/YV12LUTxy|YV12LUTxy]] or [[MaskTools/YV12Subtract|YV12Subtract]]. And voilΰ, you&amp;#039;ve got a threshold clip containing local contrasts.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Back to [[MaskTools]].&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>