![]() |
Leptonica
1.82.0
Image processing and image analysis suite
|
#include "allheaders.h"
Go to the source code of this file.
Functions | |
PIXTILING * | pixTilingCreate (PIX *pixs, l_int32 nx, l_int32 ny, l_int32 w, l_int32 h, l_int32 xoverlap, l_int32 yoverlap) |
void | pixTilingDestroy (PIXTILING **ppt) |
l_ok | pixTilingGetCount (PIXTILING *pt, l_int32 *pnx, l_int32 *pny) |
l_ok | pixTilingGetSize (PIXTILING *pt, l_int32 *pw, l_int32 *ph) |
PIX * | pixTilingGetTile (PIXTILING *pt, l_int32 i, l_int32 j) |
l_ok | pixTilingNoStripOnPaint (PIXTILING *pt) |
l_ok | pixTilingPaintTile (PIX *pixd, l_int32 i, l_int32 j, PIX *pixs, PIXTILING *pt) |
PIXTILING *pixTilingCreate() void *pixTilingDestroy() l_int32 pixTilingGetCount() l_int32 pixTilingGetSize() PIX *pixTilingGetTile() l_int32 pixTilingNoStripOnPaint() l_int32 pixTilingPaintTile() This provides a simple way to split an image into tiles and to perform operations independently on each tile. The tile created with pixTilingGetTile() can have pixels in adjacent tiles for computation. The number of extra pixels on each side of the tile is given by an 'overlap' parameter to pixTilingCreate(). For tiles at the boundary of the input image, quasi-overlap pixels are created by reflection symmetry into the tile. Here's a typical intended usage. Suppose you want to parallelize the operation on an image, by operating on tiles. For each tile, you want to generate an in-place image result at the same resolution. Suppose you choose a one-dimensional vertical tiling, where the desired tile width is 256 pixels and the overlap is 30 pixels on left and right sides: PIX *pixd = pixCreateTemplate(pixs); // output PIXTILING *pt = pixTilingCreate(pixs, 0, 1, 256, 30, 0); pixTilingGetCount(pt, &nx, NULL); for (j = 0; j < nx; j++) { PIX *pixt = pixTilingGetTile(pt, 0, j); SomeInPlaceOperation(pixt, 30, 0, ...); pixTilingPaintTile(pixd, 0, j, pixt, pt); pixDestroy(&pixt); } In this example, note the following: ~ The unspecfified in-place operation could instead generate a new pix. If this is done, the resulting pix must be the same size as pixt, because pixTilingPaintTile() makes that assumption, removing the overlap pixels before painting into the destination. ~ The 'overlap' parameters have been included in your function, to indicate which pixels are not in the exterior overlap region. You will need to change only pixels that are not in the overlap region, because those are the pixels that will be painted into the destination. ~ For tiles on the outside of the image, mirrored pixels are added to substitute for the overlap that is added to interior tiles. This allows you to implement your function without reference to which tile it is; no special coding is necessary for pixels that are near the image boundary. ~ The tiles are labeled by (i, j) = (row, column), and in this example there is one row and nx columns.
Definition in file pixtiling.c.
PIXTILING* pixTilingCreate | ( | PIX * | pixs, |
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | w, | ||
l_int32 | h, | ||
l_int32 | xoverlap, | ||
l_int32 | yoverlap | ||
) |
[in] | pixs | pix to be tiled; any depth; colormap OK |
[in] | nx | number of tiles across image |
[in] | ny | number of tiles down image |
[in] | w | desired width of each tile |
[in] | h | desired height of each tile |
[in] | xoverlap | overlap into neighboring tiles on each side |
[in] | yoverlap | overlap into neighboring tiles above and below |
Notes: (1) We put a clone of pixs in the PixTiling. (2) The input to pixTilingCreate() for horizontal tiling can be either the number of tiles across the image or the approximate width of the tiles. If the latter, the actual width will be determined by making all tiles but the last of equal width, and making the last as close to the others as possible. The same consideration is applied independently to the vertical tiling. To specify tile width, set nx = 0; to specify the number of tiles horizontally across the image, set w = 0. (3) If pixs is to be tiled in one-dimensional strips, use ny = 1 for vertical strips and nx = 1 for horizontal strips. (4) The overlap must not be larger than the width or height of the leftmost or topmost tile(s).
Definition at line 123 of file pixtiling.c.
References PixTiling::h, PixTiling::nx, PixTiling::ny, PixTiling::pix, pixClone(), pixGetDimensions(), PixTiling::strip, PixTiling::w, PixTiling::xoverlap, and PixTiling::yoverlap.
void pixTilingDestroy | ( | PIXTILING ** | ppt | ) |
[in,out] | ppt | will be set to null before returning |
Definition at line 179 of file pixtiling.c.
References PixTiling::pix, and pixDestroy().
l_ok pixTilingGetCount | ( | PIXTILING * | pt, |
l_int32 * | pnx, | ||
l_int32 * | pny | ||
) |
[in] | pt | pixtiling |
[out] | pnx | [optional] nx; can be null |
[out] | pny | [optional] ny; can be null |
Definition at line 208 of file pixtiling.c.
References PixTiling::nx, and PixTiling::ny.
Referenced by pixTilingGetTile().
l_ok pixTilingGetSize | ( | PIXTILING * | pt, |
l_int32 * | pw, | ||
l_int32 * | ph | ||
) |
[in] | pt | pixtiling |
[out] | pw | [optional] tile width; can be null |
[out] | ph | [optional] tile height; can be null |
Definition at line 231 of file pixtiling.c.
References PixTiling::h, and PixTiling::w.
Referenced by pixTilingGetTile().
[in] | pt | pixtiling |
[in] | i | tile row index |
[in] | j | tile column index |
Definition at line 255 of file pixtiling.c.
References boxCreate(), boxDestroy(), PixTiling::pix, pixAddMirroredBorder(), pixClipRectangle(), pixClone(), pixDestroy(), pixGetDimensions(), pixTilingGetCount(), pixTilingGetSize(), PixTiling::xoverlap, and PixTiling::yoverlap.
l_ok pixTilingNoStripOnPaint | ( | PIXTILING * | pt | ) |
[in] | pt | pixtiling |
Notes: (1) The default for paint is to strip out the overlap pixels that are added by pixTilingGetTile(). However, some operations will generate an image with these pixels stripped off. This tells the paint operation not to strip the added boundary pixels when painting.
Definition at line 368 of file pixtiling.c.
References PixTiling::strip.
[in] | pixd | dest: paint tile onto this, without overlap |
[in] | i | tile row index |
[in] | j | tile column index |
[in] | pixs | source: tile to be painted from |
[in] | pt | pixtiling struct |
Definition at line 390 of file pixtiling.c.
References PixTiling::h, PixTiling::nx, PixTiling::ny, PIX_SRC, pixGetDimensions(), pixRasterop(), PixTiling::strip, PixTiling::w, PixTiling::xoverlap, and PixTiling::yoverlap.