Когда-нибудь можно будет сказать «cd /usr/ports/lang/ipl && make install clean && man ipl».
Но когда – не знаю.

[vladimir@sleepgate /usr/home/vladimir]$ ipl --help-ipl
The IPL script can contain:
        "global" section(s);
        definitions of IPL object(s);
        definitions of transform(s);
        definitions of function(s);
        "targets" section(s).

The main purpose of the "global" section is to define aliases. The initial
value of the random number generator can be specified there also. All "global"
sections parsed _before_ any "targets" section. The format of section:

global
{
        random_seed <integer>
        alias <old_token> <replacement>
        alias <old_token> <replacement>
        ...
}

where
        <integer> - initial value of random number generator;
        <old_token> - string to be replaced by <replacement>.

The purpose of "targets" section is to specify raster images and IPL
objects that have to be evaluated. Format of "targets" section:

targets
{
        <ipl_object_class> <object_name>
        <ipl_object_class> <object_name>
        ...
        output <file_name> <colorspace> <channel 0> ... <channel N>
        output <file_name> <colorspace> <channel 0> ... <channel N>
        ...
}

where
        <ipl_object_class> - class of IPL object (see below);
        <object_name> - unique identifier of object;
        <file_name> - name of output raster image file;
        <colorspace> - string that specifies how to handle color channels;
        <channel 0...N> - matrices containing data of color channels 0...N.

Internal format of the raster image file is determined by its extension.
Supported formats:
        Windows bitmap (*.bmp)
        TrueVision TARGA (*.tga)
        JPEG (*.jpg) (input only)

The <colorspace> parameter can be one of the following:
        "RGB": channels 0...3 represents red, green and blue;
        "RGBA": channels 0...4 represents red, green, blue and alpha;
        "CIE": channels 0...3 represents CIE X, Y and Z;
        "HSV": channels 0...3 represents hue, saturation, and value.

The format of IPL object definition:
<ipl_object_class> <object_name>
{
        state <state_field> <field_value>
        state <state_field> <field_value>
        ...
        <operation> <argument 1> ... <argument N>
        <operation> <argument 1> ... <argument N>
        ...
}

where
        <state_field> - name of state field to be set to <field_value>;
        <operation> - some operation on current data of object.

The <state_field> may be one of the following:
        "custom_width" (unsigned): width of matrix to be loaded/created;
        "custom_height" (unsigned): height of matrix to be loaded/created;
        "custom_size" (unsigned): size of vector to be created;
        "input_powers2" (boolean): resizing flag for matrix to be loaded;
        "input_square" (boolean): resizing flag for matrix to be loaded;
        "frequency_domain" (boolean): affects the interpretation of data;
        "pad_value" (real): padding value for "expand" / "expand_powers2".

The <ipl_object_class> may be one of the following:
        "matrix": 2D array of real numbers;
        "vector": array of real numbers;
        "decomposition": binary-tree image decomposition.

