Exact Area Box Filtering
I have been investigating the possibility of implementing exact area
box filtering in GEGL. Specifically, I would like to build a sampler
that behaves like exact area box filtering when downsampling but also
behaves reasonably when performing other transformations.
The basic idea is to average the piecewise constant "nearest
neighbour" surface on the smallest rectangle (width and height at
least 1) that contains the pull-back (inverse image, anti-image) of an
"output" pixel area by the inverse Jacobian (approximated if needed).
The main issues are:
1) Averaging over a region too large for the usual 64x128 tile.
If we downsample by a significant amount, the region to average over
may be larger than the size of a tile. This could be solved by either
calling gegl_sampler_get_ptr () repeatedly with a large, constant
footprint, or by devising a system to change the footprint on a
pixel-by-pixel basis. The latter solution just involves modifying
context_rect on the fly, which should be feasible.
2) Passing the four numbers which define (an approximation of) the
inverse Jacobian to the sampler from the operation which calls it.
I see that there are create_matrix () methods that seem to construct a
Jacobian for various affine transformations. The proposed method would
require the inverse Jacobian instead, which may require some changes
to the API. Since more complex warping may also make use of this
feature in the future, would it be acceptable to add methods to
support this?
3) Is there already code which does this?
I have noticed that resample_boxfilter_u8 seems to do something
related. How similar is this code and Is there too much overlap for
this project to be worthwhile?
I would appreciate any feedback or help that anyone can provide.
Adam Turcotte