Generating the multi-size image

Carver object creation
Carver activation

Carver object creation

The LqrCarver objects are initialized from a plain buffer representing an image. The default constructor assumes a colour depth of 8 bits per channel:

LqrCarver * lqr_carver_new( guchar * buffer,
  gint width,
  gint height,
  gint channels);
 

Here, buffer is the array representing an image of size width by height with channels colour channels per pixels. Thus, the overall buffer size has to be of widht * height * channels unsigned characters, and ordered such that the k-th colour of the pixel at row y and column x is found at:

buffer[(y * width + x) * channels + k]

(this assumes that x, y and k all start from 0 and reach the maximum values widht-1, height-1 and channels-1, respectively)

The function returns a pointer to the newly allocated LqrCarver upon success, or NULL in case of insufficient memory.

In order to create LqrCarver objects with more than 8 bits per channel, an extended version of the constructor must be used:

LqrCarver * lqr_carver_new_ext( void * buffer,
  gint width,
  gint height,
  gint channels,
  LqrColDepth colour_depth);
 

The differnece with the default version is that the input buffer must be passed as void, and its type must be specified through the additional parameter colour_depth, which can take one of the following values:

LQR_COLDEPTH_8I

8 bit unsigned integers (guchar)

LQR_COLDEPTH_16I

16 bit unsigned integers (guint16)

LQR_COLDEPTH_32F

32 bit floating point (gfloat)

LQR_COLDEPTH_64F

64 bit floating point (gdouble)

Floating point type values must range between 0 and 1.

Important

The buffer will become part of the LqrCarver object and must not be accessed directly any more.

Carver activation

The newly created LqrCarver consists only of the image buffer plus an uninitialized visibility map. If one had a previously computed visibility map, it could be imported into the LqrCarver and that would be enough (see the Importing a visibility map in a carver section). If the visibility map has to be computed, the LqrCarver needs to be initialized through this function:

LqrRetVal lqr_carver_init( LqrCarver * carver,
  gint delta_x,
  gfloat rigidity);
 

Here, delta_x is the maximum allowed transversal step of the seams (0 means straight seams, the typical value is 1), while the rigidity parameter can be used to introduce a global bias for non-straight seams (the typical value is 0; a nonzero value can be modulated locally for specific areas using the functions described in section Adding a rigidity mask).

Important

It is currently an error to initalize a carver object if a visibility map has been imported already.