/usr/share/gtk-doc/html/libvips/libvips-morphology.html is in libvips-doc 7.28.5-1+deb7u1.
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 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 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>morphology</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="VIPS Reference Manual">
<link rel="up" href="ch02.html" title="VIPS operation API by section">
<link rel="prev" href="libvips-mask.html" title="mask">
<link rel="next" href="libvips-mosaicing.html" title="mosaicing">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="libvips-mask.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch02.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">VIPS Reference Manual</th>
<td><a accesskey="n" href="libvips-mosaicing.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#libvips-morphology.synopsis" class="shortcut">Top</a>
|
<a href="#libvips-morphology.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="libvips-morphology"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="libvips-morphology.top_of_page"></a>morphology</span></h2>
<p>morphology — morphological operators, rank filters and related image
analysis</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="libvips-morphology.stability-level"></a><h2>Stability Level</h2>
Stable, unless otherwise indicated
</div>
<div class="refsynopsisdiv">
<a name="libvips-morphology.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include <vips/vips.h>
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-cntlines" title="im_cntlines ()">im_cntlines</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *im</code></em>,
<em class="parameter"><code><span class="type">double</span> *nolines</code></em>,
<em class="parameter"><code><span class="type">int</span> flag</code></em>);
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-dilate" title="im_dilate ()">im_dilate</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><a class="link" href="libvips-mask.html#INTMASK:CAPS" title="INTMASK"><span class="type">INTMASK</span></a> *mask</code></em>);
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-erode" title="im_erode ()">im_erode</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><a class="link" href="libvips-mask.html#INTMASK:CAPS" title="INTMASK"><span class="type">INTMASK</span></a> *mask</code></em>);
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-label-regions" title="im_label_regions ()">im_label_regions</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *test</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *mask</code></em>,
<em class="parameter"><code><span class="type">int</span> *segments</code></em>);
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-maxvalue" title="im_maxvalue ()">im_maxvalue</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> **in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> n</code></em>);
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-profile" title="im_profile ()">im_profile</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> dir</code></em>);
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-rank" title="im_rank ()">im_rank</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> width</code></em>,
<em class="parameter"><code><span class="type">int</span> height</code></em>,
<em class="parameter"><code><span class="type">int</span> index</code></em>);
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-rank-image" title="im_rank_image ()">im_rank_image</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> **in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> n</code></em>,
<em class="parameter"><code><span class="type">int</span> index</code></em>);
<span class="returnvalue">int</span> <a class="link" href="libvips-morphology.html#im-zerox" title="im_zerox ()">im_zerox</a> (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> sign</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="libvips-morphology.description"></a><h2>Description</h2>
<p>
The morphological functions search images
for particular patterns of pixels, specified with the mask argument,
either adding or removing pixels when they find a match. They are useful
for cleaning up images --- for example, you might threshold an image, and
then use one of the morphological functions to remove all single isolated
pixels from the result.
</p>
<p>
If you combine the morphological operators with the mask rotators
<a class="link" href="libvips-mask.html#im-rotate-imask45" title="im_rotate_imask45 ()"><code class="function">im_rotate_imask45()</code></a>, for example) and apply them repeatedly, you
can achieve very complicated effects: you can thin, prune, fill, open edges,
close gaps, and many others. For example, see `Fundamentals of Digital
Image Processing' by A. Jain, pp 384-388, Prentice-Hall, 1989 for more
ideas.
</p>
<p>
Beware that VIPS reverses the usual image processing convention, by
assuming white objects (non-zero pixels) on a black background (zero
pixels).
</p>
<p>
The mask you give to the morphological functions should contain only the
values 0 (for background), 128 (for don't care) and 255 (for object). The
mask must have odd length sides --- the origin of the mask is taken to be
the centre value. For example, the mask:
</p>
<p>
3 3
128 255 128
255 0 255
128 255 128
</p>
<p>
applied to an image with <a class="link" href="libvips-morphology.html#im-erode" title="im_erode ()"><code class="function">im_erode()</code></a>, will find all black pixels
4-way connected with white pixels. Essentially, <a class="link" href="libvips-morphology.html#im-dilate" title="im_dilate ()"><code class="function">im_dilate()</code></a>
sets pixels in the output if any part of the mask matches, whereas
<a class="link" href="libvips-morphology.html#im-erode" title="im_erode ()"><code class="function">im_erode()</code></a> sets pixels only if all of the mask matches.
</p>
<p>
See <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-andimage"><code class="function">im_andimage()</code></a>, <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-orimage"><code class="function">im_orimage()</code></a> and <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-eorimage"><code class="function">im_eorimage()</code></a>
for analogues of the usual set difference and set union operations.
</p>
</div>
<div class="refsect1">
<a name="libvips-morphology.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="im-cntlines"></a><h3>im_cntlines ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_cntlines (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *im</code></em>,
<em class="parameter"><code><span class="type">double</span> *nolines</code></em>,
<em class="parameter"><code><span class="type">int</span> flag</code></em>);</pre>
<p>
Function which calculates the number of transitions
between black and white for the horizontal or the vertical
direction of an image. black<128 , white>=128
The function calculates the number of transitions for all
Xsize or Ysize and returns the mean of the result
Input should be one band, 8-bit.
</p>
<p>
See also: <a class="link" href="libvips-morphology.html#im-erode" title="im_erode ()"><code class="function">im_erode()</code></a>, <a class="link" href="libvips-morphology.html#im-zerox" title="im_zerox ()"><code class="function">im_zerox()</code></a>, <a class="link" href="libvips-convolution.html#im-conv" title="im_conv ()"><code class="function">im_conv()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>im</code></em> :</span></p></td>
<td>input <span class="type">IMAGE</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>nolines</code></em> :</span></p></td>
<td>output average number of lines</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>flag</code></em> :</span></p></td>
<td>0 horizontal, 1 vertical</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="im-dilate"></a><h3>im_dilate ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_dilate (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><a class="link" href="libvips-mask.html#INTMASK:CAPS" title="INTMASK"><span class="type">INTMASK</span></a> *mask</code></em>);</pre>
<p>
<a class="link" href="libvips-morphology.html#im-dilate" title="im_dilate ()"><code class="function">im_dilate()</code></a> performs a morphological dilate operation on <em class="parameter"><code>in</code></em> using <em class="parameter"><code>mask</code></em> as a
structuring element. The output pixel is set if any part of the mask
matches, that is, the result is the logical OR of the selected input pixels.
</p>
<p>
The image should have 0 (black) for no object and 255
(non-zero) for an object. Note that this is the reverse of the usual
convention for these operations, but more convenient when combined with the
boolean operators <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-andimage"><code class="function">im_andimage()</code></a> and friends. The output image is the same
size as the input image: edge pxels are made by expanding the input image
as necessary in the manner of <a class="link" href="libvips-convolution.html#im-conv" title="im_conv ()"><code class="function">im_conv()</code></a>.
</p>
<p>
Mask coefficients can be either 0 (for object) or 255 (for background)
or 128 (for do not care). The origin of the mask is at location
(m.xsize / 2, m.ysize / 2), integer division. All algorithms have been
based on the book "Fundamentals of Digital Image Processing" by A. Jain,
pp 384-388, Prentice-Hall, 1989.
</p>
<p>
See the boolean operations <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-andimage"><code class="function">im_andimage()</code></a>, <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-orimage"><code class="function">im_orimage()</code></a> and <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-eorimage"><code class="function">im_eorimage()</code></a>
for analogues of the usual set difference and set union operations.
</p>
<p>
Operations are performed using the processor's vector unit,
if possible. Disable this with --vips-novector or IM_NOVECTOR.
</p>
<p>
See also: <a class="link" href="libvips-morphology.html#im-erode" title="im_erode ()"><code class="function">im_erode()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>in</code></em> :</span></p></td>
<td>input image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>out</code></em> :</span></p></td>
<td>output image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mask</code></em> :</span></p></td>
<td>mask</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="im-erode"></a><h3>im_erode ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_erode (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><a class="link" href="libvips-mask.html#INTMASK:CAPS" title="INTMASK"><span class="type">INTMASK</span></a> *mask</code></em>);</pre>
<p>
<a class="link" href="libvips-morphology.html#im-erode" title="im_erode ()"><code class="function">im_erode()</code></a> performs a morphological erode operation on <em class="parameter"><code>in</code></em> using <em class="parameter"><code>mask</code></em> as a
structuring element. The whole mask must match for the output pixel to be
set, that is, the result is the logical AND of the selected input pixels.
</p>
<p>
The image should have 0 (black) for no object and 255
(non-zero) for an object. Note that this is the reverse of the usual
convention for these operations, but more convenient when combined with the
boolean operators <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-andimage"><code class="function">im_andimage()</code></a> and friends. The output image is the same
size as the input image: edge pxels are made by expanding the input image
as necessary in the manner of <a class="link" href="libvips-convolution.html#im-conv" title="im_conv ()"><code class="function">im_conv()</code></a>.
</p>
<p>
Mask coefficients can be either 0 (for object) or 255 (for background)
or 128 (for do not care). The origin of the mask is at location
(m.xsize / 2, m.ysize / 2), integer division. All algorithms have been
based on the book "Fundamentals of Digital Image Processing" by A. Jain,
pp 384-388, Prentice-Hall, 1989.
</p>
<p>
See the boolean operations <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-andimage"><code class="function">im_andimage()</code></a>, <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-orimage"><code class="function">im_orimage()</code></a> and <a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html#im-eorimage"><code class="function">im_eorimage()</code></a>
for analogues of the usual set difference and set union operations.
</p>
<p>
Operations are performed using the processor's vector unit,
if possible. Disable this with --vips-novector or IM_NOVECTOR.
</p>
<p>
See also: <a class="link" href="libvips-morphology.html#im-dilate" title="im_dilate ()"><code class="function">im_dilate()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>in</code></em> :</span></p></td>
<td>input image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>out</code></em> :</span></p></td>
<td>output image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mask</code></em> :</span></p></td>
<td>mask</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="im-label-regions"></a><h3>im_label_regions ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_label_regions (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *test</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *mask</code></em>,
<em class="parameter"><code><span class="type">int</span> *segments</code></em>);</pre>
<p>
<a class="link" href="libvips-morphology.html#im-label-regions" title="im_label_regions ()"><code class="function">im_label_regions()</code></a> repeatedly scans <em class="parameter"><code>test</code></em> for regions of 4-connected pixels
with the same pixel value. Every time a region is discovered, those
pixels are marked in <em class="parameter"><code>mask</code></em> with a unique serial number. Once all pixels
have been labelled, the operation returns, setting <em class="parameter"><code>segments</code></em> to the number
of discrete regions which were detected.
</p>
<p>
<em class="parameter"><code>mask</code></em> is always a 1-band <code class="literal">IM_BANDFMT_UINT</code> image of the same dimensions as
<em class="parameter"><code>test</code></em>.
</p>
<p>
This operation is useful for, for example, blob counting. You can use the
morphological operators to detect and isolate a series of objects, then use
<a class="link" href="libvips-morphology.html#im-label-regions" title="im_label_regions ()"><code class="function">im_label_regions()</code></a> to number them all.
</p>
<p>
Use <code class="function">im_histindexed()</code> to (for example) find blob coordinates.
</p>
<p>
See also: <code class="function">im_histindexed()</code>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>test</code></em> :</span></p></td>
<td>image to test</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>mask</code></em> :</span></p></td>
<td>write labelled regions here</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>segments</code></em> :</span></p></td>
<td>return number of regions here</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="im-maxvalue"></a><h3>im_maxvalue ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_maxvalue (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> **in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> n</code></em>);</pre>
<p>
<a class="link" href="libvips-morphology.html#im-maxvalue" title="im_maxvalue ()"><code class="function">im_maxvalue()</code></a> is a convenience function over <a class="link" href="libvips-morphology.html#im-rank-image" title="im_rank_image ()"><code class="function">im_rank_image()</code></a>. It sorts the
input images pixel-wise, then outputs an image
in which each pixel is the maximum of all the corresponding input images.
It works for any uncoded, non-complex image type. Images are cast up to the
smallest common-format.
</p>
<p>
Any image can have either 1 band or n bands, where n is the same for all
the non-1-band images. Single band images are then effectively copied to
make n-band images.
</p>
<p>
See also: <a class="link" href="libvips-morphology.html#im-rank-image" title="im_rank_image ()"><code class="function">im_rank_image()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>in</code></em> :</span></p></td>
<td>input image array</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>out</code></em> :</span></p></td>
<td>output image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em> :</span></p></td>
<td>number of input images</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="im-profile"></a><h3>im_profile ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_profile (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> dir</code></em>);</pre>
<p>
<a class="link" href="libvips-morphology.html#im-profile" title="im_profile ()"><code class="function">im_profile()</code></a> searches inward from the edge of <em class="parameter"><code>in</code></em> and finds the
first non-zero pixel. It outputs an image containing a list of the offsets
for each row or column.
</p>
<p>
If <em class="parameter"><code>dir</code></em> == 0, then <a class="link" href="libvips-morphology.html#im-profile" title="im_profile ()"><code class="function">im_profile()</code></a> searches down from the top edge, writing an
image as wide as the input image, but only 1 pixel high, containing the
number of pixels down to the first non-zero pixel for each column of input
pixels.
</p>
<p>
If <em class="parameter"><code>dir</code></em> == 1, then <a class="link" href="libvips-morphology.html#im-profile" title="im_profile ()"><code class="function">im_profile()</code></a> searches across from the left edge,
writing an image as high as the input image, but only 1 pixel wide,
containing the number of pixels across to the
first non-zero pixel for each row of input pixels.
</p>
<p>
See also: <a class="link" href="libvips-morphology.html#im-cntlines" title="im_cntlines ()"><code class="function">im_cntlines()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>in</code></em> :</span></p></td>
<td>input image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>out</code></em> :</span></p></td>
<td>output image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td>
<td>search direction</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="im-rank"></a><h3>im_rank ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_rank (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> width</code></em>,
<em class="parameter"><code><span class="type">int</span> height</code></em>,
<em class="parameter"><code><span class="type">int</span> index</code></em>);</pre>
<p>
<a class="link" href="libvips-morphology.html#im-rank" title="im_rank ()"><code class="function">im_rank()</code></a> does rank filtering on an image. A window of size <em class="parameter"><code>width</code></em> by
<em class="parameter"><code>height</code></em> is passed over the image. At each position, the pixels inside the
window are sorted into ascending order and the pixel at position <em class="parameter"><code>index</code></em> is
output. <em class="parameter"><code>index</code></em> numbers from 0.
</p>
<p>
It works for any non-complex image type, with any number of bands.
The input is expanded by copying edge pixels before performing the
operation so that the output image has the same size as the input.
Edge pixels in the output image are therefore only approximate.
</p>
<p>
For a median filter with mask size m (3 for 3x3, 5 for 5x5, etc.) use
</p>
<p>
im_rank( in, out, m, m, m * m / 2 );
</p>
<p>
The special cases n == 0 and n == m * m - 1 are useful dilate and
expand operators.
</p>
<p>
See also: <a class="link" href="libvips-convolution.html#im-conv" title="im_conv ()"><code class="function">im_conv()</code></a>, <a class="link" href="libvips-convolution.html#im-fastcor" title="im_fastcor ()"><code class="function">im_fastcor()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>in</code></em> :</span></p></td>
<td>input image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>out</code></em> :</span></p></td>
<td>output image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td>
<td>window width</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td>
<td>window height</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index</code></em> :</span></p></td>
<td>select pixel</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="im-rank-image"></a><h3>im_rank_image ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_rank_image (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> **in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> n</code></em>,
<em class="parameter"><code><span class="type">int</span> index</code></em>);</pre>
<p>
<a class="link" href="libvips-morphology.html#im-rank-image" title="im_rank_image ()"><code class="function">im_rank_image()</code></a> sorts the images <em class="parameter"><code>in</code></em> pixel-wise, then outputs an
image in which each pixel is selected from the sorted list by the
<em class="parameter"><code>index</code></em> parameter. For example, if <em class="parameter"><code>index</code></em>
is zero, then each output pixel will be the minimum of all the
corresponding input pixels.
</p>
<p>
It works for any uncoded, non-complex image type. Images are cast up to the
smallest common-format.
</p>
<p>
Any image can have either 1 band or n bands, where n is the same for all
the non-1-band images. Single band images are then effectively copied to
make n-band images.
</p>
<p>
See also: <a class="link" href="libvips-morphology.html#im-rank" title="im_rank ()"><code class="function">im_rank()</code></a>, <a class="link" href="libvips-morphology.html#im-maxvalue" title="im_maxvalue ()"><code class="function">im_maxvalue()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>in</code></em> :</span></p></td>
<td>input image array</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>out</code></em> :</span></p></td>
<td>output image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n</code></em> :</span></p></td>
<td>number of input images</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index</code></em> :</span></p></td>
<td>select pixel</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="im-zerox"></a><h3>im_zerox ()</h3>
<pre class="programlisting"><span class="returnvalue">int</span> im_zerox (<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *in</code></em>,
<em class="parameter"><code><a class="link" href="VipsImage.html" title="VipsImage"><span class="type">VipsImage</span></a> *out</code></em>,
<em class="parameter"><code><span class="type">int</span> sign</code></em>);</pre>
<p>
<a class="link" href="libvips-morphology.html#im-zerox" title="im_zerox ()"><code class="function">im_zerox()</code></a> detects the positive or negative zero crossings <em class="parameter"><code>in</code></em>,
depending on <em class="parameter"><code>sign</code></em>. If <em class="parameter"><code>sign</code></em> is -1, negative zero crossings are returned,
if <em class="parameter"><code>sign</code></em> is 1, positive zero crossings are returned.
</p>
<p>
The output image is byte with zero crossing set to 255 and all other values
set to zero. Input can have any number of channels, and be any non-complex
type.
</p>
<p>
See also: <a class="link" href="libvips-convolution.html#im-conv" title="im_conv ()"><code class="function">im_conv()</code></a>, im_rot90.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>in</code></em> :</span></p></td>
<td>input image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>out</code></em> :</span></p></td>
<td>output image</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>sign</code></em> :</span></p></td>
<td>detect positive or negative zero crossings</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>0 on success, -1 on error</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1">
<a name="libvips-morphology.see-also"></a><h2>See Also</h2>
<a href="http://http://www.vips.ecs.soton.ac.uk/libvips-boolean.html">boolean</a>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.18</div>
</body>
</html>
|