blob: c33c0b8f3d658378414ff10dee075c9649d62a3a [file] [log] [blame]
cristydcca3fa2010-12-29 21:50:07 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
cristy3eaa0ef2010-03-06 20:35:26 +00004<head>
cristy3c98a4f2010-08-13 20:09:41 +00005 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
6 <meta name="verify-v1" content="g222frIIxcQTrvDR3NBRUSKP3AnMNoqxOkIniCEkV7U="/>
cristyffb69ed2010-12-25 00:06:48 +00007 <title>ImageMagick: MagickCore, C API for ImageMagick: Morphological Erosions, Dilations, Openings, and Closings</title>
cristyd2baf7d2010-03-06 04:26:44 +00008 <meta http-equiv="Content-Language" content="en-US"/>
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
10 <meta http-equiv="Reply-to" content="magick-users@imagemagick.org"/>
cristy3c98a4f2010-08-13 20:09:41 +000011 <meta name="Application-name" content="ImageMagick"/>
cristydcca3fa2010-12-29 21:50:07 +000012 <meta name="Description" content="ImageMagick is a software suite to create, edit, compose, or convert bitmap images in a variety of formats. Use ImageMagick to scale, rotate, shear, distort and transform images."/>
cristy3c98a4f2010-08-13 20:09:41 +000013 <meta name="Application-url" content="http://www.imagemagick.org"/>
cristyd2baf7d2010-03-06 04:26:44 +000014 <meta name="Generator" content="PHP"/>
15 <meta name="Keywords" content="magickcore, c, api, for, imagemagick:, morphological, erosions, dilations, openings, closings, ImageMagick, ImageMagic, MagickCore, MagickWand, PerlMagick, Magick++, RMagick, PythonMagick, JMagick, TclMagick, Image, Magick, Magic, Wand, ImageMagickObject, Swiss, Army, Knife, Image, Processing"/>
cristyd2baf7d2010-03-06 04:26:44 +000016 <meta name="Rating" content="GENERAL"/>
17 <meta name="Robots" content="INDEX, FOLLOW"/>
18 <meta name="Generator" content="ImageMagick Studio LLC"/>
19 <meta name="Author" content="ImageMagick Studio LLC"/>
20 <meta name="Revisit-after" content="2 DAYS"/>
21 <meta name="Resource-type" content="document"/>
cristy4103d562010-12-10 01:38:54 +000022 <meta name="Copyright" content="Copyright (c) 1999-2011 ImageMagick Studio LLC"/>
cristyd2baf7d2010-03-06 04:26:44 +000023 <meta name="Distribution" content="Global"/>
cristydcca3fa2010-12-29 21:50:07 +000024 <link rel="icon" href="../../images/wand.png"/>
cristy3c98a4f2010-08-13 20:09:41 +000025 <link rel="shortcut icon" href="../../images/wand.ico" type="images/x-icon"/>
26 <link rel="meta" type="application/rdf+xml" title="ICI" href="http://imagemagick.org/ici.rdf"/>
cristy7a40ba82011-01-08 20:31:18 +000027 <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
cristy3c98a4f2010-08-13 20:09:41 +000028 <style type="text/css" media="all">
29 @import url("../../www/magick.css");
30 </style>
cristydcca3fa2010-12-29 21:50:07 +000031 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
cristy361f4662010-12-31 23:02:52 +000032 <script type="text/javascript" src="../fancybox/jquery.fancybox-1.3.4.pack.js"></script>
33 <link rel="stylesheet" type="text/css" href="../fancybox/jquery.fancybox-1.3.4.css" media="screen" />
34 <script type="text/javascript">
35 $(document).ready(function() {
36 $("a[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox({
37 'transitionIn' : 'elastic',
38 'transitionOut' : 'elastic',
39 'overlayShow' : false,
40 'opacity' : true
41 });
42 });
43 </script>
cristy3eaa0ef2010-03-06 20:35:26 +000044</head>
45
46<body id="www-imagemagick-org">
47<div class="titlebar">
48<a href="../../index.html">
49 <img src="../../images/script.png" alt="[ImageMagick]"
50 style="width: 350px; height: 60px; margin: 28px auto; float: left;" /></a>
51<a href="http://www.networkredux.com">
52 <img src="../../images/networkredux.png" alt="[sponsor]"
53 style="margin: 45px auto; border: 0px; float: left;" /></a>
54<a href="http://www.imagemagick.org/discourse-server/">
55 <img src="../../images/logo.jpg" alt=""
56 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
57<a href="../../index.html">
58 <img src="../../images/sprite.jpg" alt=""
59 style="width: 114px; height: 118px; border: 0px; float: right;" /></a>
60</div>
61
cristyce69bb02010-07-27 19:49:46 +000062<div class="westbar">
cristy3eaa0ef2010-03-06 20:35:26 +000063
cristyd2baf7d2010-03-06 04:26:44 +000064<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000065 <a title="About ImageMagick" href="../../index.html">About ImageMagick</a>
cristyd2baf7d2010-03-06 04:26:44 +000066</div>
cristy3eaa0ef2010-03-06 20:35:26 +000067<div class="sep"></div>
cristyd2baf7d2010-03-06 04:26:44 +000068<div class="menu">
cristybb503372010-05-27 20:51:26 +000069 <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
70</div>
71<div class="sub">
72 <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
73</div>
74<div class="sub">
75 <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
76</div>
77<div class="sub">
78 <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
79</div>
80<div class="sep"></div>
81<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000082 <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
cristyd2baf7d2010-03-06 04:26:44 +000083</div>
84<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000085 <a title="Command-line Tools: Processing" href="../../www/command-line-processing.html">Processing</a>
cristyd2baf7d2010-03-06 04:26:44 +000086</div>
87<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000088 <a title="Command-line Tools: Options" href="../../www/command-line-options.html">Options</a>
cristyd2baf7d2010-03-06 04:26:44 +000089</div>
90<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000091 <a title="Command-line Tools: Usage" href="http://www.imagemagick.org/Usage/">Usage</a>
cristyd2baf7d2010-03-06 04:26:44 +000092</div>
93<div class="menu">
cristy83a272e2010-05-07 20:40:35 +000094 <a title="Program Interfaces" href="../../www/api.html">Program Interfaces</a>
cristyd2baf7d2010-03-06 04:26:44 +000095</div>
96<div class="sub">
cristy83a272e2010-05-07 20:40:35 +000097 <a title="Program Interface: MagickWand" href="../../www/magick-wand.html">MagickWand</a>
cristyd2baf7d2010-03-06 04:26:44 +000098</div>
99<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000100 <a title="Program Interface: MagickCore" href="../../www/magick-core.html">MagickCore</a>
cristyd2baf7d2010-03-06 04:26:44 +0000101</div>
102<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000103 <a title="Program Interface: PerlMagick" href="../../www/perl-magick.html">PerlMagick</a>
cristyd2baf7d2010-03-06 04:26:44 +0000104</div>
105<div class="sub">
cristydcca3fa2010-12-29 21:50:07 +0000106 <a title="Program Interface: Magick++" href="../../www/magick++.html">Magick++</a>
cristyd2baf7d2010-03-06 04:26:44 +0000107</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000108<div class="sep"></div>
cristyd2baf7d2010-03-06 04:26:44 +0000109<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000110 <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
cristyd2baf7d2010-03-06 04:26:44 +0000111</div>
112<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000113 <a title="Install from Source: Unix" href="../../www/install-source.html#unix">Unix</a>
cristyd2baf7d2010-03-06 04:26:44 +0000114</div>
115<div class="sub">
cristy83a272e2010-05-07 20:40:35 +0000116 <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
cristyd2baf7d2010-03-06 04:26:44 +0000117 </div>
118<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000119 <a title="Resources" href="../../www/resources.html">Resources</a>
cristyd2baf7d2010-03-06 04:26:44 +0000120</div>
cristybb503372010-05-27 20:51:26 +0000121<div class="menu">
122 <a title="Architecture" href="../../www/architecture.html">Architecture</a>
123</div>
cristyd2baf7d2010-03-06 04:26:44 +0000124<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000125 <a title="Download" href="../../www/download.html">Download</a>
cristyd2baf7d2010-03-06 04:26:44 +0000126</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000127<div class="sep"></div>
cristyd2baf7d2010-03-06 04:26:44 +0000128<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000129 <a title="Search" href="../http://www.imagemagick.org/script/search.php">Search</a>
cristyd2baf7d2010-03-06 04:26:44 +0000130</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000131<div class="sep"></div>
cristyd2baf7d2010-03-06 04:26:44 +0000132<div class="menu">
cristyffb69ed2010-12-25 00:06:48 +0000133 <a title="Site Map" href="../../www/sitemap.html">Site Map</a>
cristyd2baf7d2010-03-06 04:26:44 +0000134</div>
135<div class="sub">
cristyffb69ed2010-12-25 00:06:48 +0000136 <a title="Site Map: Links" href="../../www/links.html">Links</a>
cristyd2baf7d2010-03-06 04:26:44 +0000137</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000138<div class="sep"></div>
cristyd2baf7d2010-03-06 04:26:44 +0000139<div class="menu">
cristy83a272e2010-05-07 20:40:35 +0000140 <a title="Sponsors" href="../../www/sponsors.html">Sponsors:</a>
cristyd2baf7d2010-03-06 04:26:44 +0000141
142<div class="sponsbox">
cristyec6b4752011-01-08 03:16:23 +0000143<div class="sponsor">
144 <a title="Sponsor: Web Hosting" href="http://www.bodhost.com/hosting.html">Web Hosting</a><!-- 201104010090 -->
cristy73fd1cd2010-09-12 19:14:25 +0000145</div>
146<div class="sponsor">
cristy7d52cd62010-10-01 17:26:59 +0000147 <a title="Sponsor: Druckerei" href="http://print24.com/de/">Druckerei</a><!-- 201110010720 -->
148</div>
149<div class="sponsor">
cristyc5baf4f2010-08-31 15:05:33 +0000150 <a title="Sponsor: Image Converter" href="http://www.batchphoto.com">Image Converter</a><!-- 201103010900 Bits Coffee-->
151</div>
152<div class="sponsor">
cristy851dbce2010-08-06 21:40:00 +0000153 <a title="Sponsor: Flyer drucken" href="http://www.online-druck.biz">Flyer drucken</a><!-- 201109010900 Floeter-->
154</div>
cristyec6b4752011-01-08 03:16:23 +0000155<div class="sponsor">
cristy7a40ba82011-01-08 20:31:18 +0000156 <a title="Sponsor: Webdesign" href="http://www.renehornig.com/">Webdesign</a><!-- 20111001000240 -->
cristyec6b4752011-01-08 03:16:23 +0000157</div>
cristyd2baf7d2010-03-06 04:26:44 +0000158</div>
159</div>
cristyce69bb02010-07-27 19:49:46 +0000160</div>
cristy3eaa0ef2010-03-06 20:35:26 +0000161
cristyce69bb02010-07-27 19:49:46 +0000162<div class="eastbar">
163 <script type="text/javascript">
164 <!--
165 google_ad_client = "pub-3129977114552745";
cristyce69bb02010-07-27 19:49:46 +0000166 google_ad_slot = "0574824969";
167 google_ad_width = 160;
168 google_ad_height = 600;
169 //-->
170 </script>
171 <script type="text/javascript"
172 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
173 </script>
cristy3eaa0ef2010-03-06 20:35:26 +0000174</div>
175
176<div class="main">
177
cristy307ba182010-12-25 01:00:34 +0000178<h1>Module morphology
179 Methods</h1>
cristya7cb4312010-06-26 00:47:03 +0000180<p class="navigation-index">[<a href="#** This macro IsNaN">** This macro IsNaN</a> &bull; <a href="#AcquireKernelInfo">AcquireKernelInfo</a> &bull; <a href="#AcquireKernelBuiltIn">AcquireKernelBuiltIn</a> &bull; <a href="#CloneKernelInfo">CloneKernelInfo</a> &bull; <a href="#DestroyKernelInfo">DestroyKernelInfo</a> &bull; <a href="#MorphologyApply">MorphologyApply</a> &bull; <a href="#MorphologyImageChannel">MorphologyImageChannel</a> &bull; <a href="#ScaleGeometryKernelInfo">ScaleGeometryKernelInfo</a> &bull; <a href="#ScaleKernelInfo">ScaleKernelInfo</a> &bull; <a href="#ShowKernelInfo">ShowKernelInfo</a> &bull; <a href="#UnityAddKernelInfo">UnityAddKernelInfo</a> &bull; <a href="#ZeroKernelNans">ZeroKernelNans</a>]</p>
cristyd2baf7d2010-03-06 04:26:44 +0000181
cristy7a40ba82011-01-08 20:31:18 +0000182<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
183_8c.html" id="**_This macro IsNaN">** This macro IsNaN</a></h2>
cristyd2baf7d2010-03-06 04:26:44 +0000184<div class="doc-section">
185
cristybb503372010-05-27 20:51:26 +0000186<p>** This macro IsNaN() is thus is only true if the value given is NaN. </p>
cristyd2baf7d2010-03-06 04:26:44 +0000187 </div>
cristy7a40ba82011-01-08 20:31:18 +0000188<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
189_8c.html" id="AcquireKernelInfo">AcquireKernelInfo</a></h2>
cristyd2baf7d2010-03-06 04:26:44 +0000190<div class="doc-section">
191
cristy7a40ba82011-01-08 20:31:18 +0000192<p>AcquireKernelInfo() takes the given string (generally supplied by the user) and converts it into a Morphology/Convolution Kernel. This allows users to specify a kernel from a number of pre-defined kernels, or to fully specify their own kernel for a specific Convolution or Morphology Operation.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000193
cristy7a40ba82011-01-08 20:31:18 +0000194<p>The kernel so generated can be any rectangular array of floating point values (doubles) with the 'control point' or 'pixel being affected' anywhere within that array of values.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000195
cristy7a40ba82011-01-08 20:31:18 +0000196<p>Previously IM was restricted to a square of odd size using the exact center as origin, this is no longer the case, and any rectangular kernel with any value being declared the origin. This in turn allows the use of highly asymmetrical kernels.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000197
cristy7a40ba82011-01-08 20:31:18 +0000198<p>The floating point values in the kernel can also include a special value known as 'nan' or 'not a number' to indicate that this value is not part of the kernel array. This allows you to shaped the kernel within its rectangular area. That is 'nan' values provide a 'mask' for the kernel shape. However at least one non-nan value must be provided for correct working of a kernel.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000199
cristy7a40ba82011-01-08 20:31:18 +0000200<p>The returned kernel should be freed using the DestroyKernelInfo() when you are finished with it. Do not free this memory yourself.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000201
cristy7a40ba82011-01-08 20:31:18 +0000202<p>Input kernel defintion strings can consist of any of three types.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000203
cristy7a40ba82011-01-08 20:31:18 +0000204<p>"name:args[[@><]" Select from one of the built in kernels, using the name and geometry arguments supplied. See AcquireKernelBuiltIn()</p>
cristyd2baf7d2010-03-06 04:26:44 +0000205
cristy7a40ba82011-01-08 20:31:18 +0000206<p>"WxH[+X+Y][@><]:num, num, num ..." a kernel of size W by H, with W*H floating point numbers following. the 'center' can be optionally be defined at +X+Y (such that +0+0 is top left corner). If not defined the pixel in the center, for odd sizes, or to the immediate top or left of center for even sizes is automatically selected.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000207
cristy7a40ba82011-01-08 20:31:18 +0000208<p>"num, num, num, num, ..." list of floating point numbers defining an 'old style' odd sized square kernel. At least 9 values should be provided for a 3x3 square kernel, 25 for a 5x5 square kernel, 49 for 7x7, etc. Values can be space or comma separated. This is not recommended.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000209
cristy7a40ba82011-01-08 20:31:18 +0000210<p>You can define a 'list of kernels' which can be used by some morphology operators A list is defined as a semi-colon seperated list kernels.</p>
cristyf0d1f5d2010-05-13 16:29:38 +0000211
cristy7a40ba82011-01-08 20:31:18 +0000212<p>" kernel ; kernel ; kernel ; "</p>
cristyf0d1f5d2010-05-13 16:29:38 +0000213
cristy7a40ba82011-01-08 20:31:18 +0000214<p>Any extra ';' characters, at start, end or between kernel defintions are simply ignored.</p>
cristyc4960862010-05-23 22:24:24 +0000215
cristy7a40ba82011-01-08 20:31:18 +0000216<p>The special flags will expand a single kernel, into a list of rotated kernels. A '@' flag will expand a 3x3 kernel into a list of 45-degree cyclic rotations, while a '>' will generate a list of 90-degree rotations. The '<' also exands using 90-degree rotates, but giving a 180-degree reflected kernel before the +/- 90-degree rotations, which can be important for Thinning operations.</p>
cristyc3186d52010-06-04 13:55:23 +0000217
cristy7a40ba82011-01-08 20:31:18 +0000218<p>Note that 'name' kernels will start with an alphabetic character while the new kernel specification has a ':' character in its specification string. If neither is the case, it is assumed an old style of a simple list of numbers generating a odd-sized square kernel has been given.</p>
cristyf0d1f5d2010-05-13 16:29:38 +0000219
cristyd2baf7d2010-03-06 04:26:44 +0000220<p>The format of the AcquireKernal method is:</p>
221
222<pre class="code">
223 KernelInfo *AcquireKernelInfo(const char *kernel_string)
224</pre>
225
cristy7a40ba82011-01-08 20:31:18 +0000226<p>A description of each parameter follows:</p>
cristyd2baf7d2010-03-06 04:26:44 +0000227
228<h5>kernel_string</h5>
cristy7a40ba82011-01-08 20:31:18 +0000229<p>the Morphology/Convolution kernel wanted.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000230
231 </div>
cristy7a40ba82011-01-08 20:31:18 +0000232<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
233_8c.html" id="AcquireKernelBuiltIn">AcquireKernelBuiltIn</a></h2>
cristyd2baf7d2010-03-06 04:26:44 +0000234<div class="doc-section">
235
cristy7a40ba82011-01-08 20:31:18 +0000236<p>AcquireKernelBuiltIn() returned one of the 'named' built-in types of kernels used for special purposes such as gaussian blurring, skeleton pruning, and edge distance determination.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000237
cristy7a40ba82011-01-08 20:31:18 +0000238<p>They take a KernelType, and a set of geometry style arguments, which were typically decoded from a user supplied string, or from a more complex Morphology Method that was requested.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000239
240<p>The format of the AcquireKernalBuiltIn method is:</p>
241
242<pre class="code">
243 KernelInfo *AcquireKernelBuiltIn(const KernelInfoType type,
244 const GeometryInfo args)
245</pre>
246
cristy7a40ba82011-01-08 20:31:18 +0000247<p>A description of each parameter follows:</p>
cristyd2baf7d2010-03-06 04:26:44 +0000248
249<h5>type</h5>
cristy7a40ba82011-01-08 20:31:18 +0000250<p>the pre-defined type of kernel wanted</p>
cristyd2baf7d2010-03-06 04:26:44 +0000251
252<h5>args</h5>
cristy7a40ba82011-01-08 20:31:18 +0000253<p>arguments defining or modifying the kernel</p>
cristyd2baf7d2010-03-06 04:26:44 +0000254
cristy7a40ba82011-01-08 20:31:18 +0000255<p>Convolution Kernels</p>
cristyd2baf7d2010-03-06 04:26:44 +0000256
cristy7a40ba82011-01-08 20:31:18 +0000257<p>Unity the No-Op kernel, also requivelent to Gaussian of sigma zero. Basically a 3x3 kernel of a 1 surrounded by zeros.</p>
cristyc4960862010-05-23 22:24:24 +0000258
cristy7a40ba82011-01-08 20:31:18 +0000259<p>Gaussian:{radius},{sigma} Generate a two-dimentional gaussian kernel, as used by -gaussian. The sigma for the curve is required. The resulting kernel is normalized,</p>
cristyf1310b52010-05-15 16:42:04 +0000260
cristy7a40ba82011-01-08 20:31:18 +0000261<p>If 'sigma' is zero, you get a single pixel on a field of zeros.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000262
cristy7a40ba82011-01-08 20:31:18 +0000263<p>NOTE: that the 'radius' is optional, but if provided can limit (clip) the final size of the resulting kernel to a square 2*radius+1 in size. The radius should be at least 2 times that of the sigma value, or sever clipping and aliasing may result. If not given or set to 0 the radius will be determined so as to produce the best minimal error result, which is usally much larger than is normally needed.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000264
cristy7a40ba82011-01-08 20:31:18 +0000265<p>LoG:{radius},{sigma} "Laplacian of a Gaussian" or "Mexician Hat" Kernel. The supposed ideal edge detection, zero-summing kernel.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000266
cristy7a40ba82011-01-08 20:31:18 +0000267<p>An alturnative to this kernel is to use a "DoG" with a sigma ratio of approx 1.6 (according to wikipedia).</p>
cristyc4960862010-05-23 22:24:24 +0000268
cristy7a40ba82011-01-08 20:31:18 +0000269<p>DoG:{radius},{sigma1},{sigma2} "Difference of Gaussians" Kernel. As "Gaussian" but with a gaussian produced by 'sigma2' subtracted from the gaussian produced by 'sigma1'. Typically sigma2 > sigma1. The result is a zero-summing kernel.</p>
cristyc4960862010-05-23 22:24:24 +0000270
cristy7a40ba82011-01-08 20:31:18 +0000271<p>Blur:{radius},{sigma}[,{angle}] Generates a 1 dimensional or linear gaussian blur, at the angle given (current restricted to orthogonal angles). If a 'radius' is given the kernel is clipped to a width of 2*radius+1. Kernel can be rotated by a 90 degree angle.</p>
cristyf1310b52010-05-15 16:42:04 +0000272
cristy7a40ba82011-01-08 20:31:18 +0000273<p>If 'sigma' is zero, you get a single pixel on a field of zeros.</p>
cristyf1310b52010-05-15 16:42:04 +0000274
cristy7a40ba82011-01-08 20:31:18 +0000275<p>Note that two convolutions with two "Blur" kernels perpendicular to each other, is equivelent to a far larger "Gaussian" kernel with the same sigma value, However it is much faster to apply. This is how the "-blur" operator actually works.</p>
cristyf1310b52010-05-15 16:42:04 +0000276
cristy7a40ba82011-01-08 20:31:18 +0000277<p>Comet:{width},{sigma},{angle} Blur in one direction only, much like how a bright object leaves a comet like trail. The Kernel is actually half a gaussian curve, Adding two such blurs in opposite directions produces a Blur Kernel. Angle can be rotated in multiples of 90 degrees.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000278
cristy7a40ba82011-01-08 20:31:18 +0000279<p>Note that the first argument is the width of the kernel and not the radius of the kernel.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000280
cristy7a40ba82011-01-08 20:31:18 +0000281<p># Still to be implemented... # # Filter2D # Filter1D # Set kernel values using a resize filter, and given scale (sigma) # Cylindrical or Linear. Is this posible with an image? #</p>
cristyf0d1f5d2010-05-13 16:29:38 +0000282
cristy7a40ba82011-01-08 20:31:18 +0000283<p>Named Constant Convolution Kernels</p>
cristyf0d1f5d2010-05-13 16:29:38 +0000284
cristy7a40ba82011-01-08 20:31:18 +0000285<p>All these are unscaled, zero-summing kernels by default. As such for non-HDRI version of ImageMagick some form of normalization, user scaling, and biasing the results is recommended, to prevent the resulting image being 'clipped'.</p>
cristyf0d1f5d2010-05-13 16:29:38 +0000286
cristy7a40ba82011-01-08 20:31:18 +0000287<p>The 3x3 kernels (most of these) can be circularly rotated in multiples of 45 degrees to generate the 8 angled varients of each of the kernels.</p>
cristyf1310b52010-05-15 16:42:04 +0000288
cristy7a40ba82011-01-08 20:31:18 +0000289<p>Laplacian:{type} Discrete Lapacian Kernels, (without normalization) Type 0 : 3x3 with center:8 surounded by -1 (8 neighbourhood) Type 1 : 3x3 with center:4 edge:-1 corner:0 (4 neighbourhood) Type 2 : 3x3 with center:4 edge:1 corner:-2 Type 3 : 3x3 with center:4 edge:-2 corner:1 Type 5 : 5x5 laplacian Type 7 : 7x7 laplacian Type 15 : 5x5 LoG (sigma approx 1.4) Type 19 : 9x9 LoG (sigma approx 1.4)</p>
cristyf1310b52010-05-15 16:42:04 +0000290
cristy7a40ba82011-01-08 20:31:18 +0000291<p>Sobel:{angle} Sobel 'Edge' convolution kernel (3x3) | -1, 0, 1 | | -2, 0,-2 | | -1, 0, 1 |</p>
cristyc4960862010-05-23 22:24:24 +0000292
cristy7a40ba82011-01-08 20:31:18 +0000293<p>Sobel:{type},{angle} Type 0: default un-nomalized version shown above.</p>
cristyc4960862010-05-23 22:24:24 +0000294
cristy7a40ba82011-01-08 20:31:18 +0000295<p>Type 1: As default but pre-normalized | 1, 0, -1 | | 2, 0, -2 | / 4 | 1, 0, -1 |</p>
cristybb503372010-05-27 20:51:26 +0000296
cristy7a40ba82011-01-08 20:31:18 +0000297<p>Type 2: Diagonal version with same normalization as 1 | 1, 0, -1 | | 2, 0, -2 | / 4 | 1, 0, -1 |</p>
cristyfe0019b2010-06-07 02:23:32 +0000298
cristy7a40ba82011-01-08 20:31:18 +0000299<p>Roberts:{angle} Roberts convolution kernel (3x3) | 0, 0, 0 | | -1, 1, 0 | | 0, 0, 0 |</p>
cristyfe0019b2010-06-07 02:23:32 +0000300
cristy7a40ba82011-01-08 20:31:18 +0000301<p>Prewitt:{angle} Prewitt Edge convolution kernel (3x3) | -1, 0, 1 | | -1, 0, 1 | | -1, 0, 1 |</p>
cristyfe0019b2010-06-07 02:23:32 +0000302
cristy7a40ba82011-01-08 20:31:18 +0000303<p>Compass:{angle} Prewitt's "Compass" convolution kernel (3x3) | -1, 1, 1 | | -1,-2, 1 | | -1, 1, 1 |</p>
cristyfe0019b2010-06-07 02:23:32 +0000304
cristy7a40ba82011-01-08 20:31:18 +0000305<p>Kirsch:{angle} Kirsch's "Compass" convolution kernel (3x3) | -3,-3, 5 | | -3, 0, 5 | | -3,-3, 5 |</p>
cristyfe0019b2010-06-07 02:23:32 +0000306
cristy7a40ba82011-01-08 20:31:18 +0000307<p>FreiChen:{angle} Frei-Chen Edge Detector is based on a kernel that is similar to the Sobel Kernel, but is designed to be isotropic. That is it takes into account the distance of the diagonal in the kernel.</p>
cristyfe0019b2010-06-07 02:23:32 +0000308
cristy7a40ba82011-01-08 20:31:18 +0000309<p>| 1, 0, -1 | | sqrt(2), 0, -sqrt(2) | | 1, 0, -1 |</p>
cristyfe0019b2010-06-07 02:23:32 +0000310
cristy7a40ba82011-01-08 20:31:18 +0000311<p>FreiChen:{type},{angle}</p>
cristyfe0019b2010-06-07 02:23:32 +0000312
cristy7a40ba82011-01-08 20:31:18 +0000313<p>Frei-Chen Pre-weighted kernels...</p>
cristyfe0019b2010-06-07 02:23:32 +0000314
cristy7a40ba82011-01-08 20:31:18 +0000315<p>Type 0: default un-nomalized version shown above.</p>
cristyfe0019b2010-06-07 02:23:32 +0000316
cristy7a40ba82011-01-08 20:31:18 +0000317<p>Type 1: Orthogonal Kernel (same as type 11 below) | 1, 0, -1 | | sqrt(2), 0, -sqrt(2) | / 2*sqrt(2) | 1, 0, -1 |</p>
cristyfe0019b2010-06-07 02:23:32 +0000318
cristy7a40ba82011-01-08 20:31:18 +0000319<p>Type 2: Diagonal form of Kernel... | 1, sqrt(2), 0 | | sqrt(2), 0, -sqrt(2) | / 2*sqrt(2) | 0, -sqrt(2) -1 |</p>
cristybb503372010-05-27 20:51:26 +0000320
cristy7a40ba82011-01-08 20:31:18 +0000321<p>However this kernel is als at the heart of the FreiChen Edge Detection Process which uses a set of 9 specially weighted kernel. These 9 kernels not be normalized, but directly applied to the image. The results is then added together, to produce the intensity of an edge in a specific direction. The square root of the pixel value can then be taken as the cosine of the edge, and at least 2 such runs at 90 degrees from each other, both the direction and the strength of the edge can be determined.</p>
cristybb503372010-05-27 20:51:26 +0000322
cristy7a40ba82011-01-08 20:31:18 +0000323<p>Type 10: All 9 of the following pre-weighted kernels...</p>
cristyc4960862010-05-23 22:24:24 +0000324
cristy7a40ba82011-01-08 20:31:18 +0000325<p>Type 11: | 1, 0, -1 | | sqrt(2), 0, -sqrt(2) | / 2*sqrt(2) | 1, 0, -1 |</p>
cristyc4960862010-05-23 22:24:24 +0000326
cristy7a40ba82011-01-08 20:31:18 +0000327<p>Type 12: | 1, sqrt(2), 1 | | 0, 0, 0 | / 2*sqrt(2) | 1, sqrt(2), 1 |</p>
cristyc4960862010-05-23 22:24:24 +0000328
cristy7a40ba82011-01-08 20:31:18 +0000329<p>Type 13: | sqrt(2), -1, 0 | | -1, 0, 1 | / 2*sqrt(2) | 0, 1, -sqrt(2) |</p>
cristyc4960862010-05-23 22:24:24 +0000330
cristy7a40ba82011-01-08 20:31:18 +0000331<p>Type 14: | 0, 1, -sqrt(2) | | -1, 0, 1 | / 2*sqrt(2) | sqrt(2), -1, 0 |</p>
cristyc4960862010-05-23 22:24:24 +0000332
cristy7a40ba82011-01-08 20:31:18 +0000333<p>Type 15: | 0, -1, 0 | | 1, 0, 1 | / 2 | 0, -1, 0 |</p>
cristyc4960862010-05-23 22:24:24 +0000334
cristy7a40ba82011-01-08 20:31:18 +0000335<p>Type 16: | 1, 0, -1 | | 0, 0, 0 | / 2 | -1, 0, 1 |</p>
cristyc4960862010-05-23 22:24:24 +0000336
cristy7a40ba82011-01-08 20:31:18 +0000337<p>Type 17: | 1, -2, 1 | | -2, 4, -2 | / 6 | -1, -2, 1 |</p>
cristyc4960862010-05-23 22:24:24 +0000338
cristy7a40ba82011-01-08 20:31:18 +0000339<p>Type 18: | -2, 1, -2 | | 1, 4, 1 | / 6 | -2, 1, -2 |</p>
cristyfe0019b2010-06-07 02:23:32 +0000340
cristy7a40ba82011-01-08 20:31:18 +0000341<p>Type 19: | 1, 1, 1 | | 1, 1, 1 | / 3 | 1, 1, 1 |</p>
cristyc4960862010-05-23 22:24:24 +0000342
cristy7a40ba82011-01-08 20:31:18 +0000343<p>The first 4 are for edge detection, the next 4 are for line detection and the last is to add a average component to the results.</p>
cristyc4960862010-05-23 22:24:24 +0000344
cristy7a40ba82011-01-08 20:31:18 +0000345<p>Using a special type of '-1' will return all 9 pre-weighted kernels as a multi-kernel list, so that you can use them directly (without normalization) with the special "-set option:morphology:compose Plus" setting to apply the full FreiChen Edge Detection Technique.</p>
cristybb503372010-05-27 20:51:26 +0000346
cristy7a40ba82011-01-08 20:31:18 +0000347<p>If 'type' is large it will be taken to be an actual rotation angle for the default FreiChen (type 0) kernel. As such FreiChen:45 will look like a Sobel:45 but with 'sqrt(2)' instead of '2' values.</p>
cristybb503372010-05-27 20:51:26 +0000348
cristy7a40ba82011-01-08 20:31:18 +0000349<p>WARNING: The above was layed out as per http://www.math.tau.ac.il/~turkel/notes/edge_detectors.pdf But rotated 90 degrees so direction is from left rather than the top. I have yet to find any secondary confirmation of the above. The only other source found was actual source code at http://ltswww.epfl.ch/~courstiv/exos_labos/sol3.pdf Neigher paper defineds the kernels in a way that looks locical or correct when taken as a whole.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000350
cristy7a40ba82011-01-08 20:31:18 +0000351<p>Boolean Kernels</p>
cristyd2baf7d2010-03-06 04:26:44 +0000352
cristy7a40ba82011-01-08 20:31:18 +0000353<p>Diamond:[{radius}[,{scale}]] Generate a diamond shaped kernel with given radius to the points. Kernel size will again be radius*2+1 square and defaults to radius 1, generating a 3x3 kernel that is slightly larger than a square.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000354
cristy7a40ba82011-01-08 20:31:18 +0000355<p>Square:[{radius}[,{scale}]] Generate a square shaped kernel of size radius*2+1, and defaulting to a 3x3 (radius 1).</p>
cristyd2baf7d2010-03-06 04:26:44 +0000356
cristy7a40ba82011-01-08 20:31:18 +0000357<p>Note that using a larger radius for the "Square" or the "Diamond" is also equivelent to iterating the basic morphological method that many times. However iterating with the smaller radius is actually faster than using a larger kernel radius.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000358
cristy7a40ba82011-01-08 20:31:18 +0000359<p>Rectangle:{geometry} Simply generate a rectangle of 1's with the size given. You can also specify the location of the 'control point', otherwise the closest pixel to the center of the rectangle is selected.</p>
cristyf1310b52010-05-15 16:42:04 +0000360
cristy7a40ba82011-01-08 20:31:18 +0000361<p>Properly centered and odd sized rectangles work the best.</p>
cristyf1310b52010-05-15 16:42:04 +0000362
cristy7a40ba82011-01-08 20:31:18 +0000363<p>Disk:[{radius}[,{scale}]] Generate a binary disk of the radius given, radius may be a float. Kernel size will be ceil(radius)*2+1 square. NOTE: Here are some disk shapes of specific interest "Disk:1" => "diamond" or "cross:1" "Disk:1.5" => "square" "Disk:2" => "diamond:2" "Disk:2.5" => a general disk shape of radius 2 "Disk:2.9" => "square:2" "Disk:3.5" => default - octagonal/disk shape of radius 3 "Disk:4.2" => roughly octagonal shape of radius 4 "Disk:4.3" => a general disk shape of radius 4 After this all the kernel shape becomes more and more circular.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000364
cristy7a40ba82011-01-08 20:31:18 +0000365<p>Because a "disk" is more circular when using a larger radius, using a larger radius is preferred over iterating the morphological operation.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000366
cristy7a40ba82011-01-08 20:31:18 +0000367<p>Symbol Dilation Kernels</p>
cristyd2baf7d2010-03-06 04:26:44 +0000368
cristy7a40ba82011-01-08 20:31:18 +0000369<p>These kernel is not a good general morphological kernel, but is used more for highlighting and marking any single pixels in an image using, a "Dilate" method as appropriate.</p>
cristy6f6c2962010-05-14 01:39:00 +0000370
cristy7a40ba82011-01-08 20:31:18 +0000371<p>For the same reasons iterating these kernels does not produce the same result as using a larger radius for the symbol.</p>
cristy6f6c2962010-05-14 01:39:00 +0000372
cristy7a40ba82011-01-08 20:31:18 +0000373<p>Plus:[{radius}[,{scale}]] Cross:[{radius}[,{scale}]] Generate a kernel in the shape of a 'plus' or a 'cross' with a each arm the length of the given radius (default 2).</p>
cristyf1310b52010-05-15 16:42:04 +0000374
cristy7a40ba82011-01-08 20:31:18 +0000375<p>NOTE: "plus:1" is equivelent to a "Diamond" kernel.</p>
cristyf1310b52010-05-15 16:42:04 +0000376
cristy7a40ba82011-01-08 20:31:18 +0000377<p>Ring:{radius1},{radius2}[,{scale}] A ring of the values given that falls between the two radii. Defaults to a ring of approximataly 3 radius in a 7x7 kernel. This is the 'edge' pixels of the default "Disk" kernel, More specifically, "Ring" -> "Ring:2.5,3.5,1.0"</p>
cristyf1310b52010-05-15 16:42:04 +0000378
cristy7a40ba82011-01-08 20:31:18 +0000379<p>Hit and Miss Kernels</p>
cristy6f6c2962010-05-14 01:39:00 +0000380
cristy7a40ba82011-01-08 20:31:18 +0000381<p>Peak:radius1,radius2 Find any peak larger than the pixels the fall between the two radii. The default ring of pixels is as per "Ring". Edges Find flat orthogonal edges of a binary shape Corners Find 90 degree corners of a binary shape LineEnds:type Find end points of lines (for pruning a skeletion) Two types of lines ends (default to both) can be searched for Type 0: All line ends Type 1: single kernel for 4-conneected line ends Type 2: single kernel for simple line ends LineJunctions Find three line junctions (within a skeletion) Type 0: all line junctions Type 1: Y Junction kernel Type 2: Diagonal T Junction kernel Type 3: Orthogonal T Junction kernel Type 4: Diagonal X Junction kernel Type 5: Orthogonal + Junction kernel Ridges:type Find single pixel ridges or thin lines Type 1: Fine single pixel thick lines and ridges Type 2: Find two pixel thick lines and ridges ConvexHull Octagonal thicken kernel, to generate convex hulls of 45 degrees Skeleton:type Traditional skeleton generating kernels. Type 1: Tradional Skeleton kernel (4 connected skeleton) Type 2: HIPR2 Skeleton kernel (8 connected skeleton) Type 3: Experimental Variation to try to present left-right symmetry Type 4: Experimental Variation to preserve left-right symmetry</p>
cristyd2baf7d2010-03-06 04:26:44 +0000382
cristy7a40ba82011-01-08 20:31:18 +0000383<p>Distance Measuring Kernels</p>
cristyd2baf7d2010-03-06 04:26:44 +0000384
cristy7a40ba82011-01-08 20:31:18 +0000385<p>Different types of distance measuring methods, which are used with the a 'Distance' morphology method for generating a gradient based on distance from an edge of a binary shape, though there is a technique for handling a anti-aliased shape.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000386
cristy7a40ba82011-01-08 20:31:18 +0000387<p>See the 'Distance' Morphological Method, for information of how it is applied.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000388
cristy7a40ba82011-01-08 20:31:18 +0000389<p>Chebyshev:[{radius}][x{scale}[!]] Chebyshev Distance (also known as Tchebychev Distance) is a value of one to any neighbour, orthogonal or diagonal. One why of thinking of it is the number of squares a 'King' or 'Queen' in chess needs to traverse reach any other position on a chess board. It results in a 'square' like distance function, but one where diagonals are closer than expected.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000390
cristy7a40ba82011-01-08 20:31:18 +0000391<p>Manhattan:[{radius}][x{scale}[!]] Manhattan Distance (also known as Rectilinear Distance, or the Taxi Cab metric), is the distance needed when you can only travel in orthogonal (horizontal or vertical) only. It is the distance a 'Rook' in chess would travel. It results in a diamond like distances, where diagonals are further than expected.</p>
cristyf1310b52010-05-15 16:42:04 +0000392
cristy7a40ba82011-01-08 20:31:18 +0000393<p>Euclidean:[{radius}][x{scale}[!]] Euclidean Distance is the 'direct' or 'as the crow flys distance. However by default the kernel size only has a radius of 1, which limits the distance to 'Knight' like moves, with only orthogonal and diagonal measurements being correct. As such for the default kernel you will get octagonal like distance function, which is reasonally accurate.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000394
cristy7a40ba82011-01-08 20:31:18 +0000395<p>However if you use a larger radius such as "Euclidean:4" you will get a much smoother distance gradient from the edge of the shape. Of course a larger kernel is slower to use, and generally not needed.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000396
cristy7a40ba82011-01-08 20:31:18 +0000397<p>To allow the use of fractional distances that you get with diagonals the actual distance is scaled by a fixed value which the user can provide. This is not actually nessary for either ""Chebyshev" or "Manhattan" distance kernels, but is done for all three distance kernels. If no scale is provided it is set to a value of 100, allowing for a maximum distance measurement of 655 pixels using a Q16 version of IM, from any edge. However for small images this can result in quite a dark gradient.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000398
cristyd2baf7d2010-03-06 04:26:44 +0000399 </div>
cristy7a40ba82011-01-08 20:31:18 +0000400<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
401_8c.html" id="CloneKernelInfo">CloneKernelInfo</a></h2>
cristyd2baf7d2010-03-06 04:26:44 +0000402<div class="doc-section">
403
cristy7a40ba82011-01-08 20:31:18 +0000404<p>CloneKernelInfo() creates a new clone of the given Kernel List so that its can be modified without effecting the original. The cloned kernel should be destroyed using DestoryKernelInfo() when no longer needed.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000405
cristy0291e2d2010-04-04 17:50:18 +0000406<p>The format of the CloneKernelInfo method is:</p>
cristyd2baf7d2010-03-06 04:26:44 +0000407
408<pre class="code">
409 KernelInfo *CloneKernelInfo(const KernelInfo *kernel)
410</pre>
411
cristy7a40ba82011-01-08 20:31:18 +0000412<p>A description of each parameter follows:</p>
cristyd2baf7d2010-03-06 04:26:44 +0000413
414<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000415<p>the Morphology/Convolution kernel to be cloned</p>
cristyd2baf7d2010-03-06 04:26:44 +0000416
417 </div>
cristy7a40ba82011-01-08 20:31:18 +0000418<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
419_8c.html" id="DestroyKernelInfo">DestroyKernelInfo</a></h2>
cristyd2baf7d2010-03-06 04:26:44 +0000420<div class="doc-section">
421
cristy7a40ba82011-01-08 20:31:18 +0000422<p>DestroyKernelInfo() frees the memory used by a Convolution/Morphology kernel.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000423
424<p>The format of the DestroyKernelInfo method is:</p>
425
426<pre class="code">
427 KernelInfo *DestroyKernelInfo(KernelInfo *kernel)
428</pre>
429
cristy7a40ba82011-01-08 20:31:18 +0000430<p>A description of each parameter follows:</p>
cristyd2baf7d2010-03-06 04:26:44 +0000431
432<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000433<p>the Morphology/Convolution kernel to be destroyed</p>
cristyd2baf7d2010-03-06 04:26:44 +0000434
435 </div>
cristy7a40ba82011-01-08 20:31:18 +0000436<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
437_8c.html" id="MorphologyApply">MorphologyApply</a></h2>
cristyc4960862010-05-23 22:24:24 +0000438<div class="doc-section">
439
cristy7a40ba82011-01-08 20:31:18 +0000440<p>MorphologyApply() applies a morphological method, multiple times using a list of multiple kernels.</p>
cristyc4960862010-05-23 22:24:24 +0000441
cristy7a40ba82011-01-08 20:31:18 +0000442<p>It is basically equivelent to as MorphologyImageChannel() (see below) but without any user controls. This allows internel programs to use this function, to actually perform a specific task without posible interference by any API user supplied settings.</p>
cristyc4960862010-05-23 22:24:24 +0000443
cristy7a40ba82011-01-08 20:31:18 +0000444<p>It is MorphologyImageChannel() task to extract any such user controls, and pass them to this function for processing.</p>
cristyfe0019b2010-06-07 02:23:32 +0000445
cristy7a40ba82011-01-08 20:31:18 +0000446<p>More specifically kernels are not normalized/scaled/blended by the 'convolve:scale' Image Artifact (setting), nor is the convolve bias (-bias setting or image->bias) loooked at, but must be supplied from the function arguments.</p>
cristyc4960862010-05-23 22:24:24 +0000447
448<p>The format of the MorphologyApply method is:</p>
449
450<pre class="code">
451 Image *MorphologyApply(const Image *image,MorphologyMethod method,
cristybb503372010-05-27 20:51:26 +0000452 const ssize_t iterations,const KernelInfo *kernel,
cristyc4960862010-05-23 22:24:24 +0000453 const CompositeMethod compose, const double bias,
454 ExceptionInfo *exception)
455</pre>
456
cristy7a40ba82011-01-08 20:31:18 +0000457<p>A description of each parameter follows:</p>
cristyc4960862010-05-23 22:24:24 +0000458
459<h5>image</h5>
cristy7a40ba82011-01-08 20:31:18 +0000460<p>the source image</p>
cristyc4960862010-05-23 22:24:24 +0000461
462<h5>method</h5>
cristy7a40ba82011-01-08 20:31:18 +0000463<p>the morphology method to be applied.</p>
cristyc4960862010-05-23 22:24:24 +0000464
465<h5>iterations</h5>
cristy7a40ba82011-01-08 20:31:18 +0000466<p>apply the operation this many times (or no change). A value of -1 means loop until no change found. How this is applied may depend on the morphology method. Typically this is a value of 1.</p>
cristyc4960862010-05-23 22:24:24 +0000467
468<h5>channel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000469<p>the channel type.</p>
cristyc4960862010-05-23 22:24:24 +0000470
471<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000472<p>An array of double representing the morphology kernel.</p>
cristyc4960862010-05-23 22:24:24 +0000473
474<h5>compose</h5>
cristy7a40ba82011-01-08 20:31:18 +0000475<p>How to handle or merge multi-kernel results. If 'UndefinedCompositeOp' use default for the Morphology method. If 'NoCompositeOp' force image to be re-iterated by each kernel. Otherwise merge the results using the compose method given.</p>
cristyc4960862010-05-23 22:24:24 +0000476
477<h5>bias</h5>
cristy7a40ba82011-01-08 20:31:18 +0000478<p>Convolution Output Bias.</p>
cristyc4960862010-05-23 22:24:24 +0000479
480<h5>exception</h5>
cristy7a40ba82011-01-08 20:31:18 +0000481<p>return any errors or warnings in this structure.</p>
cristyc4960862010-05-23 22:24:24 +0000482
483 </div>
cristy7a40ba82011-01-08 20:31:18 +0000484<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
485_8c.html" id="MorphologyImageChannel">MorphologyImageChannel</a></h2>
cristyd2baf7d2010-03-06 04:26:44 +0000486<div class="doc-section">
487
cristy7a40ba82011-01-08 20:31:18 +0000488<p>MorphologyImageChannel() applies a user supplied kernel to the image according to the given mophology method.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000489
cristy7a40ba82011-01-08 20:31:18 +0000490<p>This function applies any and all user defined settings before calling the above internal function MorphologyApply().</p>
cristyc4960862010-05-23 22:24:24 +0000491
cristy7a40ba82011-01-08 20:31:18 +0000492<p>User defined settings include... * Output Bias for Convolution and correlation ("-bias") * Kernel Scale/normalize settings ("-set 'option:convolve:scale'") This can also includes the addition of a scaled unity kernel. * Show Kernel being applied ("-set option:showkernel 1")</p>
cristyd2baf7d2010-03-06 04:26:44 +0000493
494<p>The format of the MorphologyImage method is:</p>
495
496<pre class="code">
497 Image *MorphologyImage(const Image *image,MorphologyMethod method,
cristybb503372010-05-27 20:51:26 +0000498 const ssize_t iterations,KernelInfo *kernel,ExceptionInfo *exception)
cristyd2baf7d2010-03-06 04:26:44 +0000499</pre>
500
cristy7a40ba82011-01-08 20:31:18 +0000501<p>Image *MorphologyImageChannel(const Image *image, const ChannelType channel,MorphologyMethod method,const ssize_t iterations, KernelInfo *kernel,ExceptionInfo *exception)</p>
cristyc4960862010-05-23 22:24:24 +0000502
cristy7a40ba82011-01-08 20:31:18 +0000503<p>A description of each parameter follows:</p>
cristyd2baf7d2010-03-06 04:26:44 +0000504
505<h5>image</h5>
cristy7a40ba82011-01-08 20:31:18 +0000506<p>the image.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000507
508<h5>method</h5>
cristy7a40ba82011-01-08 20:31:18 +0000509<p>the morphology method to be applied.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000510
511<h5>iterations</h5>
cristy7a40ba82011-01-08 20:31:18 +0000512<p>apply the operation this many times (or no change). A value of -1 means loop until no change found. How this is applied may depend on the morphology method. Typically this is a value of 1.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000513
514<h5>channel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000515<p>the channel type.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000516
517<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000518<p>An array of double representing the morphology kernel. Warning: kernel may be normalized for the Convolve method.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000519
520<h5>exception</h5>
cristy7a40ba82011-01-08 20:31:18 +0000521<p>return any errors or warnings in this structure.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000522
cristyc4960862010-05-23 22:24:24 +0000523 </div>
cristy7a40ba82011-01-08 20:31:18 +0000524<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
525_8c.html" id="ScaleGeometryKernelInfo">ScaleGeometryKernelInfo</a></h2>
cristyc4960862010-05-23 22:24:24 +0000526<div class="doc-section">
cristyd2baf7d2010-03-06 04:26:44 +0000527
cristy7a40ba82011-01-08 20:31:18 +0000528<p>ScaleGeometryKernelInfo() takes a geometry argument string, typically provided as a "-set option:convolve:scale {geometry}" user setting, and modifies the kernel according to the parsed arguments of that setting.</p>
cristyc4960862010-05-23 22:24:24 +0000529
cristy7a40ba82011-01-08 20:31:18 +0000530<p>The first argument (and any normalization flags) are passed to ScaleKernelInfo() to scale/normalize the kernel. The second argument is then passed to UnityAddKernelInfo() to add a scled unity kernel into the scaled/normalized kernel.</p>
cristyc4960862010-05-23 22:24:24 +0000531
532<p>The format of the ScaleKernelInfo method is:</p>
533
534<pre class="code">
535 void ScaleKernelInfo(KernelInfo *kernel, const double scaling_factor,
536 const MagickStatusType normalize_flags )
537</pre>
538
cristy7a40ba82011-01-08 20:31:18 +0000539<p>A description of each parameter follows:</p>
cristyc4960862010-05-23 22:24:24 +0000540
541<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000542<p>the Morphology/Convolution kernel to modify</p>
cristyc4960862010-05-23 22:24:24 +0000543
544<p>o geometry:</p>
545
546<pre class="text">
547 "-set option:convolve:scale {geometry}" setting.
548</pre>
cristyd2baf7d2010-03-06 04:26:44 +0000549
550 </div>
cristy7a40ba82011-01-08 20:31:18 +0000551<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
552_8c.html" id="ScaleKernelInfo">ScaleKernelInfo</a></h2>
cristyd2baf7d2010-03-06 04:26:44 +0000553<div class="doc-section">
554
cristy7a40ba82011-01-08 20:31:18 +0000555<p>ScaleKernelInfo() scales the given kernel list by the given amount, with or without normalization of the sum of the kernel values (as per given flags).</p>
cristyd2baf7d2010-03-06 04:26:44 +0000556
cristy7a40ba82011-01-08 20:31:18 +0000557<p>By default (no flags given) the values within the kernel is scaled directly using given scaling factor without change.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000558
cristy7a40ba82011-01-08 20:31:18 +0000559<p>If either of the two 'normalize_flags' are given the kernel will first be normalized and then further scaled by the scaling factor value given.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000560
cristy7a40ba82011-01-08 20:31:18 +0000561<p>Kernel normalization ('normalize_flags' given) is designed to ensure that any use of the kernel scaling factor with 'Convolve' or 'Correlate' morphology methods will fall into -1.0 to +1.0 range. Note that for non-HDRI versions of IM this may cause images to have any negative results clipped, unless some 'bias' is used.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000562
cristy7a40ba82011-01-08 20:31:18 +0000563<p>More specifically. Kernels which only contain positive values (such as a 'Gaussian' kernel) will be scaled so that those values sum to +1.0, ensuring a 0.0 to +1.0 output range for non-HDRI images.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000564
cristy7a40ba82011-01-08 20:31:18 +0000565<p>For Kernels that contain some negative values, (such as 'Sharpen' kernels) the kernel will be scaled by the absolute of the sum of kernel values, so that it will generally fall within the +/- 1.0 range.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000566
cristy7a40ba82011-01-08 20:31:18 +0000567<p>For kernels whose values sum to zero, (such as 'Laplician' kernels) kernel will be scaled by just the sum of the postive values, so that its output range will again fall into the +/- 1.0 range.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000568
cristy7a40ba82011-01-08 20:31:18 +0000569<p>For special kernels designed for locating shapes using 'Correlate', (often only containing +1 and -1 values, representing foreground/brackground matching) a special normalization method is provided to scale the positive values seperatally to those of the negative values, so the kernel will be forced to become a zero-sum kernel better suited to such searches.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000570
cristy7a40ba82011-01-08 20:31:18 +0000571<p>WARNING: Correct normalization of the kernel assumes that the '*_range' attributes within the kernel structure have been correctly set during the kernels creation.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000572
cristy7a40ba82011-01-08 20:31:18 +0000573<p>NOTE: The values used for 'normalize_flags' have been selected specifically to match the use of geometry options, so that '!' means NormalizeValue, '^' means CorrelateNormalizeValue. All other GeometryFlags values are ignored.</p>
cristyd2baf7d2010-03-06 04:26:44 +0000574
575<p>The format of the ScaleKernelInfo method is:</p>
576
577<pre class="code">
578 void ScaleKernelInfo(KernelInfo *kernel, const double scaling_factor,
579 const MagickStatusType normalize_flags )
580</pre>
581
cristy7a40ba82011-01-08 20:31:18 +0000582<p>A description of each parameter follows:</p>
cristyd2baf7d2010-03-06 04:26:44 +0000583
584<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000585<p>the Morphology/Convolution kernel</p>
cristyd2baf7d2010-03-06 04:26:44 +0000586
587<p>o scaling_factor:</p>
588
589<pre class="text">
590 zero. If the kernel is normalized regardless of any flags.
591</pre>
592
593<p>o normalize_flags:</p>
594
595<pre class="text">
596 specifically: NormalizeValue, CorrelateNormalizeValue,
597 and/or PercentValue
598</pre>
599
cristyc4960862010-05-23 22:24:24 +0000600 </div>
cristy7a40ba82011-01-08 20:31:18 +0000601<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
602_8c.html" id="ShowKernelInfo">ShowKernelInfo</a></h2>
cristyc4960862010-05-23 22:24:24 +0000603<div class="doc-section">
604
cristy7a40ba82011-01-08 20:31:18 +0000605<p>ShowKernelInfo() outputs the details of the given kernel defination to standard error, generally due to a users 'showkernel' option request.</p>
cristyc4960862010-05-23 22:24:24 +0000606
607<p>The format of the ShowKernel method is:</p>
608
609<pre class="code">
610 void ShowKernelInfo(KernelInfo *kernel)
611</pre>
612
cristy7a40ba82011-01-08 20:31:18 +0000613<p>A description of each parameter follows:</p>
cristyc4960862010-05-23 22:24:24 +0000614
615<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000616<p>the Morphology/Convolution kernel</p>
cristyc4960862010-05-23 22:24:24 +0000617
618 </div>
cristy7a40ba82011-01-08 20:31:18 +0000619<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
620_8c.html" id="UnityAddKernelInfo">UnityAddKernelInfo</a></h2>
cristyc4960862010-05-23 22:24:24 +0000621<div class="doc-section">
622
cristy7a40ba82011-01-08 20:31:18 +0000623<p>UnityAddKernelInfo() Adds a given amount of the 'Unity' Convolution Kernel to the given pre-scaled and normalized Kernel. This in effect adds that amount of the original image into the resulting convolution kernel. This value is usually provided by the user as a percentage value in the 'convolve:scale' setting.</p>
cristyc4960862010-05-23 22:24:24 +0000624
cristy7a40ba82011-01-08 20:31:18 +0000625<p>The resulting effect is to convert the defined kernels into blended soft-blurs, unsharp kernels or into sharpening kernels.</p>
cristyc4960862010-05-23 22:24:24 +0000626
627<p>The format of the UnityAdditionKernelInfo method is:</p>
628
629<pre class="code">
630 void UnityAdditionKernelInfo(KernelInfo *kernel, const double scale )
631</pre>
632
cristy7a40ba82011-01-08 20:31:18 +0000633<p>A description of each parameter follows:</p>
cristyc4960862010-05-23 22:24:24 +0000634
635<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000636<p>the Morphology/Convolution kernel</p>
cristyc4960862010-05-23 22:24:24 +0000637
638<p>o scale:</p>
639
640<pre class="text">
641 the given kernel.
642</pre>
643
644 </div>
cristy7a40ba82011-01-08 20:31:18 +0000645<h2><a href="http://www.wizards-toolkit.org/api/MagickCore/morphology
646_8c.html" id="ZeroKernelNans">ZeroKernelNans</a></h2>
cristyc4960862010-05-23 22:24:24 +0000647<div class="doc-section">
648
cristy7a40ba82011-01-08 20:31:18 +0000649<p>ZeroKernelNans() replaces any special 'nan' value that may be present in the kernel with a zero value. This is typically done when the kernel will be used in special hardware (GPU) convolution processors, to simply matters.</p>
cristyc4960862010-05-23 22:24:24 +0000650
651<p>The format of the ZeroKernelNans method is:</p>
652
653<pre class="code">
654 void ZeroKernelNans (KernelInfo *kernel)
655</pre>
656
cristy7a40ba82011-01-08 20:31:18 +0000657<p>A description of each parameter follows:</p>
cristyc4960862010-05-23 22:24:24 +0000658
659<h5>kernel</h5>
cristy7a40ba82011-01-08 20:31:18 +0000660<p>the Morphology/Convolution kernel</p>
cristyc4960862010-05-23 22:24:24 +0000661
cristyd2baf7d2010-03-06 04:26:44 +0000662 </div>
cristy3eaa0ef2010-03-06 20:35:26 +0000663
664</div>
665
666<div id="linkbar">
cristyce69bb02010-07-27 19:49:46 +0000667 <span id="linkbar-west">&nbsp;</span>
cristy3eaa0ef2010-03-06 20:35:26 +0000668 <span id="linkbar-center">
669 <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;
cristya8902942010-07-30 00:49:52 +0000670 <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>
cristy3eaa0ef2010-03-06 20:35:26 +0000671 </span>
672 <span id="linkbar-east">&nbsp;</span>
673 </div>
674 <div class="footer">
cristy4103d562010-12-10 01:38:54 +0000675 <span id="footer-west">&copy; 1999-2011 ImageMagick Studio LLC</span>
cristy3eaa0ef2010-03-06 20:35:26 +0000676 <span id="footer-east"> <a href="../http://www.imagemagick.org/script/contact.php">Contact the Wizards</a></span>
677 </div>
678 <div style="clear: both; margin: 0; width: 100%; "></div>
cristya8902942010-07-30 00:49:52 +0000679 <script type="text/javascript">
680 var _gaq = _gaq || [];
681 _gaq.push(['_setAccount', 'UA-17690367-1']);
682 _gaq.push(['_trackPageview']);
683
684 (function() {
685 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
686 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
687 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
688 })();
689 </script>
cristy3eaa0ef2010-03-06 20:35:26 +0000690</body>
691</html>