Valid operations for "matrix" class:
        copy <matrix src>: copies the data from matrix 'src';

        input <string image_name,channel_name>: loads data from image file;

        get <int dst_left,dst_top;matrix src;uint left,top,right,bottom>:
                copies contents of source rectangle [left...bottom]
                at [dst_left,dst_top] position of current matrix
                (may be useful for circular shifts of elements);

        set_elem <uint col,row;real value>: sets element at 'row' and 'col'
                to 'value';

        set_rect <uint left,top,right,bottom;real value>: sets all elements
                in specified rectangle to given 'value';

        shift <int shift_cols,shift_rows>: circular shift of elements;

        mirror <boolean mirror_x,mirror_y>: mirrors
                rows and / or columns of the matrix;

        transpose: transposes the matrix;

        expand <uint new_width,new_height>: expands or crops the matrix,
                padding it with state->pad_value if necessary;

        expand_powers2: expands the matrix in such a way that both width
                and height becomes powers of 2;

        resize <uint new_width,new_height>: resizes the matrix using
                subpixel-correct bilinear interpolation;

        save <string file_name>: writes matrix to text file;

        save32 <string file_name>: converts matrix data to fixed-point
                representation (assumes [0..1] range) and writes to TGA file;

        load <string file_name>: reads matrix from text file;

        load32 <string file_name>: reads TGA file and converts data from
                fixed-point representation to [0..1] range;

        constant <real value>: sets all elements to given 'value';

        uniform <real lower,upper>: sets all elements to samples of uniform
                distribution with given 'lower' and 'upper' bounds;

        gaussian <real mean,standard_deviation>: sets all elements to
                samples of normal distribution with given mean and
                standard deviation;

        row_linear <real min,max>: linearly interpolates from given 'min'
                to given 'max' and writes results to every row;

        col_linear <real min,max>: linearly interpolates from given 'min'
                to given 'max' and writes results to every column;

        fourier_forward: replaces matrix by its 2D Fourier transform;

        fourier_inverse: replaces 2D Fourier transform by its inversion;

        scale <real value>: multiplies all elements by given 'value';

        offset <real value>: performs either addition of given 'value' to
                all elements of (spatial-domain) matrix, or phase addition
                for frequency-domain matrix;

        mat_scale <matrix other>: per-element multiplication of two matrices
                or (complex) multiplication of two Fourier transforms
                (useful for computing convolutions);

        mat_unscale <matrix other>: per-element division of two matrices
                or (complex) division of two Fourier transforms
                (useful for computing deconvolutions);

        mat_offset <matrix other>: performs either per-element addition of
                elements of two (spatial-domain) matrices, or per-element
                phase addition of two frequency-domain matrices;

        zero_rows <uint min,max>; clears rows in range ['min','max']
                (operates correctly with Fourier transforms; useful
                for frequency-domain filtering);

        zero_cols <uint min,max>: clears columns in range ['min','max']
                (operates correctly with Fourier transforms; useful
                for frequency-domain filtering);

        convolve3x3 <matrix filter3x3>: convolves the matrix with 3x3 PSF;

        band_reject <uint min,max>: clears both rows and columns in range
                ['min','max'] (operates correctly with Fourier transforms;
                useful for frequency-domain filtering);

        band_pass <uint min,max>: clears both rows and columns outside the
                range ['min','max'] (operates correctly with Fourier
                transforms; useful for frequency-domain filtering);

        adjust_contrast <real min,max>: linearly interpolates range
                ['min';'max'] in current (spatial-domain) matrix to
                range [0,1] (useful for selecting the only specific,
                a-priori known range for visualizing at full contrast;
                shouldn't be confused with "normalize" operation);

        normalize: linearly transforms all elements in such a way that
                minimal value of matrix becomes 0, and maximal becomes 1;

        range_normalize <real new_min,new_max>: linearly transforms all
                elements in such a way that minimal value of matrix becomes
                'new_min', and maximal one becomes 'new_max';

        gamma_correction <vector curve>: performs arbitrary transform of all
                elements in such a way that minimal value of matrix becomes
                equal to first element of 'curve', and maximal one becomes
                equal to last element of 'curve'; uses 'curve' as
                input-to-output function (useful for color reduction and
                histogram equalization);

        draw_decomposition <decomposition decomp>: stores (sparse)
                representation of binary image decomposition 'decomp'
                in current matrix;

        draw_decomposition_scale <decomposition decomp;vector colors>:
                stores representation of binary decomposition 'decomp',
                using, at each depth, colors from vector 'colors';

        draw_decomposition_linear <decomposition decomp;real min,max>:
                stores representation of binary decomposition 'decomp',
                using, at each depth, colors from 'min' up to 'max';

        matrix_transform <string name[(real arg1,...,argN)]>: executes
                transform 'name' for current spatial-domain matrix;

        cartesian_transform <string name[(real arg1,...,argN)]>:
                executes transform 'name' for current frequency-domain
                matrix, passing (Re,Im) pairs on each iteration;

        polar_transform <string name[(real arg1,...,argN)]>: executes
                transform 'name' for current frequency-domain matrix,
                passing (Magnitude,Phase) pairs on each iteration;

        matrix_pair_transform <string name[(real arg1,...,argN)];matrix other>:
                executes transform 'name' for current and 'other'
                matrices (both matrices must be in spatial domain);

        cartesian_pair_transform <string name[(real arg1,...,argN)];matrix m2>:
                executes transform 'name' for current and 'm2'
                matrices (both matrices must be in frequency domain),
                passing (Re1,Im1) and (Re1,Im2) pairs;

        polar_pair_transform <string name[(real arg1,...,argN)];matrix other>:
                executes transform 'name' for current and 'other'
                matrices (both matrices must be in frequency domain),
                passing (Magnitude1,Phase1) and (Magnitude2,Phase2) pairs;

        spectrum: replaces current frequency-domain matrix by its (half-sized)
                power spectrum estimation (adds magnitudes which
                corresponds to maximal and zero frequencies);

        puts <string token>: writes 'token' to standard output;

        run_time: prints time since the start of program.


Valid operations for "vector" class:
        copy <vector src>: copies the data from vector 'src';

        save <string file_name>: writes vector to text file;

        load <string file_name>: loads vector from text file;

        shift <int amount>: circular shift of elements;

        mirror: mirrors the vector;

        uniform <real lower,upper>: sets all elements to samples of uniform
                distribution with given 'lower' and 'upper' bounds;

        gaussian <real mean,standard_deviation>: sets all elements to
                samples of normal distribution with given mean and
                standard deviation;

        constant <real value>: sets all elements to given 'value';

        linear <real min,max>: linearly interpolates from 'min' to 'max';

        histogram <matrix src>: computes histogram of matrix 'src',
                lower bound of first bin will be equal to minimal element
                of 'src', upper bound of last bin will be equal to maximal
                element of 'src';

        range_histogram <matrix src;real min,max>: computes histogram of 'src',
                lower bound of first bin will be equal to 'min', upper
                bound of last bin will be equal to 'max';

        histogram_with_coords <matrix src,vector coords>: computes histogram
                of matrix 'src', stores center of each bin to 'coords';

        range_histogram_with_coords <matrix src,vector coords>: computes range histogram
                of matrix 'src', stores center of each bin to 'coords';

        integrate: computes running sum ("discrete integral");

        normalize: linearly transforms all elements in such a way that
                minimal value of vector becomes 0, and maximal becomes 1;

        range_normalize <real new_min,new_max>: linearly transforms all
                elements in such a way that minimal value of vector becomes
                'new_min', and maximal one becomes 'new_max';

        vector_transform <string name[(real arg1,...,argN)]>: executes
                transform 'name' for current spatial-domain vector;

        vector_pair_transform <string name[(real arg1,...,argN)];vector other>:
                executes transform 'name' for current and 'other'
                spatial-domain vectors;

        puts <string token>: writes 'token' to standard output;

        run_time: prints time since the start of program.


Valid operations for "decomposition" class:
        decompose <matrix src;real threshold;uint histogram_divisions>:
                decomposes matrix 'src' with given 'threshold' and,
                each level, computes histograms of size 'histogram_divisions';

        save <string file_name;boolean save_values,relative_frequencies>:
                saves ASCII description of decomposition to file 'file_name';

        puts <string token>: writes 'token' to standard output;

        run_time: prints time since the start of program.


Valid channel names for matrix "input" operation
        "red"   "green" "blue"
        "red"   "green" "blue"  "alpha"
        "cieX"  "cieY"  "cieZ"
        "hue"   "saturation"    "value"

Format of transform definition:
<ipl_transform_class> <transform_name>(void|[arg1,arg2,...,argN])
{
        step|pass
                <transform_body>
        step|pass
                <transform_body>
        ...
}

where
        <transform_body> - NSL compound statement (see source/examples :(... );
        <transform_name> - unique identifier of transform.

If the <transform_body> follows "step", it will be executed once;
if it follows "pass", it will be executed for every element of the
current IPL object.

The <ipl_transform_class> may be one of the following:

        "vector_transform": iterates through elements of vector;
        "vector_pair_transform": iterates through elements of two vectors;
        "matrix_transform": iterates through elements of matrix;
        "matrix_pair_transform": iterates through elements of two matrices;
        "cartesian_transform": iterates through elements of Fourier transform,
                passing the (Re,Im) pairs;
        "cartesian_pair_transform": iterates through elements of two Fourier
                transforms, passing the (Re,Im) pairs;
        "polar_transform": iterates through elements of Fourier transform,
                passing the (Magnitude,Phase) pairs;
        "polar_pair_transform": iterates through elements of two Fourier
                transforms, passing the (Magnitude,Phase) pairs.

Built-in variables valid for each type of transform:

        "vector_transform":
        "$MAX_IDX": maximal index of element;
        "$IDX": index of element;
        "$ELEM": value of current element.

        "vector_pair_transform":
        "$MAX_IDX": maximal index of element;
        "$IDX": index of element;
        "$ELEM1": value of element of current vector;
        "$ELEM2": value of element of other vector.

        "matrix_transform":
        "$MAX_ROW": maximal index of row;
        "$MAX_COL": maximal index of column;
        "$ROW": current row;
        "$COL": current column;
        "$CELL": value of current cell.

        "matrix_pair_transform":
        "$MAX_ROW": maximal index of row;
        "$MAX_COL": maximal index of column;
        "$ROW": current row;
        "$COL": current column;
        "$CELL1": value of element of current matrix;
        "$CELL2": value of element of other matrix.

        "cartesian_transform":
        "$MAX_ROW": maximal index of row;
        "$MAX_COL": maximal index of column;
        "$ROW": current row;
        "$COL": current column;
        "$NEG_FREQ": one means negative frequency;
        "$RE": real part of current FT cell;
        "$IM": imaginary part of current FT cell.

        "cartesian_pair_transform":
        "$MAX_ROW": maximal index of row;
        "$MAX_COL": maximal index of column;
        "$ROW": current row;
        "$COL": current column;
        "$NEG_FREQ": one means negative frequency;
        "$RE1": real part of cell of current FT;
        "$IM1": imaginary part of cell of current FT;
        "$RE2": real part of cell of other FT;
        "$IM2": imaginary part of cell of other FT.

        "polar_transform":
        "$MAX_ROW": maximal index of row;
        "$MAX_COL": maximal index of column;
        "$ROW": current row;
        "$COL": current column;
        "$NEG_FREQ": one means negative frequency;
        "$MAG": magnitude of current FT cell;
        "$PHASE": phase of current FT cell.

        "polar_pair_transform":
        "$MAX_ROW": maximal index of row;
        "$MAX_COL": maximal index of column;
        "$ROW": current row;
        "$COL": current column;
        "$NEG_FREQ": one means negative frequency;
        "$MAG1": magnitude of cell of current FT;
        "$PHASE1": phase of cell of current FT;
        "$MAG2": magnitude of cell of other FT;
        "$PHASE2": phase of cell of other FT.

Built-in constants valid for any transform and function:

        "Pi": Pi = 3.14159265358979312...;
        "E": e = 2.71828182845904509...;
        "MAXREAL": maximal value of 'real' variable;
        "REAL_ZERO": small, but still invertible value of 'real' variable.

Format of function definition:
function <function_name>
<function_body>

where
        <function_name> - unique identifier of function;
        <function_body> - NSL compound statement, which should contain
        'return' statement (or the assignment to '%' variable).

IPL run completed: success. (alloc: 0 bytes; leak: 0 bytes)

Ещё в язык ipl встроен язык NSL a.k.a «nano scripting language». На этом языке пишется код обработчиков (ключевые слова чтототам_transform). Тип данных только один - число с плавающей точкой (одинарной или двойной точности – определяется на этапе компиляции интерпретатора). Выражения записываются в обратной польской нотации. Среди управляющих структур – только условный оператор (другие по смыслу не нужны; семантика всех операций чтототам_transform – такая же, как пиксельных шейдеров).

Назад