Tuning

Choosing a gradient function
Choosing the resize order
Choosing the side switch frequency

The behaviour can be tuned through some additional functions.

Choosing a gradient function

The automatic feature detection relies on the computation of the gradient in each pixel of the image. The function to use can be set through:

void lqr_carver_set_gradient_function(LqrCarver* carver,
 LqrGradFuncType gf_ind);
 

The possible values for gf_ind are:

LQR_GF_XABS

absolute value of the gradient in the direction of the rescaling (this is the default)

LQR_GF_SUMABS

sum of absolute values of the gradients in both directions

LQR_GF_NORM

gradient norm

LQR_GF_NULL

null

The null value can be used to override completely the automatic feature detection (see the Adding a bias section).

Choosing the resize order

When the function lqr_carver_resize is asked to resize along both directions in a single step, it has to choose which direction to resize first. The resize order can be changed through this function:

void lqr_carver_set_resize_order(LqrCarver* carver,
 LqrResizeOrder resize_order);
 

The possible values for resize_order are:

LQR_RES_ORDER_HOR

resize horizonally first (this is the default)

LQR_RES_ORDER_VERT

resize vertically first

Choosing the side switch frequency

When the function lqr_carver_resize is invoked, it chooses at each step the optimal seam to carve based on the relvance value for each pixel. However, in the case two seams are equivalent (which may happen when large portions of the image have the same colour, for example), the algorithm always chooses the seams from one side, which might be a problem (e.g. an object centered in the original image might not be centered any more in the resulting image).

In order to overcome this effect, an option is given to automatically switch the favoured side during rescaling, at the cost of a slightly worse performance. The number of times such a switching event occurs for each rescale operation can be set using the function:

void lqr_carver_set_side_switch_frequency(LqrCarver* carver,
 guint switch_frequency);
 

The default value for newly created LqrCarver objects is 0, which is equivalent to disabling this feature. Giving a value greater than the number of pixels by which to rescale produces a switch for each pixel, therefore you could set switch_freqency to a ridicolously high value in order to be sure to get this effect.

As for the final result, a very small value (e.g. 1 to 4) will normally suffice to balance the left and right side of the image (or the top and the bottom sides for vertical rescalings), without noticeable computational costs. However, in order to obtain a smoother behaviour for the visibiliy map, i.e. for the intermediate steps, higher values may be required.