The rigidity parameter which is set at carver activation time (see section Carver activation) normally affects the whole image. It is possible, however, to specify which areas of the image should be affected by using a rigidity mask.
When a rigidity mask is used, each pixel of the image acquires an individual rigidity coefficient, which has to be multiplied with the overall rigidity parameter to get the actual pixel's rigidity. This is useful in some situations to reduce distorsions in specific areas of the image while keeping the seams optimal in other areas.
The library interface to deal with rigidity masks follows verty closely the scheme for bias masks as described in the bias section), the only difference being that no equivalent to the bias factor has to be provided.
The rigidity mask has to be added always after
the LqrCarver
initialization and before
resizing takes place.
All of the functions can be called multiple times; in such case, their effect will be summed up.
The rigidity mask values are stored as an array of floating points. It is possible to use directly one such array through this function:
LqrRetVal lqr_carver_rigmask_add( | LqrCarver* carver, |
gdouble* buffer) ; |
Here, buffer
is an array contining the bias values,
and it is assumed to have the same size as the image loaded in
carver
.
This function, and all the following, will not swallow
the buffer (to the contrary of what happens e.g. when creating
a new LqrCarver
object).
The rigidity mask can also be read from an 8-bit rgb buffer. This buffer has to be in the same format as the one used in the 8-bit LqrCarver constructor (but may have a different number of colours per channel). The function is:
LqrRetVal lqr_carver_rigmask_add_rgb( | LqrCarver* carver, |
guchar* buffer, | |
gint channels) ; |
As in the previous case, buffer
is assumed to
hold and image of the same size as the one in the carver
.
The buffer
contents will be transformed into
floating-points by averaging the colour components and multiplying the
result by the alpha channel (transparency) value.
The existence of an alpha channel is inferred from the
channels
value: if this is 1 or 3, no alpha
channel is assumed, if it is 2 or 4, it is assumed that the last
channel is holds the alpha value. If this is not what you want, you should
resort to the previous method.
The above functions operate on the whole LqrCarver
image.
It is also possible to access specific image regions; for
the floating point use:
LqrRetVal lqr_carver_rigmask_add_area( | LqrCarver* carver, |
gdouble* buffer, | |
gint width, | |
gint height, | |
gint x_off, | |
gint y_off) ; |
while for the rgb image use:
LqrRetVal lqr_carver_rigmask_add_rgb_area( | LqrCarver* carver, |
guchar* buffer, | |
gint channels, | |
gint width, | |
gint height, | |
gint x_off, | |
gint y_off) ; |
In both functions, width
and height
are used to specify the size of the area of interest, while
x_off
and y_off
specify its offset.
For the rest, both functions work in the same way as their global couterpart.
The provided buffers have to be of size
(or width
* height
for the rgb case)
but the specified areas need not to be strictly included inside the
width
* height
* channels
LqrCarver
image area : only the parts which overlap with it will be used.
For example, the offsets can also be negative.
Outside of the affected areas, the rigidity will be set to 0, which means that the global rigidity value will not be used for such areas.