| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| "http://www.w3.org/TR/html4/loose.dtd"> |
| <html > |
| <head><title>VIPS packages</title> |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> |
| <meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)"> |
| <!-- 3,html --> |
| <meta name="src" content="vipsmanual.tex"> |
| <meta name="date" content="2010-06-09 21:39:00"> |
| <link rel="stylesheet" type="text/css" href="vipsmanual.css"> |
| </head><body |
| > |
| <!--l. 1--><div class="crosslinks"><p class="noindent">[<a |
| href="vipsmanualse17.html" >prev</a>] [<a |
| href="vipsmanualse17.html#tailvipsmanualse17.html" >prev-tail</a>] [<a |
| href="#tailvipsmanualse18.html">tail</a>] [<a |
| href="vipsmanualch4.html#vipsmanualse18.html" >up</a>] </p></div> |
| <h3 class="sectionHead"><span class="titlemark">4.2 </span> <a |
| id="x26-1060004.2"></a>VIPS packages</h3> |
| <!--l. 2--><p class="noindent" ><a name="nip_label_sec:packages"></a> |
| <!--l. 4--><p class="noindent" > |
| <h4 class="subsectionHead"><span class="titlemark">4.2.1 </span> <a |
| id="x26-1070004.2.1"></a>Arithmetic</h4> |
| <!--l. 6--><p class="noindent" >See Figure <a |
| href="#x26-1070011">4.1<!--tex4ht:ref: fg:arithmetic --></a>. |
| <!--l. 8--><p class="indent" > Arithmetic functions work on images as if each band |
| element were a separate number. All operations are |
| point-to-point — each output element depends exactly upon |
| the corresponding input element. All (except in a few cases |
| noted in the manual pages) will work with images of any |
| type (or any mixture of types), of any size and of any |
| number of bands. |
| <!--l. 14--><p class="indent" > Arithmetic operations try to preserve precision by |
| increasing the number of bits in the output image |
| when necessary. Generally, this follows the ANSI C |
| conventions for type promotion — so multiplying two |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_UCHAR</span></span></span> images together, for example, |
| produces a <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_USHORT</span></span></span> image, and taking the |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_costra()</span></span></span> of a <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_USHORT</span></span></span> image |
| produces a <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_FLOAT</span></span></span> image. The details of |
| the type conversions are in the manual pages. |
| |
| |
| |
| |
| <!--l. 23--><p class="indent" > <a |
| id="x26-1070011"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-177"> |
| $ vips --list arithmetic |
|  <br />im_abs               - absolute value |
|  <br />im_acostra           - acos of image (result in degrees) |
|  <br />im_add               - add two images |
|  <br />im_asintra           - asin of image (result in degrees) |
|  <br />im_atantra           - atan of image (result in degrees) |
|  <br />im_avg               - average value of image |
|  <br />im_point_bilinear    - interpolate value at single point, linearly |
|  <br />im_bandmean          - average image bands |
|  <br />im_ceil              - round to smallest integal value not less than |
|  <br />im_cmulnorm          - multiply two complex images, normalising output |
|  <br />im_costra            - cos of image (angles in degrees) |
|  <br />im_cross_phase       - phase of cross power spectrum of two complex images |
|  <br />im_deviate           - standard deviation of image |
|  <br />im_divide            - divide two images |
|  <br />im_exp10tra          - 10^pel of image |
|  <br />im_expntra           - x^pel of image |
|  <br />im_expntra_vec       - [x,y,z]^pel of image |
|  <br />im_exptra            - e^pel of image |
|  <br />im_fav4              - average of 4 images |
|  <br />im_floor             - round to largest integal value not greater than |
|  <br />im_gadd              - calculate a⋆in1 + b⋆in2 + c = outfile |
|  <br />im_invert            - photographic negative |
|  <br />im_lintra            - calculate a⋆in + b = outfile |
|  <br />im_linreg            - pixelwise linear regression |
|  <br />im_lintra_vec        - calculate a⋆in + b -> out, a and b vectors |
|  <br />im_litecor           - calculate max(white)⋆factor⋆(in/white), if clip == 1 |
|  <br />im_log10tra          - log10 of image |
|  <br />im_logtra            - ln of image |
|  <br />im_max               - maximum value of image |
|  <br />im_maxpos            - position of maximum value of image |
|  <br />im_maxpos_avg        - position of maximum value of image, averaging in case of draw |
|  <br />im_maxpos_vec        - position and value of n maxima of image |
|  <br />im_measure           - measure averages of a grid of patches |
|  <br />im_min               - minimum value of image |
|  <br />im_minpos            - position of minimum value of image |
|  <br />im_minpos_vec        - position and value of n minima of image |
|  <br />im_multiply          - multiply two images |
|  <br />im_powtra            - pel^x ofbuildimage |
|  <br />im_powtra_vec        - pel^[x,y,z] of image |
|  <br />im_remainder         - remainder after integer division |
|  <br />im_remainderconst    - remainder after integer division by a constant |
|  <br />im_remainderconst_vec - remainder after integer division by a vector of constants |
|  <br />im_rint              - round to nearest integal value |
|  <br />im_sign              - unit vector in direction of value |
|  <br />im_sintra            - sin of image (angles in degrees) <br />im_stats             - many image statistics in one pass |
|  <br />im_subtract          - subtract two images |
|  <br />im_tantra            - tan of image (angles in degrees) |
| </div> |
| <!--l. 73--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.1: </span><span |
| class="content">Arithmetic functions</span></div><!--tex4ht:label?: x26-1070011 --> |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.2 </span> <a |
| id="x26-1080004.2.2"></a>Relational</h4> |
| <!--l. 80--><p class="noindent" >See Figure <a |
| href="#x26-1080012">4.2<!--tex4ht:ref: fg:relational --></a>. |
| <!--l. 82--><p class="indent" > Relational functions compare images to other images or |
| to constants. They accept any image or pair of images |
| (provided they are the same size and have the same |
| number of bands — their types may differ) and produce a |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_UCHAR</span></span></span> image with the same number of |
| bands as the input image, with 255 in every band element |
| for which the condition is true and 0 elsewhere. |
| <!--l. 89--><p class="indent" > They may be combined with the boolean functions to |
| form complex relational conditions. Use <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_max()</span></span></span> (or |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_min()</span></span></span>) to find out if a condition is true (or false) for a |
| whole image. |
| |
| |
| |
| |
| <!--l. 94--><p class="indent" > <a |
| id="x26-1080012"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-178"> |
| $ vips --list relational |
|  <br />im_blend             - use cond image to blend between images in1 and in2 |
|  <br />im_equal             - two images equal in value |
|  <br />im_equal_vec         - image equals doublevec |
|  <br />im_equalconst        - image equals const |
|  <br />im_ifthenelse        - use cond image to choose pels from image in1 or in2 |
|  <br />im_less              - in1 less than in2 in value |
|  <br />im_less_vec          - in less than doublevec |
|  <br />im_lessconst         - in less than const |
|  <br />im_lesseq            - in1 less than or equal to in2 in value |
|  <br />im_lesseq_vec        - in less than or equal to doublevec |
|  <br />im_lesseqconst       - in less than or equal to const |
|  <br />im_more              - in1 more than in2 in value |
|  <br />im_more_vec          - in more than doublevec |
|  <br />im_moreconst         - in more than const |
|  <br />im_moreeq            - in1 more than or equal to in2 in value |
|  <br />im_moreeq_vec        - in more than or equal to doublevec |
|  <br />im_moreeqconst       - in more than or equal to const |
|  <br />im_notequal          - two images not equal in value |
|  <br />im_notequal_vec      - image does not equal doublevec |
|  <br />im_notequalconst     - image does not equal const |
| </div> |
| <!--l. 116--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.2: </span><span |
| class="content">Relational functions</span></div><!--tex4ht:label?: x26-1080012 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.3 </span> <a |
| id="x26-1090004.2.3"></a>Boolean</h4> |
| <!--l. 123--><p class="noindent" >See Figure <a |
| href="#x26-1090013">4.3<!--tex4ht:ref: fg:boolean --></a>. |
| <!--l. 125--><p class="indent" > The boolean functions perform boolean arithmetic on |
| pairs of <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_UCHAR</span></span></span> images. They are useful for |
| combining the results of the relational and morphological |
| functions. You can use <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_eorconst()</span></span></span> with 255 as |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_not()</span></span></span>. |
| |
| |
| |
| |
| <!--l. 131--><p class="indent" > <a |
| id="x26-1090013"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-179"> |
| $ vips --list boolean |
|  <br />im_andimage          - bitwise and of two images |
|  <br />im_andimageconst     - bitwise and of an image with a constant |
|  <br />im_andimage_vec      - bitwise and of an image with a vector constant |
|  <br />im_orimage           - bitwise or of two images |
|  <br />im_orimageconst      - bitwise or of an image with a constant |
|  <br />im_orimage_vec       - bitwise or of an image with a vector constant |
|  <br />im_eorimage          - bitwise eor of two images |
|  <br />im_eorimageconst     - bitwise eor of an image with a constant |
|  <br />im_eorimage_vec      - bitwise eor of an image with a vector constant |
|  <br />im_shiftleft         - shift integer image n bits to left |
|  <br />im_shiftright        - shift integer image n bits to right |
| </div> |
| <!--l. 144--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.3: </span><span |
| class="content">Boolean functions</span></div><!--tex4ht:label?: x26-1090013 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.4 </span> <a |
| id="x26-1100004.2.4"></a>Colour</h4> |
| <!--l. 152--><p class="noindent" >See Figure <a |
| href="#x26-1100025">4.5<!--tex4ht:ref: fg:colour --></a>. |
| <!--l. 154--><p class="indent" > The colour functions can be divided into two main types. |
| First, functions to transform images between the different |
| colour spaces supported by VIPS: <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">RGB</span></span></span> (also referred to as |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">disp</span></span></span>), <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">sRGB</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">XYZ</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">Yxy</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">Lab</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">LabQ</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">LabS</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">LCh</span></span></span> and |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">UCS</span></span></span>), and second, functions for calculating colour |
| difference metrics. Figure <a |
| href="#x26-1100014">4.4<!--tex4ht:ref: fg:convert --></a> shows how the VIPS colour |
| spaces interconvert. |
| |
| |
| |
| |
| <!--l. 163--><p class="indent" > <a |
| id="x26-1100014"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="center" |
| > |
| <!--l. 163--><p class="noindent" > |
| |
| <!--l. 163--><p class="noindent" ><img |
| src="figs/interconvert.png" alt="PIC" |
| ></div> |
| <br /> <div class="caption" |
| ><span class="id">Figure 4.4: </span><span |
| class="content">VIPS colour space conversion</span></div><!--tex4ht:label?: x26-1100014 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <!--l. 168--><p class="indent" > The colour spaces supported by VIPS are: |
| <dl class="description"><dt class="description"> |
| <span |
| class="pcrb7t-">LabQ</span> </dt><dd |
| class="description">This is the principal VIPS colorimetric storage |
| format. See the man page for <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_LabQ2Lab()</span></span></span> |
| for an explanation. You cannot perform |
| calculations on <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">LabQ</span></span></span> images. They are for storage |
| only. Also refered to as <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">LABPACK</span></span></span>. |
| </dd><dt class="description"> |
| <span |
| class="pcrb7t-">LabS</span> </dt><dd |
| class="description">This format |
| represents coordinates in <span |
| class="ptmri7t-">CIE</span><span |
| class="ptmri7t-"> </span><span |
| class="cmmi-10">L</span><span |
| class="cmsy-7">*</span><span |
| class="cmmi-10">a</span><span |
| class="cmsy-7">*</span><span |
| class="cmmi-10">b</span><span |
| class="cmsy-7">*</span> space as a |
| three- band <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_SHORT</span></span></span> image, scaled |
| to fit the full range of bits. It is the best format for |
| computation, being relatively compact, quick, and |
| accurate. Colour values expressed in this way are |
| hard to visualise. |
| </dd><dt class="description"> |
| <span |
| class="pcrb7t-">Lab</span> </dt><dd |
| class="description"><span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">Lab</span></span></span> colourspace represents <span |
| class="ptmri7t-">CIE</span><span |
| class="ptmri7t-"> </span><span |
| class="cmmi-10">L</span><span |
| class="cmsy-7">*</span><span |
| class="cmmi-10">a</span><span |
| class="cmsy-7">*</span><span |
| class="cmmi-10">b</span><span |
| class="cmsy-7">*</span> colour |
| values with a three-band <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_FLOAT</span></span></span> |
| image. This is the simplest format for general |
| work: adding the constant 50 to the L channel, for |
| example, has the expected result. |
| </dd><dt class="description"> |
| <span |
| class="pcrb7t-">XYZ</span> </dt><dd |
| class="description"><span |
| class="ptmri7t-">CIE XYZ </span>colour space represented as a three-band |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_FLOAT</span></span></span> image. |
| </dd><dt class="description"> |
| <span |
| class="pcrb7t-">XYZ</span> </dt><dd |
| class="description"><span |
| class="ptmri7t-">CIE Yxy </span>colour space represented as a three-band |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_FLOAT</span></span></span> image. |
| </dd><dt class="description"> |
| <span |
| class="pcrb7t-">RGB</span> </dt><dd |
| class="description">(also refered to as <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">disp</span></span></span>) This format is |
| similar to the RGB colour systems used in |
| other packages. If you want to export your |
| image to a PC, for example, convert your |
| colorimetric image to <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">RGB</span></span></span>, then turn it to TIFF |
| with <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_vips2tiff()</span></span></span>. You need to supply a |
| structure which characterises your display. See the |
| manual page for <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_col_XYZ2rgb()</span></span></span> for hints |
| on these guys. |
| <!--l. 205--><p class="noindent" >VIPS also supports <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">sRGB</span></span></span>. This is a version |
| of RGB with a carefully defined and standard |
| conversion from XYZ. See: |
| <div class="verbatim" id="verbatim-180"> |
| http://www.color.org/ |
| </div> |
| <!--l. 210--><p class="nopar" > |
| </dd><dt class="description"> |
| <span |
| class="pcrb7t-">LCh</span> </dt><dd |
| class="description">Like <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">Lab</span></span></span>, but rectangular <span |
| class="cmmi-10">ab </span>coordinates are replaced |
| with polar <span |
| class="cmmi-10">Ch </span>(Chroma and hue) coordinates. Hue |
| angles are expressed in degrees. |
| </dd><dt class="description"> |
| <span |
| class="pcrb7t-">UCS</span> </dt><dd |
| class="description">A colour space based on the CMC(1:1) colour |
| difference measurement. This is a highly uniform |
| colour space, much better than <span |
| class="ptmri7t-">CIE</span><span |
| class="ptmri7t-"> </span><span |
| class="cmmi-10">L</span><span |
| class="cmsy-7">*</span><span |
| class="cmmi-10">a</span><span |
| class="cmsy-7">*</span><span |
| class="cmmi-10">b</span><span |
| class="cmsy-7">*</span> for |
| expressing small differences. Conversions to and from |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">UCS</span></span></span> are extremely slow. |
| </dd></dl> |
| <!--l. 223--><p class="indent" > All VIPS colourspaces assume a D65 illuminant. |
| <!--l. 225--><p class="indent" > The colour-difference functions calculate either <span |
| class="cmr-10">Δ</span><span |
| class="cmmi-10">E</span> |
| <span |
| class="ptmri7t-">CIE</span><span |
| class="ptmri7t-"> </span><span |
| class="cmmi-10">L</span><span |
| class="cmsy-7">*</span><span |
| class="cmmi-10">a</span><span |
| class="cmsy-7">*</span><span |
| class="cmmi-10">b</span><span |
| class="cmsy-7">*</span> (1976 or 2000) or <span |
| class="cmr-10">Δ</span><span |
| class="cmmi-10">E </span>CMC(1:1) on two |
| images in <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">Lab</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">XYZ</span></span></span> or <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">disp</span></span></span> colour space. |
| |
| |
| |
| <!--l. 230--><p class="indent" > <a |
| id="x26-1100025"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-181"> |
| $ vips --list colour |
|  <br />im_LCh2Lab           - convert LCh to Lab |
|  <br />im_LCh2UCS           - convert LCh to UCS |
|  <br />im_Lab2LCh           - convert Lab to LCh |
|  <br />im_Lab2LabQ          - convert Lab to LabQ |
|  <br />im_Lab2LabS          - convert Lab to LabS |
|  <br />im_Lab2UCS           - convert Lab to UCS |
|  <br />im_Lab2XYZ           - convert D65 Lab to XYZ |
|  <br />im_Lab2XYZ_temp      - convert Lab to XYZ, with a specified colour temperature |
|  <br />im_Lab2disp          - convert Lab to displayable |
|  <br />im_LabQ2LabS         - convert LabQ to LabS |
|  <br />im_LabQ2Lab          - convert LabQ to Lab |
|  <br />im_LabQ2XYZ          - convert LabQ to XYZ |
|  <br />im_LabQ2disp         - convert LabQ to displayable |
|  <br />im_LabS2LabQ         - convert LabS to LabQ |
|  <br />im_LabS2Lab          - convert LabS to Lab |
|  <br />im_UCS2LCh           - convert UCS to LCh |
|  <br />im_UCS2Lab           - convert UCS to Lab |
|  <br />im_UCS2XYZ           - convert UCS to XYZ |
|  <br />im_XYZ2Lab           - convert D65 XYZ to Lab |
|  <br />im_XYZ2Lab_temp      - convert XYZ to Lab, with a specified colour temperature |
|  <br />im_XYZ2UCS           - convert XYZ to UCS |
|  <br />im_XYZ2Yxy           - convert XYZ to Yxy |
|  <br />im_XYZ2disp          - convert XYZ to displayble |
|  <br />im_XYZ2sRGB          - convert XYZ to sRGB |
|  <br />im_Yxy2XYZ           - convert Yxy to XYZ |
|  <br />im_dE00_fromLab      - calculate delta-E CIE2000 for two Lab images |
|  <br />im_dECMC_fromLab     - calculate delta-E CMC(1:1) for two Lab images |
|  <br />im_dECMC_fromdisp    - calculate delta-E CMC(1:1) for two displayable images |
|  <br />im_dE_fromLab        - calculate delta-E for two Lab images |
|  <br />im_dE_fromXYZ        - calculate delta-E for two XYZ images |
|  <br />im_dE_fromdisp       - calculate delta-E for two displayable images |
|  <br />im_disp2Lab          - convert displayable to Lab |
|  <br />im_disp2XYZ          - convert displayable to XYZ |
|  <br />im_float2rad         - convert float to Radiance packed |
|  <br />im_icc_ac2rc         - convert LAB from AC to RC using an ICC profile |
|  <br />im_icc_export        - convert a float LAB to an 8-bit device image with an ICC profile |
|  <br />im_icc_export_depth  - convert a float LAB to device space with an ICC profile |
|  <br />im_icc_import        - convert a device image to float LAB with an ICC profile |
|  <br />im_icc_import_embedded - convert a device image to float LAB using the embedded profile |
|  <br />im_icc_present       - test for presence of ICC library |
|  <br />im_icc_transform     - convert between two device images with a pair of ICC profiles |
|  <br />im_lab_morph         - morph colourspace of a LAB image |
|  <br />im_rad2float         - convert Radiance packed to float |
|  <br />im_sRGB2XYZ          - convert sRGB to XYZ |
| </div> <!--l. 276--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.5: </span><span |
| class="content">Colour functions</span></div><!--tex4ht:label?: x26-1100025 --> |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.5 </span> <a |
| id="x26-1110004.2.5"></a>Conversion</h4> |
| <!--l. 283--><p class="noindent" >See Figure <a |
| href="#x26-1110016">4.6<!--tex4ht:ref: fg:conversion --></a>. |
| <!--l. 285--><p class="indent" > These functions may be split into three broad groups: |
| functions which convert between the VIPS numeric formats |
| (<span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_clip2fmt()</span></span></span>, for example, converts an image of |
| any type to the specified <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT</span></span></span>), functions |
| supporting complex arithmetic (<span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_c2amph()</span></span></span>, for |
| example, converts a complex image from rectangular to |
| polar co ordinates) and functions which perform some |
| simple geometric conversion (<span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_extract()</span></span></span> forms a |
| sub-image). |
| <!--l. 293--><p class="indent" > <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">gbandjoin</span></span></span> and the C function <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_gbandjoin()</span></span></span> |
| will do a bandwise join of many images at the same time. |
| See the manual pages. |
| |
| |
| |
| |
| <!--l. 297--><p class="indent" > <a |
| id="x26-1110016"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-182"> |
| $ vips --list conversion |
|  <br />im_bandjoin          - bandwise join of two images |
|  <br />im_bernd             - extract from pyramid as jpeg |
|  <br />im_black             - generate black image |
|  <br />im_c2amph            - convert real and imaginary to phase and amplitude |
|  <br />im_c2imag            - extract imaginary part of complex image |
|  <br />im_c2ps              - find power spectrum of complex image |
|  <br />im_c2real            - extract real part of complex image |
|  <br />im_c2rect            - convert phase and amplitude to real and imaginary |
|  <br />im_clip2c            - convert to signed 8-bit integer |
|  <br />im_clip2cm           - convert to complex |
|  <br />im_clip2d            - convert to double-precision float |
|  <br />im_clip2dcm          - convert to double complex |
|  <br />im_clip2f            - convert to single-precision float |
|  <br />im_clip2fmt          - convert image format to ofmt |
|  <br />im_clip2i            - convert to signed 32-bit integer |
|  <br />im_clip2s            - convert to signed 16-bit integer |
|  <br />im_clip2ui           - convert to unsigned 32-bit integer |
|  <br />im_clip2us           - convert to unsigned 16-bit integer |
|  <br />im_clip              - convert to unsigned 8-bit integer |
|  <br />im_copy              - copy image |
|  <br />im_copy_morph        - copy image, setting pixel layout |
|  <br />im_copy_swap         - copy image, swapping byte order |
|  <br />im_copy_set          - copy image, setting informational fields |
|  <br />im_copy_set_meta     - copy image, setting a meta field |
|  <br />im_extract_area      - extract area |
|  <br />im_extract_areabands - extract area and bands |
|  <br />im_extract_band      - extract band |
|  <br />im_extract_bands     - extract several bands |
|  <br />im_extract           - extract area/band |
|  <br />im_falsecolour       - turn luminance changes into chrominance changes |
|  <br />im_fliphor           - flip image left-right |
|  <br />im_flipver           - flip image top-bottom |
|  <br />im_gbandjoin         - bandwise join of many images |
|  <br />im_grid              - chop a tall thin image into a grid of images |
|  <br />im_insert            - insert sub-image into main image at position |
|  <br />im_insert_noexpand   - insert sub-image into main image at position, no expansion |
|  <br />im_lrjoin            - join two images left-right |
|  <br />im_mask2vips         - convert DOUBLEMASK to VIPS image |
|  <br />im_msb               - convert to uchar by discarding bits |
|  <br />im_msb_band          - convert to single band uchar by discarding bits |
|  <br />im_print             - print string to stdout |
|  <br />im_recomb            - linear recombination with mask |
|  <br />im_replicate         - replicate an image horizontally and vertically |
|  <br />im_ri2c              - join two non-complex images to form complex |
| </div> <!--l. 343--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.6: </span><span |
| class="content">Conversion functions</span></div><!--tex4ht:label?: x26-1110016 --> |
| |
| |
| |
| </div><hr class="endfloat" /> |
| |
| |
| |
| |
| <!--l. 349--><p class="indent" > <a |
| id="x26-1110027"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-183"> |
| im_rot180            - rotate image 180 degrees |
|  <br />im_rot270            - rotate image 270 degrees clockwise |
|  <br />im_rot90             - rotate image 90 degrees clockwise |
|  <br />im_scale             - scale image linearly to fit range 0-255 |
|  <br />im_scaleps           - logarithmic scale of image to fit range 0-255 |
|  <br />im_rightshift_size   - decrease size by a power-of-two factor |
|  <br />im_slice             - slice an image using two thresholds |
|  <br />im_subsample         - subsample image by integer factors |
|  <br />im_system            - run command on image |
|  <br />im_tbjoin            - join two images top-bottom |
|  <br />im_text              - generate text image |
|  <br />im_thresh            - slice an image at a threshold |
|  <br />im_vips2mask         - convert VIPS image to DOUBLEMASK |
|  <br />im_wrap              - shift image origin, wrapping at sides |
|  <br />im_zoom              - simple zoom of an image by integer factors |
| </div> |
| <!--l. 365--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.7: </span><span |
| class="content">Conversion functions (cont.)</span></div><!--tex4ht:label?: x26-1110027 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.6 </span> <a |
| id="x26-1120004.2.6"></a>Matricies</h4> |
| <!--l. 371--><p class="noindent" >See Figure <a |
| href="#x26-1120018">4.8<!--tex4ht:ref: fg:matricies --></a>. |
| <!--l. 373--><p class="indent" > VIPS uses matricies for morphological operations, for |
| convolutions, and for some colour-space conversions. There |
| are two types of matrix: integer (<span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">INTMASK</span></span></span>) and double |
| precision floating point (<span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">DOUBLEMASK</span></span></span>). |
| <!--l. 377--><p class="indent" > For convenience, both types are stored in files as ASCII. |
| The first line of the file should start with the matrix |
| dimensions, width first, then on the same line an optional |
| scale and offset. The two size fields should be integers; the |
| scale and offset may be floats. Subsequent lines should |
| contain the matrix elements, one row per line. The scale |
| and offset are the conventional ones used to represent |
| non-integer values in convolution masks — in other |
| words: |
| <center class="par-math-display" > |
| <img |
| src="vipsmanual0x.png" alt=" value |
| result =-scale + of fset |
| " class="par-math-display" ></center> |
| <!--l. 387--><p class="nopar" > |
| <!--l. 389--><p class="indent" > If the scale and offset are missing, they default to 1.0 and |
| 0.0. See the sections on convolution for more on the use of |
| these fields. So as an example, a 4 by 4 identity matrix |
| would be stored as: |
| <div class="verbatim" id="verbatim-184"> |
| 4 4 |
|  <br />1 0 0 0 |
|  <br />0 1 0 0 |
|  <br />0 0 1 0 |
|  <br />0 0 0 1 |
| </div> |
| <!--l. 399--><p class="nopar" > |
| <!--l. 401--><p class="indent" > And a 3 by 3 mask for block averaging with convolution |
| might be stored as: |
| |
| |
| |
| <div class="verbatim" id="verbatim-185"> |
| 3 3 9 0 |
|  <br />1 1 1 |
|  <br />1 1 1 |
|  <br />1 1 1 |
| </div> |
| <!--l. 408--><p class="nopar" > |
| <!--l. 410--><p class="noindent" >(in other words, sum all the pels in every 3 by 3 area, and |
| divide by 9). |
| <!--l. 413--><p class="indent" > This matrix contains only integer elements and so could |
| be used as an argument to functions expecting both |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">INTMASK</span></span></span> and <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">DOUBLEMASK</span></span></span> matricies. However, masks |
| containing floating-point values (such as the output of |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_matinv()</span></span></span>) can only be used as arguments to |
| functions expecting <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">DOUBLEMASK</span></span></span>s. |
| <!--l. 419--><p class="indent" > A set of functions for mask input and output are also |
| available for C-programmers — see the manual pages for |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_read_dmask()</span></span></span>. For other matrix functions, |
| see also the convolution sections and the arithmetic |
| sections. |
| |
| |
| |
| |
| <!--l. 425--><p class="indent" > <a |
| id="x26-1120018"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-186"> |
| $ vips --list matrix |
|  <br />im_matcat          - append matrix in2 to the end of matrix in1 |
|  <br />im_matinv          - invert matrix |
|  <br />im_matmul          - multiply matrix in1 by matrix in2 |
|  <br />im_mattrn          - transpose matrix |
| </div> |
| <!--l. 431--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.8: </span><span |
| class="content">Matrix functions</span></div><!--tex4ht:label?: x26-1120018 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.7 </span> <a |
| id="x26-1130004.2.7"></a>Convolution</h4> |
| <!--l. 438--><p class="noindent" >See Figure <a |
| href="#x26-1130019">4.9<!--tex4ht:ref: fg:convolution --></a>. |
| <!--l. 440--><p class="indent" > The functions available in the convolution package can be |
| split into five main groups. |
| <!--l. 443--><p class="indent" > First, are the convolution functions. The most useful |
| function is <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_conv()</span></span></span> which will convolve any |
| non-complex type with an <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">INTMASK</span></span></span> matrix. The output |
| image will have the same size, type, and number of bands as |
| the input image. Of the other <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_conv()</span></span></span> functions, |
| functions whose name ends in <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">_raw</span></span></span> do not add a black |
| border around the output image, functions ending in <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">f</span></span></span> use |
| a <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">DOUBLEMASK</span></span></span> matrix and write float (or double) |
| output, and functions containing <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">sep</span></span></span> are for seperable |
| convolutions. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_compass()</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_lindetect()</span></span></span> |
| and <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_gradient()</span></span></span> convolve with rotating masks. |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_embed()</span></span></span> is used by the convolution functions to add |
| the border to the output. |
| <!--l. 454--><p class="indent" > Next, are the build functions. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_gauss_⋆mask()</span></span></span> and |
| its ilk generate gaussian masks, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_log_⋆mask()</span></span></span> |
| generate logs of Laplacians. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_addgnoise()</span></span></span> and |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_gaussnoise()</span></span></span> create or add gaussian noise to an |
| image. |
| <!--l. 459--><p class="indent" > Two functions do correlation: <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_fastcor()</span></span></span> does a |
| quick and dirty correlation, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_spcor()</span></span></span> calculates true |
| spatial correlation, and is rather slow. |
| <!--l. 463--><p class="indent" > Some functions are provided for analysing images: |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_zerox()</span></span></span> counts zero-crossing points in an image, |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_mpercent()</span></span></span> finds a threshold that will isolate a |
| percentage of points in an image. |
| <!--l. 467--><p class="indent" > Finally, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_resize_linear()</span></span></span> and <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_shrink()</span></span></span> |
| do as you would expect. |
| |
| |
| |
| |
| <!--l. 471--><p class="indent" > <a |
| id="x26-1130019"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-187"> |
| $ vips --list convolution |
|  <br />im_addgnoise         - add gaussian noise with mean 0 and std. dev. sigma |
|  <br />im_compass           - convolve with 8-way rotating integer mask |
|  <br />im_contrast_surface  - find high-contrast points in an image |
|  <br />im_contrast_surface_raw - find high-contrast points in an image |
|  <br />im_conv              - convolve |
|  <br />im_conv_raw          - convolve, no border |
|  <br />im_convf             - convolve, with DOUBLEMASK |
|  <br />im_convf_raw         - convolve, with DOUBLEMASK, no border |
|  <br />im_convsep           - seperable convolution |
|  <br />im_convsep_raw       - seperable convolution, no border |
|  <br />im_convsepf          - seperable convolution, with DOUBLEMASK |
|  <br />im_convsepf_raw      - seperable convolution, with DOUBLEMASK, no border |
|  <br />im_convsub           - convolve uchar to uchar, sub-sampling by xskip, yskip |
|  <br />im_dmask_xsize       - horizontal size of a doublemask |
|  <br />im_dmask_ysize       - vertical size of a doublemask |
|  <br />im_embed             - embed in within a set of borders |
|  <br />im_fastcor           - fast correlate in2 within in1 |
|  <br />im_fastcor_raw       - fast correlate in2 within in1, no border |
|  <br />im_gauss_dmask       - generate gaussian DOUBLEMASK |
|  <br />im_gauss_imask       - generate gaussian INTMASK |
|  <br />im_gauss_imask_sep   - generate separable gaussian INTMASK |
|  <br />im_gaussnoise        - generate image of gaussian noise with specified statistics |
|  <br />im_grad_x            - horizontal difference image |
|  <br />im_grad_y            - vertical difference image |
|  <br />im_gradcor           - non-normalised correlation of gradient of in2 within in1 |
|  <br />im_gradcor_raw       - non-normalised correlation of gradient of in2 within in1, no padding |
|  <br />im_gradient          - convolve with 2-way rotating mask |
|  <br />im_imask_xsize       - horizontal size of an intmask |
|  <br />im_imask_ysize       - vertical size of an intmask |
|  <br />im_rank_image        - point-wise pixel rank |
|  <br />im_lindetect         - convolve with 4-way rotating mask |
|  <br />im_log_dmask         - generate laplacian of gaussian DOUBLEMASK |
|  <br />im_log_imask         - generate laplacian of gaussian INTMASK |
|  <br />im_maxvalue          - point-wise maximum value |
|  <br />im_mpercent          - find threshold above which there are percent values |
|  <br />im_phasecor_fft      - non-normalised correlation of gradient of in2 within in1 |
|  <br />im_rank              - rank filter nth element of xsize/ysize window |
|  <br />im_rank_raw          - rank filter nth element of xsize/ysize window, no border |
|  <br />im_read_dmask        - read matrix of double from file |
|  <br />im_resize_linear     - resize to X by Y pixels with linear interpolation |
|  <br />im_rotate_dmask45    - rotate DOUBLEMASK clockwise by 45 degrees |
|  <br />im_rotate_dmask90    - rotate DOUBLEMASK clockwise by 90 degrees |
|  <br />im_rotate_imask45    - rotate INTMASK clockwise by 45 degrees |
|  <br />im_rotate_imask90    - rotate INTMASK clockwise by 90 degrees |
|  <br />im_sharpen           - sharpen high frequencies of L channel of LabQ <br />im_shrink            - shrink image by xfac, yfac times |
|  <br />im_spcor             - normalised correlation of in2 within in1 |
|  <br />im_spcor_raw         - normalised correlation of in2 within in1, no black padding |
|  <br />im_stretch3          - stretch 3%, sub-pixel displace by xdisp/ydisp |
|  <br />im_zerox             - find +ve or -ve zero crossings in image |
| </div> |
| <!--l. 523--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.9: </span><span |
| class="content">Convolution functions</span></div><!--tex4ht:label?: x26-1130019 --> |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.8 </span> <a |
| id="x26-1140004.2.8"></a>In-place operations</h4> |
| <!--l. 531--><p class="noindent" >See Figure <a |
| href="#x26-11400110">4.10<!--tex4ht:ref: fg:inplace --></a>. |
| <!--l. 533--><p class="indent" > A few of the in-place operations are available from the |
| command-line. Most are not. |
| |
| |
| |
| |
| <!--l. 537--><p class="indent" > <a |
| id="x26-11400110"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-188"> |
| $ vips --list inplace |
|  <br />im_circle          - plot circle on image |
|  <br />im_flood_blob_copy - flood while pixel == start pixel |
|  <br />im_insertplace     - draw image sub inside image main at position (x,y) |
|  <br />im_line            - draw line between points (x1,y1) and (x2,y2) |
|  <br />im_lineset         - draw line between points (x1,y1) and (x2,y2) |
| </div> |
| <!--l. 544--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.10: </span><span |
| class="content">In-place operations</span></div><!--tex4ht:label?: x26-11400110 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.9 </span> <a |
| id="x26-1150004.2.9"></a>Frequency filtering</h4> |
| <!--l. 551--><p class="noindent" >See Figure <a |
| href="#x26-11500111">4.11<!--tex4ht:ref: fg:freq --></a>. |
| <!--l. 553--><p class="indent" > The basic Fourier functions are <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_fwfft()</span></span></span> and |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_invfft()</span></span></span>, which calculate the fast-fourier transform |
| and inverse transform of an image. Also <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_invfftr()</span></span></span>, |
| which just returns the real part of the inverse transform. The |
| Fourier image has its origin at pel (0,0) — for viewing, use |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_rotquad()</span></span></span> to move the origin to the centre of the |
| image. |
| <!--l. 561--><p class="indent" > Once an image is in the frequency domain, it can be |
| filtered by multiplying it with a mask image. The VIPS |
| mask generator is <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_create_fmask()</span></span></span> see the manual |
| page for details of the arguments, but it will create low pass, |
| high pass, ring pass and band pass filters, which may each |
| be ideal, Gaussian or Butterworth. There is also a fractal |
| mask option. |
| <!--l. 567--><p class="indent" > The other functions in the package build on these base |
| facilities. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_freqflt()</span></span></span> transforms an input image |
| to Fourier space, multiplies it by a mask image, and |
| transforms it back again. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_flt_image_freq()</span></span></span> will |
| create a mask image of the correct size for you, and call |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_freqflt()</span></span></span>. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_disp_ps()</span></span></span> will call the right |
| combinations of functions to make a displayable power |
| spectrum for an image. |
| |
| |
| |
| |
| <!--l. 576--><p class="indent" > <a |
| id="x26-11500111"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-189"> |
| $ vips --list freq_filt |
|  <br />im_create_fmask    - create frequency domain filter mask |
|  <br />im_disp_ps         - make displayable power spectrum |
|  <br />im_flt_image_freq  - frequency domain filter image |
|  <br />im_fractsurf       - generate a fractal surface of given dimension |
|  <br />im_freqflt         - frequency-domain filter of in with mask |
|  <br />im_fwfft           - forward fast-fourier transform |
|  <br />im_rotquad         - rotate image quadrants to move origin to centre |
|  <br />im_invfft          - inverse fast-fourier transform |
|  <br />im_invfftr         - real part of inverse fast-fourier transform |
| </div> |
| <!--l. 587--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.11: </span><span |
| class="content">Fourier functions</span></div><!--tex4ht:label?: x26-11500111 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.10 </span> <a |
| id="x26-1160004.2.10"></a>Histograms and LUTs</h4> |
| <!--l. 594--><p class="noindent" >See Figure <a |
| href="#x26-11600112">4.12<!--tex4ht:ref: fg:hist --></a>. |
| <!--l. 596--><p class="indent" > VIPS represents histograms and look-up tables in the |
| same way — as images. |
| <!--l. 598--><p class="indent" > They should have either <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">Xsize</span></span></span> or <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">Ysize</span></span></span> set to 1, and |
| the other dimension set to the number of elements in the |
| table. The table can be of any size, have any band format, |
| and have any number of bands. |
| <!--l. 602--><p class="indent" > Use <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_histgr()</span></span></span> to find the histogram of an |
| image. Use <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_histnD()</span></span></span> to find the n-dimensional |
| histogram of an n-band image. Perform operations on |
| histograms with <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_histcum()</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_histnorm()</span></span></span>, |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_histspec()</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_invertlut()</span></span></span>. Visualise |
| histograms with <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_histplot()</span></span></span>. Use a histogram (or |
| LUT) to transform an image with <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_maplut()</span></span></span>. Build a |
| histogram from scratch with <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_identity()</span></span></span> or |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_identity_ushort()</span></span></span>. |
| <!--l. 610--><p class="indent" > Use <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_lhist⋆()</span></span></span> for local histogram equalisation, |
| and <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_stdif⋆()</span></span></span> for statisticaol differencing. The |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_tone_⋆()</span></span></span> functions are for operations on the L |
| channel of a LAB image. Other functions are useful |
| combinations of these basic operations. |
| |
| |
| |
| |
| <!--l. 616--><p class="indent" > <a |
| id="x26-11600112"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-190"> |
| $ vips --list histograms_lut |
|  <br />im_gammacorrect      - gamma-correct image |
|  <br />im_heq               - histogram-equalise image |
|  <br />im_hist              - find and graph histogram of image |
|  <br />im_histcum           - turn histogram to cumulative histogram |
|  <br />im_histeq            - form histogram equalistion LUT |
|  <br />im_histgr            - find histogram of image |
|  <br />im_histnD            - find 1D, 2D or 3D histogram of image |
|  <br />im_histnorm          - form normalised histogram |
|  <br />im_histplot          - plot graph of histogram |
|  <br />im_histspec          - find histogram which will make pdf of in match ref |
|  <br />im_hsp               - match stats of in to stats of ref |
|  <br />im_identity          - generate identity histogram |
|  <br />im_identity_ushort   - generate ushort identity histogram |
|  <br />im_ismonotonic       - test LUT for monotonicity |
|  <br />im_lhisteq           - local histogram equalisation |
|  <br />im_lhisteq_raw       - local histogram equalisation, no border |
|  <br />im_invertlut         - generate correction table from set of measures |
|  <br />im_buildlut          - generate LUT table from set of x/y positions |
|  <br />im_maplut            - map image through LUT |
|  <br />im_project           - find horizontal and vertical projections of an image |
|  <br />im_stdif             - statistical differencing |
|  <br />im_stdif_raw         - statistical differencing, no border |
|  <br />im_tone_analyse      - analyse in and create LUT for tone adjustment |
|  <br />im_tone_build        - create LUT for tone adjustment of LabS images |
|  <br />im_tone_build_range  - create LUT for tone adjustment |
|  <br />im_tone_map          - map L channel of LabS or LabQ image through LUT |
| </div> |
| <!--l. 644--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.12: </span><span |
| class="content">Histogram/LUT functions</span></div><!--tex4ht:label?: x26-11600112 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.11 </span> <a |
| id="x26-1170004.2.11"></a>Morphology</h4> |
| <!--l. 651--><p class="noindent" >See Figure <a |
| href="#x26-11700113">4.13<!--tex4ht:ref: fg:morph --></a>. |
| <!--l. 653--><p class="indent" > The morphological functions are used on one-band |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">IM_BANDFMT_UCHAR</span></span></span> binary images (images containing |
| only zero and not-zero). They 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. |
| <!--l. 661--><p class="indent" > If you combine the morphological operators with |
| the mask rotators (<span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_rotate_imask45()</span></span></span>, 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. |
| <!--l. 667--><p class="indent" > Beware that VIPS reverses the usual image processing |
| convention, by assuming white objects on a black |
| background. |
| <!--l. 670--><p class="indent" > 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: |
| <div class="verbatim" id="verbatim-191"> |
| 3 3 |
|  <br />128 255 128 |
|  <br />255 0   255 |
|  <br />128 255 128 |
| </div> |
| <!--l. 680--><p class="nopar" > |
| <!--l. 682--><p class="noindent" >applied to an image with <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_erode()</span></span></span>, will find all black |
| pixels 4-way connected with white pixels. Essentially, |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_dilate()</span></span></span> sets pixels in the output if any part of the |
| mask matches, whereas <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_erode()</span></span></span> sets pixels only if all |
| of the mask matches. |
| <!--l. 688--><p class="indent" > The <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">_raw()</span></span></span> version of the functions do not add a |
| black border to the output. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_cntlines()</span></span></span> and |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_profile</span></span></span> are occasionally useful for analysing |
| results. |
| <!--l. 692--><p class="indent" > See the boolean operations <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_and()</span></span></span>, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_or()</span></span></span> and |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_eor()</span></span></span> for analogues of the usual set difference and set |
| union operations. |
| |
| |
| |
| <!--l. 697--><p class="indent" > <a |
| id="x26-11700113"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-192"> |
| $ vips --list morphology |
|  <br />im_cntlines        - count horizontal or vertical lines |
|  <br />im_dilate          - dilate image with mask, adding a black border |
|  <br />im_dilate_raw      - dilate image with mask |
|  <br />im_erode           - erode image with mask, adding a black border |
|  <br />im_erode_raw       - erode image with mask |
|  <br />im_profile         - find first horizontal/vertical edge |
| </div> |
| <!--l. 705--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.13: </span><span |
| class="content">Morphological functions</span></div><!--tex4ht:label?: x26-11700113 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.12 </span> <a |
| id="x26-1180004.2.12"></a>Mosaicing</h4> |
| <!--l. 712--><p class="noindent" >See Figure <a |
| href="#x26-11800114">4.14<!--tex4ht:ref: fg:mosaicing --></a>. |
| <!--l. 714--><p class="indent" > These functions are useful for joining many small images |
| together to make one large image. They can cope with |
| unstable contrast, and arbitary sub-image layout, but will |
| not do any geometric correction. The mosaicing functions |
| can be grouped into layers: |
| <!--l. 719--><p class="indent" > The lowest level functions are <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_correl()</span></span></span>. and |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_affine()</span></span></span>. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_correl()</span></span></span> searches a large image |
| for a small sub-image, returning the position of the best |
| sub-image match. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_affine()</span></span></span> performs a general |
| affine transform on an image: that is, any transform in |
| which parallel lines remain parallel. |
| <!--l. 725--><p class="indent" > Next, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_lrmerge()</span></span></span> and <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_tbmerge()</span></span></span> blend two |
| images together left-right or up-down. |
| <!--l. 728--><p class="indent" > Next up are <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_lrmosaic()</span></span></span> and <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_tbmosaic()</span></span></span>. |
| These use the two low-level merge operations to join two |
| images given just an approximate overlap as a start point. |
| Optional extra parameters let you do ’balancing’ too: if |
| your images have come from a source where there |
| is no precise control over the exposure (for example, |
| images from a tube camera, or a set of images scanned |
| from photographic sources), <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_lrmosaic()</span></span></span> and |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_tbmosaic()</span></span></span> will adjust the contrast of the left image |
| to match the right, the right to the left, or both to some |
| middle value. |
| <!--l. 737--><p class="indent" > The functions <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_lrmosaic1()</span></span></span> and <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_tbmosaic1()</span></span></span> |
| are first-order analogues of the basic mosaic functions: |
| they take two tie-points and use them to rotate and |
| scale the right-hand or bottom image before starting to |
| join. |
| <!--l. 741--><p class="indent" > Finally, <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_global_balance()</span></span></span> can be used to |
| re-balance a mosaic which has been assembled with |
| these functions. It will generally do a better job than the |
| low-level balancer built into <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_lrmosaic()</span></span></span> and |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_tbmosaic()</span></span></span>. See the man page. <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_remosaic()</span></span></span> |
| uses the same techniques, but will reassemble the image |
| from a different set of source images. |
| |
| |
| |
| |
| <!--l. 749--><p class="indent" > <a |
| id="x26-11800114"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-193"> |
| $ vips --list mosaicing |
|  <br />im_align_bands       - align the bands of an image |
|  <br />im_correl            - search area around sec for match for area around ref |
|  <br />im__find_lroverlap   - search for left-right overlap of ref and sec |
|  <br />im__find_tboverlap   - search for top-bottom overlap of ref and sec |
|  <br />im_global_balance    - automatically rebuild mosaic with balancing |
|  <br />im_global_balancef   - automatically rebuild mosaic with balancing, float output |
|  <br />im_lrmerge           - left-right merge of in1 and in2 |
|  <br />im_lrmerge1          - first-order left-right merge of ref and sec |
|  <br />im_lrmosaic          - left-right mosaic of ref and sec |
|  <br />im_lrmosaic1         - first-order left-right mosaic of ref and sec |
|  <br />im_match_linear      - resample ref so that tie-points match |
|  <br />im_match_linear_search - search sec, then resample so that tie-points match |
|  <br />im_maxpos_subpel     - subpixel position of maximum of (phase correlation) image |
|  <br />im_remosaic          - automatically rebuild mosaic with new files |
|  <br />im_tbmerge           - top-bottom merge of in1 and in2 |
|  <br />im_tbmerge1          - first-order top-bottom merge of in1 and in2 |
|  <br />im_tbmosaic          - top-bottom mosaic of in1 and in2 |
|  <br />im_tbmosaic1         - first-order top-bottom mosaic of ref and sec |
| </div> |
| <!--l. 769--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.14: </span><span |
| class="content">Mosaic functions</span></div><!--tex4ht:label?: x26-11800114 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.13 </span> <a |
| id="x26-1190004.2.13"></a>CImg functions</h4> |
| <!--l. 776--><p class="noindent" >See Figure <a |
| href="#x26-11900115">4.15<!--tex4ht:ref: fg:cimg --></a>. |
| <!--l. 778--><p class="indent" > These operations wrap the anisotropic blur function from |
| the CImg library. They are useful for removing noise from |
| images. |
| |
| |
| |
| |
| <!--l. 782--><p class="indent" > <a |
| id="x26-11900115"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-194"> |
| $ vips --list cimg |
|  <br />im_greyc           - noise-removing filter |
|  <br />im_greyc_mask      - noise-removing filter, with a mask |
| </div> |
| <!--l. 786--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.15: </span><span |
| class="content">CImg functions</span></div><!--tex4ht:label?: x26-11900115 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.14 </span> <a |
| id="x26-1200004.2.14"></a>Other</h4> |
| <!--l. 793--><p class="noindent" >See Figure <a |
| href="#x26-12000116">4.16<!--tex4ht:ref: fg:other --></a>. |
| <!--l. 795--><p class="indent" > These functions generate various test images. You can |
| combine them with the arithmetic and rotate functions to |
| build more complicated images. |
| <!--l. 798--><p class="indent" > The <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">im_benchmark⋆()</span></span></span> operations are for testing the |
| VIPS SMP system. |
| |
| |
| |
| |
| <!--l. 801--><p class="indent" > <a |
| id="x26-12000116"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-195"> |
| $ vips --list other |
|  <br />im_benchmark       - do something complicated for testing |
|  <br />im_benchmark2      - do something complicated for testing |
|  <br />im_benchmarkn      - do something complicated for testing |
|  <br />im_eye             - generate IM_BANDFMT_UCHAR [0,255] frequency/amplitude image |
|  <br />im_grey            - generate IM_BANDFMT_UCHAR [0,255] grey scale image |
|  <br />im_feye            - generate IM_BANDFMT_FLOAT [-1,1] frequency/amplitude image |
|  <br />im_fgrey           - generate IM_BANDFMT_FLOAT [0,1] grey scale image |
|  <br />im_fzone           - generate IM_BANDFMT_FLOAT [-1,1] zone plate image |
|  <br />im_make_xy         - generate image with pixel value equal to coordinate |
|  <br />im_zone            - generate IM_BANDFMT_UCHAR [0,255] zone plate image |
| </div> |
| <!--l. 813--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.16: </span><span |
| class="content">Other functions</span></div><!--tex4ht:label?: x26-12000116 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.15 </span> <a |
| id="x26-1210004.2.15"></a>IO functions</h4> |
| <!--l. 820--><p class="noindent" >See Figure <a |
| href="#x26-12100117">4.17<!--tex4ht:ref: fg:io --></a>. |
| <!--l. 822--><p class="indent" > These functions are related to the image IO system. |
| |
| |
| |
| |
| <!--l. 825--><p class="indent" > <a |
| id="x26-12100117"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-196"> |
| $ vips --list iofuncs |
|  <br />im_binfile         - open a headerless binary file |
|  <br />im_cache           - cache results of an operation |
|  <br />im_guess_prefix    - guess install area |
|  <br />im_guess_libdir    - guess library area |
|  <br />im_header_get_type - return field type |
|  <br />im_header_int      - extract int fields from header |
|  <br />im_header_double   - extract double fields from header |
|  <br />im_header_string   - extract string fields from header |
|  <br />im_version         - VIPS version number |
|  <br />im_version_string  - VIPS version string |
| </div> |
| <!--l. 837--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.17: </span><span |
| class="content">IO functions</span></div><!--tex4ht:label?: x26-12100117 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.16 </span> <a |
| id="x26-1220004.2.16"></a>Format functions</h4> |
| <!--l. 844--><p class="noindent" >See Figure <a |
| href="#x26-12200118">4.18<!--tex4ht:ref: fg:format --></a>. |
| <!--l. 846--><p class="indent" > These functions convert to and from various image |
| formats. See <span |
| class="cmsy-10">ยง</span><a |
| href="vipsmanualse11.html#x17-740002.5">2.5<!--tex4ht:ref: sec:format --></a> for a nice API over these. VIPS can |
| read more than these formats, see the man page for |
| <span class="obeylines-h"><span class="verb"><span |
| class="pcrr7t-">VipsFormat</span></span></span>. |
| |
| |
| |
| |
| <!--l. 851--><p class="indent" > <a |
| id="x26-12200118"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-197"> |
| $ vips --list format |
|  <br />im_csv2vips          - read a file in csv format |
|  <br />im_jpeg2vips         - convert from jpeg |
|  <br />im_magick2vips       - load file with libMagick |
|  <br />im_png2vips          - convert PNG file to VIPS image |
|  <br />im_exr2vips          - convert an OpenEXR file to VIPS |
|  <br />im_ppm2vips          - read a file in pbm/pgm/ppm format |
|  <br />im_analyze2vips      - read a file in analyze format |
|  <br />im_tiff2vips         - convert TIFF file to VIPS image |
|  <br />im_vips2csv          - write an image in csv format |
|  <br />im_vips2jpeg         - convert to jpeg |
|  <br />im_vips2mimejpeg     - convert to jpeg as mime type on stdout |
|  <br />im_vips2png          - convert VIPS image to PNG file |
|  <br />im_vips2ppm          - write a file in pbm/pgm/ppm format |
|  <br />im_vips2tiff         - convert VIPS image to TIFF file |
| </div> |
| <!--l. 867--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.18: </span><span |
| class="content">Format functions</span></div><!--tex4ht:label?: x26-12200118 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <h4 class="subsectionHead"><span class="titlemark">4.2.17 </span> <a |
| id="x26-1230004.2.17"></a>Resample functions</h4> |
| <!--l. 874--><p class="noindent" >See Figure <a |
| href="#x26-12300119">4.19<!--tex4ht:ref: fg:resample --></a>. |
| <!--l. 876--><p class="indent" > These functions resample images with various |
| interpolators. |
| |
| |
| |
| |
| <!--l. 879--><p class="indent" > <a |
| id="x26-12300119"></a><hr class="float"><div class="float" |
| > |
| |
| |
| |
| |
| <div class="verbatim" id="verbatim-198"> |
| $ vips --list resample |
|  <br />im_affine            - affine transform |
|  <br />im_affinei           - affine transform |
|  <br />im_affinei_all       - affine transform of whole image |
|  <br />im_similarity_area   - output area xywh of similarity transformation |
|  <br />im_similarity        - similarity transformation |
| </div> |
| <!--l. 886--><p class="nopar" > |
| <br /><div class="caption" |
| ><span class="id">Figure 4.19: </span><span |
| class="content">Resample functions</span></div><!--tex4ht:label?: x26-12300119 --> |
| |
| |
| |
| |
| </div><hr class="endfloat" /> |
| <!--l. 91--><div class="crosslinks"><p class="noindent">[<a |
| href="vipsmanualse17.html" >prev</a>] [<a |
| href="vipsmanualse17.html#tailvipsmanualse17.html" >prev-tail</a>] [<a |
| href="vipsmanualse18.html" >front</a>] [<a |
| href="vipsmanualch4.html#vipsmanualse18.html" >up</a>] </p></div> |
| <!--l. 91--><p class="indent" > <a |
| id="tailvipsmanualse18.html"></a> |
| </body></html> |