create

create — create VipsImage in various ways

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <vips/vips.h>

int                 im_benchmark2                       (VipsImage *in,
                                                         double *out);
int                 im_benchmarkn                       (VipsImage *in,
                                                         VipsImage *out,
                                                         int n);
int                 vips_black                          (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);
void                vips_create_operation_init          (void);
int                 vips_eye                            (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);
int                 vips_gaussnoise                     (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);
int                 vips_grey                           (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);
int                 vips_sines                          (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);
int                 vips_text                           (VipsImage **out,
                                                         const char *text,
                                                         ...);
int                 vips_xyz                            (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);
int                 vips_zone                           (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Description

These functions generate various test images. You can combine them with the arithmetic and rotate functions to build more complicated images.

The im_benchmark() operations are for testing the VIPS SMP system.

Details

im_benchmark2 ()

int                 im_benchmark2                       (VipsImage *in,
                                                         double *out);

This operation runs a single im_benchmarkn() and calculates the average pixel value. It's useful if you just want to test image input.

See also: im_benchmarkn().

in :

input image

out :

average image value

Returns :

0 on success, -1 on error

im_benchmarkn ()

int                 im_benchmarkn                       (VipsImage *in,
                                                         VipsImage *out,
                                                         int n);

This operation runs a complicated set of other operations on image in, producing image out. Use n to set the number of iterations to run: a larger number will make the operation more CPU-bound, a smaller number will make the operation more IO-bound.

See http://www.vips.ecs.soton.ac.uk/index.php?title=Benchmarks for a detailed discussion of the benchmark and some sample results.

See also: im_benchmark2().

in :

input image

out :

output image

n :

iterations

Returns :

0 on success, -1 on error

vips_black ()

int                 vips_black                          (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

bands: output bands

Make a black unsigned char image of a specified size.

See also: im_make_xy(), im_text(), im_gaussnoise().

out :

output image

width :

output width

height :

output height

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_create_operation_init ()

void                vips_create_operation_init          (void);


vips_eye ()

int                 vips_eye                            (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

factor: maximum spatial frequency uchar: output a uchar image

Create a test pattern with increasing spatial frequence in X and amplitude in Y. factor should be between 0 and 1 and determines the maximum spatial frequency.

Set uchar to output a uchar image.

See also: vips_zone().

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_gaussnoise ()

int                 vips_gaussnoise                     (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

mean: mean of generated pixels sigma: standard deviation of generated pixels

Make a one band float image of gaussian noise with the specified distribution. The noise distribution is created by averaging 12 random numbers with the appropriate weights.

See also: vips_black(), im_make_xy(), im_text().

out :

output image

width :

output width

height :

output height

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_grey ()

int                 vips_grey                           (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

uchar: output a uchar image

Create a one-band float image with the left-most column zero and the right-most 1. Intermediate pixels are a linear ramp.

Set uchar to output a uchar image with the leftmost pixel 0 and the rightmost 255.

See also: vips_xyz(), vips_identity().

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_sines ()

int                 vips_sines                          (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

hfreq: horizontal frequency vreq: vertical frequency uchar: output a uchar image

Creates a float one band image of the a sine waveform in two dimensions.

The number of horizontal and vertical spatial frequencies are determined by the variables hfreq and vfreq respectively. The function is useful for creating displayable sine waves and square waves in two dimensions.

If horfreq and verfreq are integers the resultant image is periodical and therfore the Fourier transform does not present spikes

Pixels are normally in [-1, +1], set uchar to output [0, 255].

See also: vips_grey(), vips_xyz().

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_text ()

int                 vips_text                           (VipsImage **out,
                                                         const char *text,
                                                         ...);

Optional arguments:

font: font to render with width: render within this many pixels across alignment: left/centre/right alignment dpi: render at this resolution

Draw the string text to an image. out is a one-band 8-bit unsigned char image, with 0 for no text and 255 for text. Values inbetween are used for anti-aliasing.

text is the text to render as a UTF-8 string. It can contain Pango markup, for example "<i>The</i>Guardian".

font is the font to render with, as a fontconfig name. Examples might be "sans 12" or perhaps "bitstream charter bold 10".

width is the maximum number of pixels across to draw within. If the generated text is wider than this, it will wrap to a new line. In this case, alignment can be used to set the alignment style for multi-line text. 0 means left-align, 1 centre, 2 right-align.

dpi sets the resolution to render at. "sans 12" at 72 dpi draws characters approximately 12 pixels high.

See also: vips_make_xy(), vips_text(), vips_gaussnoise().

out :

output image

text :

utf-8 text string to render

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_xyz ()

int                 vips_xyz                            (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

csize: size for third dimension dsize: size for fourth dimension esize: size for fifth dimension

Create a two-band uint32 image where the elements in the first band have the value of their x coordinate and elements in the second band have their y coordinate.

You can make any image where the value of a pixel is a function of its (x, y) coordinate by combining this operator with the arithmetic operators.

Set csize, dsize, esize to generate higher dimensions and add more bands. The extra dimensions are placed down the vertical axis. Use vips_grid() to change the layout.

See also: vips_grey(), vips_grid(), vips_identity().

out :

output image

width :

horizontal size

height :

vertical size

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error

vips_zone ()

int                 vips_zone                           (VipsImage **out,
                                                         int width,
                                                         int height,
                                                         ...);

Optional arguments:

uchar: output a uchar image

Create a one-band image of a zone plate.

Pixels are normally in [-1, +1], set uchar to output [0, 255].

See also: vips_eye(), vips_xyz().

out :

output image

... :

NULL-terminated list of optional named arguments

Returns :

0 on success, -1 on error