next up previous contents
Next: 3.6 Writing results Up: 3. The VImage class Previous: 3.4 Assignment   Contents


3.5 Computing with VImages

All VIPS image processing operations are member functions of the VImage class. For example:

VImage fred( "fred.v" );
VImage jim( "jim.v" );

Vimage result = fred.cos() + jim;

Will apply im_costra() to fred.v, making an image where each pixel is the cosine of the corresponding pixel in fred.v; then add that image to jim.v. Finally, the result will be held in result.

VIPS is a demand-driven image processing system: when it computes expressions like this, no actual pixels are calculated (although you can use the projection functions on images -- result.BandFmt() for example). When you finally write the result to a file (or use some operation that needs pixel values, such as min(), find minimum value), VIPS evaluates all of the operations you have called to that point in parallel. If you have more than one CPU in your machine, the load is spread over the available processors. This means that there is no limit to the size of the images you can process.

Section 4 lists all of the members, but these general rules apply:

This part of the C++ API is generated automatically from the VIPS function database, so it should all be up-to-date.

There are a set of arithmetic operators defined for your convenience:

VImage operator+( VImage a, VImage b );
VImage operator+( double a, VImage b );
VImage operator+( VImage a, double b );
VImage operator-( VImage a, VImage b );
VImage operator-( double a, VImage b );
VImage operator-( VImage a, double b );
VImage operator*( VImage a, VImage b );
VImage operator*( double a, VImage b );
VImage operator*( VImage a, double b );
VImage operator/( VImage a, VImage b );
VImage operator/( double a, VImage b );
VImage operator/( VImage a, double b );
VImage operator-( VImage a );
VImage operator%( VImage a, VImage b );
VImage operator%( VImage a, double b );
VImage operator<( VImage a, VImage b );
VImage operator<( double a, VImage b );
VImage operator<( VImage a, double b );
VImage operator<=( VImage a, VImage b );
VImage operator<=( double a, VImage b );
VImage operator<=( VImage a, double b );
VImage operator>( VImage a, VImage b );
VImage operator>( double a, VImage b );
VImage operator>( VImage a, double b );
VImage operator>=( VImage a, VImage b );
VImage operator>=( double a, VImage b );
VImage operator>=( VImage a, double b );
VImage operator==( VImage a, VImage b );
VImage operator==( double a, VImage b );
VImage operator==( VImage a, double b );
VImage operator!=( VImage a, VImage b );
VImage operator!=( double a, VImage b );
VImage operator!=( VImage a, double b );
VImage operator&( VImage a, VImage b );
VImage operator&( double a, VImage b );
VImage operator&( VImage a, double b );
VImage operator|( VImage a, VImage b );
VImage operator|( double a, VImage b );
VImage operator|( VImage a, double b );
VImage operator^( VImage a, VImage b );
VImage operator^( double a, VImage b );
VImage operator^( VImage a, double b );
VImage operator<<( VImage a, int b );
VImage operator>>( VImage a, int b );
VImage operator-( VImage a );

So you can write stuff like:

VImage fred( "fred.v" );
VImage jim( "jim.v" );

Vimage result = (fred + jim) / 2;


next up previous contents
Next: 3.6 Writing results Up: 3. The VImage class Previous: 3.4 Assignment   Contents
John Cupitt 2003-07-21