Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/share/doc/liblqr-1-0-dev/html/ drwxr-xr-x | |
| Viewing file: Select action/file-type: The automatic feature detection relies on the evaluation of the relevance of each pixel; this quantity is called `energy': the higher the energy of a pixel, the less likely it will be that such pixel will be directly involved in the rescaling. The energy function which the library uses can be customised; normally, edge detector filters are the best choices for this purpose. There is a unified framework in the Liquid Rescale library for energy fucntions: briefly, each energy function used by the library receives the current position and image size as parameters, and is provided access to a square of values from the image, centered around the current position. This access is provided through an object which is called a "reading window", and the image pixels are not read directly, but rather they are accessed according to a "reader type", which means that the energy function can get e.g. the brightness of a pixel without needing to care for the underlying image representation, i.e. the image type or the colour depth. The library provides a small set of very simple (yet normally effective) gradient-based energy functions, and a customisation framework for defining more functions.
The library has some builtin functions for energy evaluation; in order to set one of the builtin
functions in a
The currently available builtin functions which can be used as
All of the above gradient functions have a radius of 1 pixel.
Custom energy functions for a
Here,
The
These readouts always return values beetween NoteNote that these readouts may have special meanings depending on the image type:
The custom energy function must be declared like in the following sample declaration: Example 2.5. Custom energy declaration
gfloat my_energy (gint x, gint y, gint width, gint height, LqrReadingWindow *rwindow, gpointer extra_data);
When reading out the content from a window, the
The
Following is an example of how a simple Sobel fliter can be defined and used within this framework: Example 2.6. Custom energy definition and setup
/* definition */
gfloat sobel(gint x, gint y, gint width, gint height, LqrReadingWindow *rw, gpointer extra_data)
{
gint i, j;
gdouble ex = 0;
gdouble ey = 0;
gdouble k[3][3] = {{0.125, 0.25, 0.125}, {0, 0, 0}, {-0.125, -0.25, -0.125}};
for (i = -1; i <=1; i++) {
for (j = -1; j <=1; j++) {
ex += k[i + 1][j + 1] * lqr_rwindow_read(rw, i, j, 0);
ey += k[j + 1][i + 1] * lqr_rwindow_read(rw, i, j, 0);
}
}
return (gfloat) sqrt(ex * ex + ey * ey);
}
/* usage */
lqr_carver_set_energy_function (carver, sobel, 1, LQR_ER_BRIGHTNESS, NULL);
In the above Note
The function Note
The energy functions are called over the transposed image in case of vertical scaling,
therefore, if they are asymmetrical, the result will be different depending on the scaling
orientation (this is the case for example for the Note
The energy function output should be normalised in order to be comparable with the builtin
functions, otherwise the scale of the bias would be different depending on the energy function
used. This is the reason why in the Sobel filter written above the kernel
Note
In actual code, the call to The energy can be read out with three similar functions, all of which fill a buffer provided by the user, but in different ways: two of them are suitable for plotting, while the third one can be used to retreive the true values of the energy, as used internally. The first function can be used to get a buffer of normalised values, and it has a simple syntax:
This function writes the the energy values at the time of calling to the given
The
The The above function does not return the true energy which is used internally, because that would not be suitable for plotting, since the energy range is arbitrary (only the energy differences are meaningful, and there is no upper nor lower bound to the values). In order to get the true energy values used internally, this function must be used instead (with the same syntax):
The third function can be used to fill directly an image buffer:
In this case, the buffer must be passed as void*, while the
For any choice of the parameters, the Note
Calling the function |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0055 ]-- |