/usr/share/doc/gimp-plugin-registry/refocus/doc.html is in gimp-plugin-registry 5.20120621.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <?xml version="1.0" encoding="ISO-8859-1"?>
<!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><title xmlns="http://www.w3.org/1999/xhtml">refocus</title><meta xmlns="http://www.w3.org/1999/xhtml" name="generator" content="DocBook XSL Stylesheets V1.49"/></head><body><div xmlns="http://www.w3.org/1999/xhtml" class="article"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h1 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id2799801"/>refocus</h1></div><div xmlns="http://www.w3.org/1999/xhtml"><h3 xmlns="http://www.w3.org/1999/xhtml" class="subtitle"><i>A Gimp plug-in for sharpening images</i></h3></div><div xmlns="http://www.w3.org/1999/xhtml"><h3 xmlns="http://www.w3.org/1999/xhtml" class="author">Ernst Lippe</h3><div xmlns="http://www.w3.org/1999/xhtml" class="affiliation"><div xmlns="http://www.w3.org/1999/xhtml" class="address"><p><tt xmlns="http://www.w3.org/1999/xhtml"><<a xmlns="http://www.w3.org/1999/xhtml" href="mailto:ernstl@users.sourceforge.net">ernstl@users.sourceforge.net</a>></tt></p></div></div></div><hr xmlns="http://www.w3.org/1999/xhtml"/></div><div xmlns="http://www.w3.org/1999/xhtml" class="toc"><p xmlns="http://www.w3.org/1999/xhtml"><b>Table of Contents</b></p><dl><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2755288">Introduction</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#installation">Installation</a></dt><dd><dl><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2751335">Requirements</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#atlas">Using ATLAS</a></dt><dd><dl><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2751556">What is ATLAS</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2751936">How to use ATLAS</a></dt></dl></dd></dl></dd><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#using">Using the plug-in</a></dt><dd><dl><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2751603">The preview</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2751658">The parameters</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2752608">Tips and tricks</a></dt><dd><dl><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2752622">General</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2752653">Performance</a></dt></dl></dd><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2752745">Technical background</a></dt><dd><dl><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2814164">Modeling the convolution</a></dt><dd><dl><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2814208">The Gaussian convolution</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2814228">The circular convolution</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2814246">Convolutions in the plug-in</a></dt><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2814334">Comparison with other techniques</a></dt></dl></dd></dl></dd></dl></dd><dt><a xmlns="http://www.w3.org/1999/xhtml" href="#id2813911">Acknowledgements</a></dt></dl></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect1"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h2 class="title" style="clear: both"><a xmlns="http://www.w3.org/1999/xhtml" id="id2755288"/>Introduction</h2></div></div><p xmlns="http://www.w3.org/1999/xhtml">The refocus Gimp plug-in can be used to sharpen images.
Frequently, when processing images, e.g. when scanning photo's
or slides, the images become slightly blurred.
This plug-in attempts to "refocus" the image.
In many cases this plug-in produces much better results than similar
plug-ins such as sharpen or unsharp mask.
</p><p xmlns="http://www.w3.org/1999/xhtml">This plug-in has a preview that helps you select the best parameters.</p><p xmlns="http://www.w3.org/1999/xhtml">Instructions for installing the plug-in are described in <a xmlns="http://www.w3.org/1999/xhtml" href="#installation">Installation</a>. </p><p xmlns="http://www.w3.org/1999/xhtml">Instructions for using the plug-in are described in <a xmlns="http://www.w3.org/1999/xhtml" href="#using">Using the plug-in</a>. </p><p xmlns="http://www.w3.org/1999/xhtml">The home page for the Refocus plug-in is located at
<a xmlns="http://www.w3.org/1999/xhtml" href="http://refocus.sourceforge.net" target="_top">http://refocus.sourceforge.net</a>.</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect1"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h2 class="title" style="clear: both"><a xmlns="http://www.w3.org/1999/xhtml" id="installation"/>Installation</h2></div></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect2"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h3 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2751335"/>Requirements</h3></div></div><p xmlns="http://www.w3.org/1999/xhtml">
For installing refocus you need the following:
</p><p xmlns="http://www.w3.org/1999/xhtml"> <div xmlns="http://www.w3.org/1999/xhtml" class="itemizedlist"><ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">The Gimp, of course. This plug-in should work with versions > 1.2.
</p></li><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Gtk+-2 plus <b xmlns="http://www.w3.org/1999/xhtml">pkg-config</b>.</p></li><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Optional: ATLAS, see <a xmlns="http://www.w3.org/1999/xhtml" href="#atlas">Using ATLAS</a>
</p></li></ul></div></p><p xmlns="http://www.w3.org/1999/xhtml">Installation should be simple. Untar the distribution.
If you want to use ATLAS install it in lib-atlas (see <a xmlns="http://www.w3.org/1999/xhtml" href="#atlas">Using ATLAS</a>).
</p><p xmlns="http://www.w3.org/1999/xhtml">
Then run <b xmlns="http://www.w3.org/1999/xhtml">./configure</b> in the top-level directory.</p><p xmlns="http://www.w3.org/1999/xhtml">Then run <b xmlns="http://www.w3.org/1999/xhtml">make install-bin</b> if you
want to install the plug-in under your home directory or
<b xmlns="http://www.w3.org/1999/xhtml">make install-admin-bin</b> if you
want to install the plug-in under your Gimp's system directory.</p><p xmlns="http://www.w3.org/1999/xhtml">If you have gtk-doc installed you can build the system documentation
in the <tt xmlns="http://www.w3.org/1999/xhtml">gtk-doc</tt> directory.
In this case you must invoke <b xmlns="http://www.w3.org/1999/xhtml">configure</b> with the <tt xmlns="http://www.w3.org/1999/xhtml">--enable-gtk-doc</tt> option.
When you <b xmlns="http://www.w3.org/1999/xhtml">make</b> it for the first time <b xmlns="http://www.w3.org/1999/xhtml">make</b> will fail with the message
<tt xmlns="http://www.w3.org/1999/xhtml">No rule to make target `tmpl/*.sgml'</tt>.
Running <b xmlns="http://www.w3.org/1999/xhtml">make</b> again will fix this problem.</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect2"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h3 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="atlas"/>Using ATLAS</h3></div></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect3"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h4 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2751556"/>What is ATLAS</h4></div></div><p xmlns="http://www.w3.org/1999/xhtml">ATLAS (see <a xmlns="http://www.w3.org/1999/xhtml" href="http://math-atlas.sourceforge.net" target="_top">http://math-atlas.sourceforge.net</a>) is
a system for generating high-performance mathematical libraries.
It generates a library that is specifically tuned to your processor and compiler.
refocus needs some routines for solving a linear system of equations.
By default refocus uses an unoptimized version from the CLAPACK distribution
(see <a xmlns="http://www.w3.org/1999/xhtml" href="http://www.netlib.org/clapack/" target="_top">http://www.netlib.org/clapack/</a>).
</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect3"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h4 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2751936"/>How to use ATLAS</h4></div></div><div xmlns="http://www.w3.org/1999/xhtml" class="itemizedlist"><ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: disc"><p xmlns="http://www.w3.org/1999/xhtml">
Make ATLAS generate its libraries.
For instructions see the ATLAS documentation.
Depending on your system, this may take a long time.
During the installation you have to select a name to identify your configuration.
In the following examples we will use Linux_PII as the chosen name.</p></li><li xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: disc"><p xmlns="http://www.w3.org/1999/xhtml">
Go to the subdirectory lib/Linux_PII and run <b xmlns="http://www.w3.org/1999/xhtml">make</b>.</p><pre xmlns="http://www.w3.org/1999/xhtml" class="programlisting">cd lib/Linux_PII
make</pre><p xmlns="http://www.w3.org/1999/xhtml">
This will generate a gzipped tar file that contains the generated libraries
and include files.
</p></li><li xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: disc"><p xmlns="http://www.w3.org/1999/xhtml">
Copy the gzipped tar file to the refocus directory and unpack it.</p><pre xmlns="http://www.w3.org/1999/xhtml" class="programlisting">cp ~/ATLAS/lib/atlas3.4.1_Linux_PII.tgz ~/refocus
cd ~/refocus
zcat atlas3.4.1_Linux_PII.tgz |tar xvf -
mv Linux_PII lib-atlas
</pre></li><li xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: disc"><p xmlns="http://www.w3.org/1999/xhtml">
If you have already run <b xmlns="http://www.w3.org/1999/xhtml">configure</b>
, you must delete the file <tt xmlns="http://www.w3.org/1999/xhtml">config.cache</tt>.</p></li><li xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: disc"><p xmlns="http://www.w3.org/1999/xhtml">Then run <b xmlns="http://www.w3.org/1999/xhtml">configure</b>.
If everything is OK you should see a message like
<tt xmlns="http://www.w3.org/1999/xhtml">using atlas in lib-atlas/lib</tt>.</p></li><li xmlns="http://www.w3.org/1999/xhtml" style="list-style-type: disc"><p xmlns="http://www.w3.org/1999/xhtml">
Now run <b xmlns="http://www.w3.org/1999/xhtml">make</b>.</p></li></ul></div><p xmlns="http://www.w3.org/1999/xhtml"> </p></div></div></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect1"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h2 class="title" style="clear: both"><a xmlns="http://www.w3.org/1999/xhtml" id="using"/>Using the plug-in</h2></div></div><p xmlns="http://www.w3.org/1999/xhtml">You can start the plug-in by clicking with the right
mouse-button in the image, and then select from the
Filters menu Enhance/Refocus.</p><p xmlns="http://www.w3.org/1999/xhtml">The plug-in window looks something like this:</p><div xmlns="http://www.w3.org/1999/xhtml" class="mediaobject"><img src="images/gui.png" alt="GUI screen dump"/></div><p xmlns="http://www.w3.org/1999/xhtml">The plug-in window contains a preview of the image on the left
and on the right a set of
spin-buttons to change its parameters.
</p><p xmlns="http://www.w3.org/1999/xhtml">
The bottom of the preview contains the following buttons:
<div xmlns="http://www.w3.org/1999/xhtml" class="variablelist"><dl><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term">OK</span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Quit the plug-in and apply the selected transformation to
the image.</p></dd><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term">Defaults</span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Select default values for all parameters.</p></dd><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term">Preview</span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Compute the new transformation matrix and show the results in the
preview.
Because computing the transformation matrix can take a lot of time, it
is not automatically recomputed, when the parameters in the
spin-buttons have changed.
When you have changed parameters the Preview button
will change to active, i.e. it is no longer grayed out.
<div xmlns="http://www.w3.org/1999/xhtml" class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p xmlns="http://www.w3.org/1999/xhtml">When the plug-in starts it shows the original untransformed
image.
When you press the Preview button the
transformation matrix is computed and the transformed image
will be shown in the preview.
</p></div>
</p></dd><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term">Cancel</span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Quit the plug-in without applying the selected transformation to
the image.</p></dd></dl></div>
</p><div xmlns="http://www.w3.org/1999/xhtml" class="sect2"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h3 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2751603"/>The preview</h3></div></div><p xmlns="http://www.w3.org/1999/xhtml">The preview allows you to preview the output of the plug-in.</p><p xmlns="http://www.w3.org/1999/xhtml">
You can scroll the preview by pressing the first mouse-button and dragging in the
preview. During scrolling, the original unprocessed image will be shown, because
the plug-in is not fast enough to compute the processed image. When you
release the mouse-button the plug-in will start computing the processed image.
Immediately below the preview is a progress-bar that shows the plug-in's progress.
</p><p xmlns="http://www.w3.org/1999/xhtml">You can scale (or zoom) the image with the + and
- buttons under the preview.
When you zoom out the plug-in has to render a larger area which takes more time.</p><p xmlns="http://www.w3.org/1999/xhtml">The size of the preview can be changed by dragging the paned widgets below and to the right of the preview.
These widgets are marked with "....".
</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect2"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h3 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2751658"/>The parameters</h3></div></div><p xmlns="http://www.w3.org/1999/xhtml">The plug-in has the following parameters:
<div xmlns="http://www.w3.org/1999/xhtml" class="variablelist"><dl><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term"><i xmlns="http://www.w3.org/1999/xhtml"><tt>Matrix Width</tt></i></span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">This parameter determines the size of the transformation matrix.
Increasing the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Matrix Width</tt></i> may give better results,
especially when you have chosen large values for <i xmlns="http://www.w3.org/1999/xhtml"><tt>Radius</tt></i> or <i xmlns="http://www.w3.org/1999/xhtml"><tt>Gauss</tt></i>.
Note that the plug-in will become very slow when you select large
values for this parameter.
In most cases you should select a value in the range 3-10.
</p></dd><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term"><i xmlns="http://www.w3.org/1999/xhtml"><tt>Radius</tt></i></span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">This is the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Radius</tt></i> of the circular convolution.
This is probably the most important parameter for using the plug-in.
For normal images, the default value of 1 should give good results.
Select a higher value when your image is very blurred.
</p></dd><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term"><i xmlns="http://www.w3.org/1999/xhtml"><tt>Gauss</tt></i></span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">This is the radius for the Gaussian convolution.
Use this parameter when you blurring is Gaussian.
In most cases you should set this parameter to 0, because it causes nasty artifacts.
When you use non-zero values you will probably have to increase the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Correlation</tt></i> and/or <i xmlns="http://www.w3.org/1999/xhtml"><tt>Noise</tt></i> parameters, too.
</p></dd><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term"><i xmlns="http://www.w3.org/1999/xhtml"><tt>Correlation</tt></i></span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Increasing the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Correlation</tt></i> may help reducing artifacts.
The correlation can range from 0-1.
Useful values are 0.5 and values close to 1, e.g. 0.95 and 0.99.
Using a high value for the correlation will reduce the sharpening effect of the plug-in.
</p></dd><dt xmlns="http://www.w3.org/1999/xhtml"><span xmlns="http://www.w3.org/1999/xhtml" class="term"><i xmlns="http://www.w3.org/1999/xhtml"><tt>Noise</tt></i></span></dt><dd xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Increasing the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Noise</tt></i> parameter may help reducing artifacts.
The <i xmlns="http://www.w3.org/1999/xhtml"><tt>Noise</tt></i> can range from 0-1. When the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Noise</tt></i> value is to low, e.g.
0 the image quality will be horrible. A useful value is 0.01.
Using a high value for the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Noise</tt></i> will reduce the sharpening effect of the plug-in.
</p></dd></dl></div>
</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect2"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h3 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2752608"/>Tips and tricks</h3></div></div><p xmlns="http://www.w3.org/1999/xhtml">
This section describes a few hints to help you work with the refocus
plug-in.
</p><div xmlns="http://www.w3.org/1999/xhtml" class="sect3"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h4 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2752622"/>General</h4></div></div><p xmlns="http://www.w3.org/1999/xhtml">Perform all color corrections on the image before using
this plug-in.</p><p xmlns="http://www.w3.org/1999/xhtml">In many cases you should use this plug-in before performing
other operations on the image.
The reason is that many operations on
the image will leave boundaries that are not immediately visible
but that will leave nasty artifacts.</p><p xmlns="http://www.w3.org/1999/xhtml">When you are scanning images and compress them, e.g. to jpg,
you should use the plug-in on the uncompressed image.
</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect3"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h4 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2752653"/>Performance</h4></div></div><p xmlns="http://www.w3.org/1999/xhtml">The performance of the plug-in when you are previewing depends
heavily on the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Matrix Width</tt></i>, the size of the preview and the scale of the
preview.</p><p xmlns="http://www.w3.org/1999/xhtml">The execution time for transforming the image depends quadratically
on the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Matrix Width</tt></i>.
So when you double the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Matrix Width</tt></i>, it takes four times as long to
process the image.
Values in the range of 3-8 usually give good results.</p><p xmlns="http://www.w3.org/1999/xhtml">The plug-in has to transform the entire part of the image
that is shown in the preview. Using a smaller preview and/or a larger
scale will improve the plug-in's performance.</p><p xmlns="http://www.w3.org/1999/xhtml">The time needed for computing the transformation matrix
after you have pressed the Update button depends
dramatically on the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Matrix Width</tt></i>. Using a smaller value for <i xmlns="http://www.w3.org/1999/xhtml"><tt>Matrix Width</tt></i>
will give you much better performance for this part of the computations.
You should also consider using ATLAS (see <a xmlns="http://www.w3.org/1999/xhtml" href="#atlas">Using ATLAS</a>).
</p></div></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect2"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h3 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2752745"/>Technical background</h3></div></div><p xmlns="http://www.w3.org/1999/xhtml">A wide range of image transformations
can be described mathematically as convolutions.
A convolution is a linear transformation where each
destination pixel is the weighted sum of the pixels in
the neighborhood of the original pixel.</p><p xmlns="http://www.w3.org/1999/xhtml">For example, the following matrix describes the convolution
where each pixel is the average of the source pixel and its 8
immediate neighbors:</p><div xmlns="http://www.w3.org/1999/xhtml" class="informaltable"><table xmlns="http://www.w3.org/1999/xhtml" border="0"><colgroup xmlns="http://www.w3.org/1999/xhtml"><col xmlns="http://www.w3.org/1999/xhtml"/><col xmlns="http://www.w3.org/1999/xhtml"/><col xmlns="http://www.w3.org/1999/xhtml"/></colgroup><tbody xmlns="http://www.w3.org/1999/xhtml"><tr xmlns="http://www.w3.org/1999/xhtml"><td>1/9</td><td>1/9</td><td>1/9</td></tr><tr xmlns="http://www.w3.org/1999/xhtml"><td>1/9</td><td>1/9</td><td>1/9</td></tr><tr xmlns="http://www.w3.org/1999/xhtml"><td>1/9</td><td>1/9</td><td>1/9</td></tr></tbody></table></div><p xmlns="http://www.w3.org/1999/xhtml">A wide range of image degradations, e.g. bad focusing and motion blur, can adequately be described with convolutions. </p><p xmlns="http://www.w3.org/1999/xhtml">In this case we are interested in undo-ing the effect of a
convolution. Using Fourier analysis it is possible to show that for
each convolution there exists an inverse convolution. </p><p xmlns="http://www.w3.org/1999/xhtml">
Unfortunately, this inverse convolution is of little practical use.
The reason is that image transformations virtually always introduce
some form of error, e.g. due to noise in the scanner or simply
round-off errors. The unmodified inverse convolution greatly
amplifies these errors. In many cases the result of the
inverse convolution is completely dominated by the noise.
If you want to get a feeling what this means, run the plug-in
with <i xmlns="http://www.w3.org/1999/xhtml"><tt>Gauss</tt></i> = 2 and <i xmlns="http://www.w3.org/1999/xhtml"><tt>Correlation</tt></i> and <i xmlns="http://www.w3.org/1999/xhtml"><tt>Noise</tt></i> = 0.
</p><p xmlns="http://www.w3.org/1999/xhtml">A standard solution is to use Wiener filtering. Wiener filtering
finds an inverse convolution that attempts to minimize noise.
Normally Wiener filtering is implemented with Fourier transforms.
</p><p xmlns="http://www.w3.org/1999/xhtml">Standard Wiener filters have two disadvantages for our purpose:</p><div xmlns="http://www.w3.org/1999/xhtml" class="itemizedlist"><ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">The memory requirements are high.The Fourier transform of the image requires two floating point numbers for each pixel.</p></li><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Wiener filtering is a global transform.
The results for a specific region can be influenced by completely unrelated regions in the image.
During experiments with Wiener filtering I found that this
frequently produces unexpected and undesirable results.
</p></li></ul></div><p xmlns="http://www.w3.org/1999/xhtml">The refocus plug-in is based on a modified form of the Wiener
filter, called the FIR (Finite Input Response) Wiener filter.
A FIR Wiener filter only uses a limited neighborhood of the
source pixels and can be easily implemented as a convolution
matrix.
</p><p xmlns="http://www.w3.org/1999/xhtml">FIR Wiener filtering has the following advantages:</p><div xmlns="http://www.w3.org/1999/xhtml" class="itemizedlist"><ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Low memory requirements. Only the convolution matrix must be
stored.</p></li><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Ease of implementation. There is no need to do a full
Fourier transform.</p></li><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">The transformation is local. The results only
depend on a small neighborhood of the original pixel.</p></li></ul></div><p xmlns="http://www.w3.org/1999/xhtml">For technical background on the FIR Wiener deconvolution see
<a xmlns="http://www.w3.org/1999/xhtml" href="#Jain89">[Jain89]</a>.</p><div xmlns="http://www.w3.org/1999/xhtml" class="sect3"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h4 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2814164"/>Modeling the convolution</h4></div></div><p xmlns="http://www.w3.org/1999/xhtml">In most cases you don't know precisely what convolution
caused the image degradation.
There are two convolutions that are frequently used to
model image degradation:
<div xmlns="http://www.w3.org/1999/xhtml" class="itemizedlist"><ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">The <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><i xmlns="http://www.w3.org/1999/xhtml">Gaussian</i></span> convolution</p></li><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">The <span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><i xmlns="http://www.w3.org/1999/xhtml">Circular</i></span> convolution</p></li></ul></div>
</p><div xmlns="http://www.w3.org/1999/xhtml" class="sect4"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h5 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2814208"/>The Gaussian convolution</h5></div></div><p xmlns="http://www.w3.org/1999/xhtml">
The Gaussian convolution is mathematically similar to the
normal distribution, with its bell-shaped curve.
From a theoretical point of view the mathematical justification
for using the Gaussian convolution is that when you a apply
a large number of independent random convolutions the results
will always approach a Gaussian convolution.
</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect4"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h5 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2814228"/>The circular convolution</h5></div></div><p xmlns="http://www.w3.org/1999/xhtml">The circular convolution spreads each source point
uniformly across a small disk with a fixed radius.
Technically this describes the effects of using
a (ideal) lens that is not correctly focused.
</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect4"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h5 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2814246"/>Convolutions in the plug-in</h5></div></div><p xmlns="http://www.w3.org/1999/xhtml">
The refocus plug-in supports both the Gaussian and the circular
convolution plus mixtures of both.
</p><p xmlns="http://www.w3.org/1999/xhtml">The <i xmlns="http://www.w3.org/1999/xhtml"><tt>Radius</tt></i> parameter determines
the radius of the circular convolution.
The <i xmlns="http://www.w3.org/1999/xhtml"><tt>Gauss</tt></i> parameter determines
the width of Gaussian convolution.</p><p xmlns="http://www.w3.org/1999/xhtml">The actual convolution that is used by the plug-in
is in fact the result of convolving both the Gaussian and
the circular convolution with one another.
Both of these convolutions are identical to the identity
convolution when their parameter is equal to 0.
Therefore, when the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Gauss</tt></i> parameter
equals 0, the result is a circular convolution, and
likewise when the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Radius</tt></i> equals
0 the result is a Gaussian convolution.
</p><p xmlns="http://www.w3.org/1999/xhtml">In practice, I found that in most cases the circular
convolution works much better than the Gaussian convolution.
The Gaussian convolution has a very long tail, so mathematically
the result of the convolution also depends on source pixels
at a large distance from the original source pixel.
The FIR Wiener inverse of a Gaussian convolution in
most cases is heavily influenced by source pixels at a large
distances, and in most cases this produces undesirable results.
</p><p xmlns="http://www.w3.org/1999/xhtml">The circular convolution generally produces much better
results. One reason is that the FIR Wiener inverse of the
circular convolution in general influenced by source pixels
in the immediate neighborhood of the original source pixel.
Another reason is that a circular convolution is theoretically
a good mathematical model for images that are slightly unfocused.
</p></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect4"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h5 class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2814334"/>Comparison with other techniques</h5></div></div><p xmlns="http://www.w3.org/1999/xhtml">Two other techniques that are frequently used to enhance
images are:</p><div xmlns="http://www.w3.org/1999/xhtml" class="itemizedlist"><ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Sharpening</p></li><li xmlns="http://www.w3.org/1999/xhtml"><p xmlns="http://www.w3.org/1999/xhtml">Unsharp mask</p></li></ul></div><p xmlns="http://www.w3.org/1999/xhtml">Sharpening applies a small convolution matrix that
increases the difference between a source pixel and its
immediate neighbors. FIR Wiener filtering is a more
general technique because it allows a much larger neighborhood
and better parameterizations.
Sharpening only works when your images are very slightly
blurred.
Furthermore, for high values of the sharpening parameter
the results frequently look "noisy".
With FIR Wiener filtering this noise can be greatly reduced
by selecting higher values for the <i xmlns="http://www.w3.org/1999/xhtml"><tt>Correlation</tt></i>
and <i xmlns="http://www.w3.org/1999/xhtml"><tt>Noise</tt></i> parameters.
</p><p xmlns="http://www.w3.org/1999/xhtml">Unsharp masking is another very popular image enhancement technique.
From a mathematical point of view its justification is a bit
obscure but many people are very fond of it.
The first step is to blur the source image, hence the name
<span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><i xmlns="http://www.w3.org/1999/xhtml">unsharp</i></span> masking. Then the difference
between the source image and the blurred image is subtracted
from the source image.
</p><p xmlns="http://www.w3.org/1999/xhtml">In general, unsharp masking produces better results
than sharpening.
This is probably caused by the fact that unsharp masking
uses a larger neighborhood than sharpening.
</p><p xmlns="http://www.w3.org/1999/xhtml">From a theoretical point of view unsharp masking
must always introduce artifacts. Even under optimal
circumstances it can never completely undo the effect of
blurring. For Wiener filtering it is possible to prove
that it is the optimal linear filter.</p><p xmlns="http://www.w3.org/1999/xhtml">In practice I found that in virtually all cases
the results of the FIR Wiener filter were at least
as good as those of unsharp masking. The FIR Wiener filter
is frequently better in restoring small details.
</p><p xmlns="http://www.w3.org/1999/xhtml">As a side note, unsharp masking generally uses
a Gaussian convolution, I suspect that in some cases
a circular convolution should give better results.</p></div></div></div><div xmlns="http://www.w3.org/1999/xhtml" id="id2814452" class="bibliography"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a xmlns="http://www.w3.org/1999/xhtml" id="id2814452"/>Bibliography</h2></div></div><div xmlns="http://www.w3.org/1999/xhtml" class="biblioentry"><a xmlns="http://www.w3.org/1999/xhtml" id="Jain89"/><p>[Jain89] <span xmlns="http://www.w3.org/1999/xhtml" class="title"><i>Fundamentals of Digital Image Processing</i>. </span><span xmlns="http://www.w3.org/1999/xhtml" class="author">Anil K. Jain. </span><span xmlns="http://www.w3.org/1999/xhtml" class="publisher"><span xmlns="http://www.w3.org/1999/xhtml" class="publishername">Prentice Hall. </span></span><span xmlns="http://www.w3.org/1999/xhtml" class="pubdate">1989. </span></p></div></div></div><div xmlns="http://www.w3.org/1999/xhtml" class="sect1"><div xmlns="http://www.w3.org/1999/xhtml" class="titlepage"><div xmlns="http://www.w3.org/1999/xhtml"><h2 class="title" style="clear: both"><a xmlns="http://www.w3.org/1999/xhtml" id="id2813911"/>Acknowledgements</h2></div></div><p xmlns="http://www.w3.org/1999/xhtml">The Gimp developers, Shawn T. Amundson for the GimpPreview widget,
Lauri Alanko for the Convolution Matrix plug-in, ATLAS, CLAPACK.</p></div></div></body></html>
|