1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>7.2. Convolution matrix</title>
<link rel="stylesheet" href="gimp-help-plain.css" type="text/css" />
<link rel="stylesheet" href="gimp-help-screen.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.66.1" />
<link rel="start" href="index.html" title=" " />
<link rel="up" href="ch06s07.html" title="7. Generic filters" />
<link rel="prev" href="ch06s07.html" title="7. Generic filters" />
<link rel="next" href="ch06s07s03.html" title="7.3. Dilate" />
</head>
<body>
<div xmlns="" class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center" id="chaptername">7.2. Convolution matrix</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="ch06s07.html">Prev</a> </td>
<th width="60%" align="center" id="sectionname">7.2. Convolution matrix</th>
<td width="20%" align="right"> <a accesskey="n" href="ch06s07s03.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="plug-in-convmatrix"></a>7.2. Convolution matrix</h3>
</div>
</div>
</div>
<a id="id3363586" class="indexterm"></a>
<div class="mediaobject">
<img src="../images/filters/filters-generic-convolution.png" />
</div>
<div class="simplesect" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3363532"></a>Overview</h4>
</div>
</div>
</div>
<p>
This filter is found in
<span class="guimenuitem">Image>Filters/Generic/<span class="accel">C</span>onvolution Matrix</span>
</p>
<p>
Here is a mathematician's domain. Most of filters are using convolution
matrix. With the Convolution Matrix filter, if the fancy takes you, you
can build a custom filter.
</p>
<p>
What is a convolution matrix? It's possible to get a rough idea of it without using
mathematical tools that only a few ones know. Convolution is the treatment of a matrix
by another one which is called "kernel".
</p>
<p>
The Convolution Matrix filter uses a first matrix which is the Image to be treated.
The image is a bi-dimensionnal collection of pixels in rectangular coordinates. The
used kernel depends on the effect you want.
</p>
<p>
GIMP uses 5x5 or 3x3 matrices. We will consider only 3x3 matrices, they are
the most used and they are enough for all effects you want. If all border
values of a kernel are set to
zero, then system will consider it as a 3x3 matrix.
</p>
<p>
The filter studies successively every pixel of the image. For each of them,
which we will calll the "initial pixel", it multiplies value of this
pixel and values of the 8 surrounding
pixels by the kernel corresponding value. Then it adds the results, and the
initial pixel is set to takes this final result value.
</p>
<p>
A simple example:
</p>
<div class="mediaobject">
<img src="../images/filters/examples/convolution-example1.png" />
</div>
<p>
On the left is the image matrix: each pixel is marked with its value. The
initial pixel has a red border. The kernel action area has a green border.
In the middle is the kernel and, on the right is the convolution result.
</p>
<p>
Here is what happened: the filter read successively, from left to right and
from top to bottom, all the pixels of the kernel action area. It multiplied
the value of each of them by the kernel corresponding value and added results:
(100*0)+(50*1)+(50*0)*(100*0)+(100*0) +(100*0)+(100*0)+(100*0)+(100*0)+(100*0) = 50.
The initial pixel took the value 50. Previously, when the initial pixel had
value=50, it took the value 100 of the above pixel (the filter doesn't
work on the image but on a copy) and so disappeared into the "100" background
pixels. As a graphical result, the initial pixel moved a pixel downwards.
</p>
</div>
<div class="simplesect" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3363540"></a>Options</h4>
</div>
</div>
</div>
<div class="variablelist">
<dl>
<dt>
<span class="term">Matrix</span>
</dt>
<dd>
<p>
This is the 5x5 kernel matrix: you enter wanted values directly into boxes.
</p>
<p>
<span class="guilabel">Divisor</span>: The result of previous calculation will be divided by
this divisor. You will hardly use 1, that lets result unchanged, and 9 or 25
according to matrix size, that gives the average of pixel values.
</p>
<p>
<span class="guilabel">Offset</span>: this value is added to the division result. This is
useful if result may be negative. This offset may be negative.
</p>
</dd>
<dt>
<span class="term">Border</span>
</dt>
<dd>
<p>
When the initial pixel is on a border, a part of kernel is out of image. You have to
decide what filter must do:
</p>
<div class="mediaobject">
<img src="../images/filters/filters-convolution-milord.png" />
</div>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>
<span class="guilabel">Extend</span>: this part of kernel is not taken into acount.
</p>
<div class="mediaobject">
<img src="../images/filters/filters-convolution-extend.png" />
</div>
</li>
<li>
<p>
<span class="guilabel">Wrap</span>: this part of kernel will study pixels of the opposite
border, so pixels disappearing from one side reappear on the other side.
</p>
<div class="mediaobject">
<img src="../images/filters/filters-convolution-wrap.png" />
</div>
</li>
<li>
<p>
<span class="guilabel">Crop</span>: Pixels on borders are not modified, but they are cropped.
</p>
<div class="mediaobject">
<img src="../images/filters/filters-convolution-crop.png" />
</div>
</li>
</ul>
</div>
</dd>
<dt>
<span class="term">Channels</span>
</dt>
<dd>
<p>
You can select there one or several channels the filter will work with.
</p>
</dd>
<dt>
<span class="term">Automatic</span>
</dt>
<dd>
<p>
If this option is checked, The Divisor takes the result value of convolution. If
this result is equal to zero (it's not possible to divide by zero), then a 128
offset is applied. If it is negative ( a negative color is not possible), a
255 offset is applied (inverts result).
</p>
</dd>
<dt>
<span class="term">Alpha weighting</span>
</dt>
<dd>
<p>
If this option is not checked, the filter doesn't take in account transparency and this
may be cause of some artefacts when blurring.
</p>
</dd>
</dl>
</div>
</div>
<div class="simplesect" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="id3364126"></a>Examples</h4>
</div>
</div>
</div>
<p>
Design of kernels is based on high levels mathematics. You can find ready-made
kernels on the Web. Here are a few examples:
</p>
<div class="variablelist">
<dl>
<dt>
<span class="term">Sharpen</span>
</dt>
<dd>
<div class="mediaobject">
<img src="../images/filters/examples/convolution-sharpen.png" />
</div>
</dd>
<dt>
<span class="term">Blur</span>
</dt>
<dd>
<div class="mediaobject">
<img src="../images/filters/examples/convolution-blur.png" />
</div>
</dd>
<dt>
<span class="term">Edge enhance</span>
</dt>
<dd>
<div class="mediaobject">
<img src="../images/filters/examples/convolution-edge.png" />
</div>
</dd>
<dt>
<span class="term">Edge detect</span>
</dt>
<dd>
<div class="mediaobject">
<img src="../images/filters/examples/convolution-edge-detect1.png" />
</div>
</dd>
<dt>
<span class="term">Emboss</span>
</dt>
<dd>
<div class="mediaobject">
<img src="../images/filters/examples/convolution-emboss.png" />
</div>
</dd>
</dl>
</div>
</div>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="ch06s07.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="ch06s07.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="ch06s07s03.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">7. Generic filters </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> 7.3. Dilate</td>
</tr>
</table>
</div>
</body>
</html>
|