![]() |
Leptonica
1.83.1
Image processing and image analysis suite
|
#include <string.h>
#include <math.h>
#include "allheaders.h"
Go to the source code of this file.
Functions | |
PIX * | pixaDisplay (PIXA *pixa, l_int32 w, l_int32 h) |
PIX * | pixaDisplayRandomCmap (PIXA *pixa, l_int32 w, l_int32 h) |
PIX * | pixaDisplayLinearly (PIXA *pixas, l_int32 direction, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border, BOXA **pboxa) |
PIX * | pixaDisplayOnLattice (PIXA *pixa, l_int32 cellw, l_int32 cellh, l_int32 *pncols, BOXA **pboxa) |
PIX * | pixaDisplayUnsplit (PIXA *pixa, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor) |
PIX * | pixaDisplayTiled (PIXA *pixa, l_int32 maxwidth, l_int32 background, l_int32 spacing) |
PIX * | pixaDisplayTiledInRows (PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border) |
PIX * | pixaDisplayTiledInColumns (PIXA *pixas, l_int32 nx, l_float32 scalefactor, l_int32 spacing, l_int32 border) |
PIX * | pixaDisplayTiledAndScaled (PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border) |
PIX * | pixaDisplayTiledWithText (PIXA *pixa, l_int32 maxwidth, l_float32 scalefactor, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor) |
PIX * | pixaDisplayTiledByIndex (PIXA *pixa, NUMA *na, l_int32 width, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor) |
PIX * | pixaDisplayPairTiledInColumns (PIXA *pixas1, PIXA *pixas2, l_int32 nx, l_float32 scalefactor, l_int32 spacing1, l_int32 spacing2, l_int32 border1, l_int32 border2, l_int32 fontsize, l_int32 startindex, SARRAY *sa) |
PIX * | pixaaDisplay (PIXAA *paa, l_int32 w, l_int32 h) |
PIX * | pixaaDisplayByPixa (PIXAA *paa, l_int32 maxnx, l_float32 scalefactor, l_int32 hspacing, l_int32 vspacing, l_int32 border) |
PIXA * | pixaaDisplayTiledAndScaled (PIXAA *paa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border) |
PIXA * | pixaConvertTo1 (PIXA *pixas, l_int32 thresh) |
PIXA * | pixaConvertTo8 (PIXA *pixas, l_int32 cmapflag) |
PIXA * | pixaConvertTo8Colormap (PIXA *pixas, l_int32 dither) |
PIXA * | pixaConvertTo32 (PIXA *pixas) |
PIXA * | pixaConstrainedSelect (PIXA *pixas, l_int32 first, l_int32 last, l_int32 nmax, l_int32 use_pairs, l_int32 copyflag) |
l_ok | pixaSelectToPdf (PIXA *pixas, l_int32 first, l_int32 last, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, l_uint32 color, l_int32 fontsize, const char *fileout) |
PIXA * | pixaMakeFromTiledPixa (PIXA *pixas, l_int32 w, l_int32 h, l_int32 nsamp) |
PIXA * | pixaMakeFromTiledPix (PIX *pixs, l_int32 w, l_int32 h, l_int32 start, l_int32 num, BOXA *boxa) |
l_ok | pixGetTileCount (PIX *pix, l_int32 *pn) |
PIXA * | pixaDisplayMultiTiled (PIXA *pixas, l_int32 nx, l_int32 ny, l_int32 maxw, l_int32 maxh, l_float32 scalefactor, l_int32 spacing, l_int32 border) |
l_ok | pixaSplitIntoFiles (PIXA *pixas, l_int32 nsplit, l_float32 scale, l_int32 outwidth, l_int32 write_pixa, l_int32 write_pix, l_int32 write_pdf) |
l_ok | convertToNUpFiles (const char *dir, const char *substr, l_int32 nx, l_int32 ny, l_int32 tw, l_int32 spacing, l_int32 border, l_int32 fontsize, const char *outdir) |
PIXA * | convertToNUpPixa (const char *dir, const char *substr, l_int32 nx, l_int32 ny, l_int32 tw, l_int32 spacing, l_int32 border, l_int32 fontsize) |
PIXA * | pixaConvertToNUpPixa (PIXA *pixas, SARRAY *sa, l_int32 nx, l_int32 ny, l_int32 tw, l_int32 spacing, l_int32 border, l_int32 fontsize) |
l_ok | pixaCompareInPdf (PIXA *pixa1, PIXA *pixa2, l_int32 nx, l_int32 ny, l_int32 tw, l_int32 spacing, l_int32 border, l_int32 fontsize, const char *fileout) |
Pixa display (render into a pix) PIX *pixaDisplay() PIX *pixaDisplayRandomCmap() PIX *pixaDisplayLinearly() PIX *pixaDisplayOnLattice() PIX *pixaDisplayUnsplit() PIX *pixaDisplayTiled() PIX *pixaDisplayTiledInRows() PIX *pixaDisplayTiledInColumns() PIX *pixaDisplayTiledAndScaled() PIX *pixaDisplayTiledWithText() PIX *pixaDisplayTiledByIndex() Pixa pair display (render into a pix) PIX *pixaDisplayPairTiledInColumns() Pixaa display (render into a pix) PIX *pixaaDisplay() PIX *pixaaDisplayByPixa() PIXA *pixaaDisplayTiledAndScaled() Conversion of all pix to specified type (e.g., depth) PIXA *pixaConvertTo1() PIXA *pixaConvertTo8() PIXA *pixaConvertTo8Colormap() PIXA *pixaConvertTo32() Pixa constrained selection and pdf generation PIXA *pixaConstrainedSelect() l_int32 pixaSelectToPdf() Generate pixa from tiled images PIXA *pixaMakeFromTiledPixa() PIXA *pixaMakeFromTiledPix() l_int32 pixGetTileCount() Pixa display into multiple tiles PIXA *pixaDisplayMultiTiled() Split pixa into files l_int32 pixaSplitIntoFiles() Tile N-Up l_int32 convertToNUpFiles() PIXA *convertToNUpPixa() PIXA *pixaConvertToNUpPixa() Render two pixa side-by-side for comparison * l_int32 pixaCompareInPdf() We give twelve pixaDisplay*() methods for tiling a pixa in a pix. Some work for 1 bpp input; others for any input depth. Some give an output depth that depends on the input depth; others give a different output depth or allow you to choose it. Some use a boxes to determine where each pix goes; others tile onto a regular lattice; others tile onto an irregular lattice; one uses an associated index array to determine which column each pix goes into. Here is a brief description of what the pixa display functions do. pixaDisplay() This uses the boxes in the pixa to lay out each pix. This can be used to reconstruct a pix that has been broken into components, if the boxes represents the positions of the components in the original image. pixaDisplayRandomCmap() This also uses the boxes to lay out each pix. However, it creates a colormapped dest, where each 1 bpp pix is given a randomly generated color (up to 256 are used). pixaDisplayLinearly() This puts each pix, sequentially, in a line, either horizontally or vertically. pixaDisplayOnLattice() This puts each pix, sequentially, onto a regular lattice, omitting any pix that are too big for the lattice size. This is useful, for example, to store bitmapped fonts, where all the characters are stored in a single image. pixaDisplayUnsplit() This lays out a mosaic of tiles (the pix in the pixa) that are all of equal size. (Don't use this for unequal sized pix!) For example, it can be used to invert the action of pixaSplitPix(). pixaDisplayTiled() Like pixaDisplayOnLattice(), this places each pix on a regular lattice, but here the lattice size is determined by the largest component, and no components are omitted. This is dangerous if there are thousands of small components and one or more very large one, because the size of the resulting pix can be huge! pixaDisplayTiledInRows() This puts each pix down in a series of rows, where the upper edges of each pix in a row are aligned and there is a uniform spacing between the pix. The height of each row is determined by the tallest pix that was put in the row. This function is a reasonably efficient way to pack the subimages. A boxa of the locations of each input pix is stored in the output. pixaDisplayTiledInColumns() This puts each pix down in a series of rows, each row having a specified number of pix. The upper edges of each pix in a row are aligned and there is a uniform spacing between the pix. The height of each row is determined by the tallest pix that was put in the row. A boxa of the locations of each input pix is stored in the output. pixaDisplayTiledAndScaled() This scales each pix to a given width and output depth, and then tiles them in rows with a given number placed in each row. This is useful for presenting a sequence of images that can be at different resolutions, but which are derived from the same initial image. pixaDisplayTiledWithText() This is a version of pixaDisplayTiledInRows() that prints, below each pix, the text in the pix text field. It renders a pixa to an image with white background that does not exceed a given value in width. pixaDisplayTiledByIndex() This scales each pix to a given width and output depth, and then tiles them in columns corresponding to the value in an associated numa. All pix with the same index value are rendered in the same column. Text in the pix text field are rendered below the pix. To render mosaics of images in a pixaa, display functions are provided that handle situations where the images are all scaled to the same size, or the number of images on each row needs to vary.
Definition in file pixafunc2.c.
l_ok convertToNUpFiles | ( | const char * | dir, |
const char * | substr, | ||
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | tw, | ||
l_int32 | spacing, | ||
l_int32 | border, | ||
l_int32 | fontsize, | ||
const char * | outdir | ||
) |
[in] | dir | full path to directory of images |
[in] | substr | [optional] can be null |
[in] | nx,ny | in [1, ... 50], tiling factors in each direction |
[in] | tw | target width, in pixels; must be >= 20 |
[in] | spacing | between images, and on outside |
[in] | border | width of additional black border on each image; use 0 for no border |
[in] | fontsize | to print tail of filename with image. Valid set is {4,6,8,10,12,14,16,18,20}. Use 0 to disable. |
[in] | outdir | subdirectory of /tmp to put N-up tiled images |
Notes: (1) Each set of nx * ny images is scaled and tiled into a single image, that is written out to outdir. (2) All images in each nx * ny set are scaled to the same width, tw. This is typically used when all images are roughly the same size. (3) This is useful for generating a pdf from the set of input files, where each page is a tile of (nx * ny) input images. Typical values for nx and ny are in the range [2 ... 5]. (4) If fontsize != 0, each image has the tail of its filename rendered below it.
Definition at line 2426 of file pixafunc2.c.
References convertToNUpPixa(), lept_mkdir(), lept_rmdir(), and pixaGetRenderingDepth().
PIXA* convertToNUpPixa | ( | const char * | dir, |
const char * | substr, | ||
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | tw, | ||
l_int32 | spacing, | ||
l_int32 | border, | ||
l_int32 | fontsize | ||
) |
[in] | dir | full path to directory of images |
[in] | substr | [optional] can be null |
[in] | nx,ny | in [1, ... 50], tiling factors in each direction |
[in] | tw | target width, in pixels; must be >= 20 |
[in] | spacing | between images, and on outside |
[in] | border | width of additional black border on each image; use 0 for no border |
[in] | fontsize | to print tail of filename with image. Valid set is {4,6,8,10,12,14,16,18,20}. Use 0 to disable. |
Notes: (1) See notes for convertToNUpFiles()
Definition at line 2486 of file pixafunc2.c.
References getSortedPathnamesInDirectory(), L_INSERT, L_NOCOPY, pixaConvertToNUpPixa(), pixaDestroy(), pixaReadFilesSA(), sarrayAddString(), sarrayCreate(), sarrayDestroy(), sarrayGetCount(), sarrayGetString(), and splitPathAtDirectory().
Referenced by convertToNUpFiles().
[in] | paa | |
[in] | w,h | if set to 0, the size is determined from the bounding box of the components in pixa |
Notes: (1) Each pix of the paa is displayed at the location given by its box, translated by the box of the containing pixa if it exists.
Definition at line 1543 of file pixafunc2.c.
References boxaDestroy(), boxaGetCount(), boxaGetExtent(), L_CLONE, pixaaGetBoxa(), pixaaGetCount(), pixaaGetPixa(), pixaDestroy(), pixaGetBoxa(), and pixaGetPix().
PIX* pixaaDisplayByPixa | ( | PIXAA * | paa, |
l_int32 | maxnx, | ||
l_float32 | scalefactor, | ||
l_int32 | hspacing, | ||
l_int32 | vspacing, | ||
l_int32 | border | ||
) |
[in] | paa | |
[in] | maxnx | maximum number of columns for rendering each pixa |
[in] | scalefactor | applied to every pix; use 1.0 for no scaling |
[in] | hspacing | between images on a row (in the pixa) |
[in] | vspacing | between tiles rows, each corresponding to a pixa |
[in] | border | width of black border added to each image; use 0 for no border |
Notes: (1) This renders a pixaa into a single image. The pix from each pixa are rendered on a row. If the number of pix in the pixa is larger than maxnx, the pix will be rendered into more than 1 row. To insure that each pixa is rendered into one row, use maxnx at least as large as the max number of pix in the pixa. (2) Each row is tiled such that the top of each pix is aligned and each pix is separated by hspacing from the next one. A black border can be added to each pix. (3) The resulting pix from each row are then rendered vertically, separated by vspacing from each other. (4) The output depth is determined by the largest depth of all the pix in paa. Colormaps are removed.
Definition at line 1644 of file pixafunc2.c.
References L_CLONE, L_INSERT, pixaAddPix(), pixaaGetCount(), pixaaGetPixa(), pixaCreate(), pixaDestroy(), and pixaDisplayTiledInColumns().
Referenced by recogDebugAverages(), and recogShowContent().
PIXA* pixaaDisplayTiledAndScaled | ( | PIXAA * | paa, |
l_int32 | outdepth, | ||
l_int32 | tilewidth, | ||
l_int32 | ncols, | ||
l_int32 | background, | ||
l_int32 | spacing, | ||
l_int32 | border | ||
) |
[in] | paa | |
[in] | outdepth | output depth: 1, 8 or 32 bpp |
[in] | tilewidth | each pix is scaled to this width |
[in] | ncols | number of tiles in each row |
[in] | background | 0 for white, 1 for black; this is the color of the spacing between the images |
[in] | spacing | between images, and on outside |
[in] | border | width of additional black border on each image; use 0 for no border |
Notes: (1) For each pixa, this generates from all the pix a tiled/scaled output pix, and puts it in the output pixa. (2) See comments in pixaDisplayTiledAndScaled().
Definition at line 1705 of file pixafunc2.c.
References L_CLONE, L_INSERT, pixaAddPix(), pixaaGetCount(), pixaaGetPixa(), pixaCreate(), pixaDestroy(), and pixaDisplayTiledAndScaled().
l_ok pixaCompareInPdf | ( | PIXA * | pixa1, |
PIXA * | pixa2, | ||
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | tw, | ||
l_int32 | spacing, | ||
l_int32 | border, | ||
l_int32 | fontsize, | ||
const char * | fileout | ||
) |
[in] | pixa1 | |
[in] | pixa2 | |
[in] | nx,ny | in [1, ... 20], tiling factors in each direction |
[in] | tw | target width, in pixels; must be >= 20 |
[in] | spacing | between images, and on outside |
[in] | border | width of additional black border on each image and on each pair; use 0 for no border |
[in] | fontsize | to print index of each pair of images. Valid set is {4,6,8,10,12,14,16,18,20}. Use 0 to disable. |
[in] | fileout | output pdf file |
Notes: (1) This takes two pixa and renders them interleaved, side-by-side in a pdf. A warning is issued if the input pixa arrays have different lengths. (2) nx and ny specify how many side-by-side pairs are displayed on each pdf page. For example, if nx = 1 and ny = 2, then two pairs are shown, one above the other, on each page. (3) The input pix are scaled to a target width of tw, and then paired with optional spacing between and optional black border of width border. (4) After a pixa is generated of these tiled images, it is written to fileout as a pdf. (5) Typical numbers for the input parameters are: nx = small integer (1 - 4) ny = 2 * nx tw = 200 - 500 pixels spacing = 10 border = 2 fontsize = 10 (6) If fontsize != 0, the index of the pix pair in their pixa is printed out below each pair.
Definition at line 2661 of file pixafunc2.c.
References L_CLONE, pixaConvertToNUpPixa(), pixaConvertToPdf(), pixaDestroy(), pixaGetCount(), pixaInterleave(), sarrayDestroy(), and sarrayGenerateIntegers().
PIXA* pixaConstrainedSelect | ( | PIXA * | pixas, |
l_int32 | first, | ||
l_int32 | last, | ||
l_int32 | nmax, | ||
l_int32 | use_pairs, | ||
l_int32 | copyflag | ||
) |
[in] | pixas | |
[in] | first | first index to choose; >= 0 |
[in] | last | biggest possible index to reach; use -1 to go to the end; otherwise, last >= first |
[in] | nmax | maximum number of pix to select; > 0 |
[in] | use_pairs | 1 = select pairs of adjacent pix; 0 = select individual pix |
[in] | copyflag | L_COPY, L_CLONE |
Notes: (1) See notes in genConstrainedNumaInRange() for how selection is made. (2) This returns a selection of the pix in the input pixa. (3) Use copyflag == L_COPY if you don't want changes in the pix in the returned pixa to affect those in the input pixa.
Definition at line 1922 of file pixafunc2.c.
References genConstrainedNumaInRange(), L_INSERT, numaDestroy(), numaGetCount(), numaGetIValue(), pixaAddPix(), pixaCreate(), pixaGetCount(), and pixaGetPix().
[in] | pixas | |
[in] | thresh | threshold for final binarization from 8 bpp gray |
Definition at line 1753 of file pixafunc2.c.
References L_CLONE, L_COPY, L_INSERT, pixaAddPix(), pixaCreate(), pixaGetBoxa(), pixaGetCount(), pixaGetPix(), pixaSetBoxa(), pixConvertTo1(), and pixDestroy().
[in] | pixas |
Notes: (1) See notes for pixConvertTo32(), applied to each pix in pixas. (2) This can be used to allow 1 bpp pix in a pixa to be displayed with color.
Definition at line 1871 of file pixafunc2.c.
References L_CLONE, L_COPY, L_INSERT, pixaAddPix(), pixaCreate(), pixaGetBoxa(), pixaGetCount(), pixaGetPix(), pixaSetBoxa(), pixConvertTo32(), and pixDestroy().
[in] | pixas | |
[in] | cmapflag | 1 to give pixd a colormap; 0 otherwise |
Notes: (1) See notes for pixConvertTo8(), applied to each pix in pixas.
Definition at line 1792 of file pixafunc2.c.
References L_CLONE, L_COPY, L_INSERT, pixaAddPix(), pixaCreate(), pixaGetBoxa(), pixaGetCount(), pixaGetPix(), pixaSetBoxa(), pixConvertTo8(), and pixDestroy().
[in] | pixas | |
[in] | dither | 1 to dither if necessary; 0 otherwise |
Notes: (1) See notes for pixConvertTo8Colormap(), applied to each pix in pixas.
Definition at line 1831 of file pixafunc2.c.
References L_CLONE, L_COPY, L_INSERT, pixaAddPix(), pixaCreate(), pixaGetBoxa(), pixaGetCount(), pixaGetPix(), pixaSetBoxa(), pixConvertTo8Colormap(), and pixDestroy().
PIXA* pixaConvertToNUpPixa | ( | PIXA * | pixas, |
SARRAY * | sa, | ||
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | tw, | ||
l_int32 | spacing, | ||
l_int32 | border, | ||
l_int32 | fontsize | ||
) |
[in] | pixas | |
[in] | sa | [optional] array of strings associated with each pix |
[in] | nx,ny | in [1, ... 50], tiling factors in each direction |
[in] | tw | target width, in pixels; must be >= 20 |
[in] | spacing | between images, and on outside |
[in] | border | width of additional black border on each image; use 0 for no border |
[in] | fontsize | to print string with each image. Valid set is {4,6,8,10,12,14,16,18,20}. Use 0 to disable. |
Notes: (1) This takes an input pixa and an optional array of strings, and generates a pixa of NUp tiles from the input, labeled with the strings if they exist and fontsize != 0. (2) See notes for convertToNUpFiles()
Definition at line 2550 of file pixafunc2.c.
References bmfCreate(), bmfDestroy(), L_ADD_BELOW, L_CLONE, L_INSERT, L_NOCOPY, pixaAddPix(), pixaCreate(), pixAddTextlines(), pixaDestroy(), pixaDisplayTiledAndScaled(), pixaGetCount(), pixaGetPix(), pixaGetRenderingDepth(), pixClone(), pixDestroy(), pixScaleToSize(), sarrayGetCount(), and sarrayGetString().
Referenced by convertToNUpPixa(), and pixaCompareInPdf().
[in] | pixa | |
[in] | w,h | if set to 0, the size is determined from the bounding box of the components in pixa |
Notes: (1) This uses the boxes to place each pix in the rendered composite. (2) Set w = h = 0 to use the b.b. of the components to determine the size of the returned pix. (3) Uses the first pix in pixa to determine the depth. (4) The background is written "white". On 1 bpp, each successive pix is "painted" (adding foreground), whereas for grayscale or color each successive pix is blitted with just the src. (5) If the pixa is empty, returns an empty 1 bpp pix.
Definition at line 191 of file pixafunc2.c.
References boxaDestroy(), boxaGetExtent(), L_CLONE, pixaGetBoxa(), pixaGetCount(), pixaGetPix(), and pixCreate().
Referenced by pixaDisplayTiledByIndex(), pixSelectByArea(), pixSelectByAreaFraction(), pixSelectByPerimSizeRatio(), pixSelectByPerimToAreaRatio(), pixSelectBySize(), pixSelectByWidthHeightRatio(), and wshedRenderColors().
PIX* pixaDisplayLinearly | ( | PIXA * | pixas, |
l_int32 | direction, | ||
l_float32 | scalefactor, | ||
l_int32 | background, | ||
l_int32 | spacing, | ||
l_int32 | border, | ||
BOXA ** | pboxa | ||
) |
[in] | pixas | |
[in] | direction | L_HORIZ or L_VERT |
[in] | scalefactor | applied to every pix; use 1.0 for no scaling |
[in] | background | 0 for white, 1 for black; this is the color of the spacing between the images |
[in] | spacing | between images, and on outside |
[in] | border | width of black border added to each image; use 0 for no border |
[out] | pboxa | [optional] location of images in output pix |
Notes: (1) This puts each pix, sequentially, in a line, either horizontally or vertically. (2) If any pix has a colormap, all pix are rendered in rgb. (3) The boxa gives the location of each image.
Definition at line 339 of file pixafunc2.c.
PIXA* pixaDisplayMultiTiled | ( | PIXA * | pixas, |
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | maxw, | ||
l_int32 | maxh, | ||
l_float32 | scalefactor, | ||
l_int32 | spacing, | ||
l_int32 | border | ||
) |
[in] | pixas | |
[in] | nx,ny | in [1, ... 50], tiling factors in each direction |
[in] | maxw,maxh | max sizes to keep |
[in] | scalefactor | scale each image by this |
[in] | spacing | between images, and on outside |
[in] | border | width of additional black border on each image; use 0 for no border |
Notes: (1) Each set of nx * ny images is optionally scaled and saved into a new pix, and then aggregated. (2) Set maxw = maxh = 0 if you want to include all pix from pixs. (3) This is useful for generating a pdf from the output pixa, where each page is a tile of (nx * ny) images from the input pixa.
Definition at line 2262 of file pixafunc2.c.
References L_CLONE, L_COPY, L_INSERT, L_SELECT_IF_BOTH, L_SELECT_IF_LTE, pixaAddPix(), pixaCopy(), pixaCreate(), pixaDestroy(), pixaDisplayTiledInColumns(), pixaGetCount(), pixaGetPix(), and pixaSelectBySize().
PIX* pixaDisplayOnLattice | ( | PIXA * | pixa, |
l_int32 | cellw, | ||
l_int32 | cellh, | ||
l_int32 * | pncols, | ||
BOXA ** | pboxa | ||
) |
[in] | pixa | |
[in] | cellw | lattice cell width |
[in] | cellh | lattice cell height |
[out] | pncols | [optional] number of columns in output lattice |
[out] | pboxa | [optional] location of images in lattice |
Notes: (1) This places each pix on sequentially on a regular lattice in the rendered composite. If a pix is too large to fit in the allocated lattice space, it is not rendered. (2) If any pix has a colormap, all pix are rendered in rgb. (3) This is useful when putting bitmaps of components, such as characters, into a single image. (4) Save the number of tiled images in the text field of the pix, in the format: n = d. This survives write/read into png files, for example. (5) The boxa gives the location of each image. The UL corner of each image is on a lattice cell corner. Omitted images (due to size) are assigned an invalid width and height of 0.
Definition at line 430 of file pixafunc2.c.
References L_CLONE, L_INSERT, pixaAddPix(), pixaAnyColormaps(), pixaCopy(), pixaCreate(), pixaGetCount(), pixaGetPix(), pixaVerifyDepth(), pixConvertTo32(), and pixDestroy().
PIX* pixaDisplayPairTiledInColumns | ( | PIXA * | pixas1, |
PIXA * | pixas2, | ||
l_int32 | nx, | ||
l_float32 | scalefactor, | ||
l_int32 | spacing1, | ||
l_int32 | spacing2, | ||
l_int32 | border1, | ||
l_int32 | border2, | ||
l_int32 | fontsize, | ||
l_int32 | startindex, | ||
SARRAY * | sa | ||
) |
pixaDisplayPairTiledInColumns()
[in] | pixas1 | |
[in] | pixas2 | |
[in] | nx | number of columns in output image |
[in] | scalefactor | applied to every pix; use 1.0 for no scaling |
[in] | spacing1 | between images within a pair |
[in] | spacing2 | between image pairs, and on outside |
[in] | border1 | width of black border added to each image; use 0 for no border |
[in] | border2 | width of black border added to each image pair. use 0 for no border |
[in] | fontsize | to print index below each pair. Valid set is {4,6,8,10,12,14,16,18,20}. Use 0 to disable. |
[in] | startindex | index for the first pair; ignore if fontsize= 0 |
[in] | sa | [optional] array of text strings to display |
Notes: (1) This renders a pair of pixa in a single image with &nx columns of tiled pairs. The background color is white, and each row is tiled such that the top of each pix is aligned. The pix are displayed in pairs, taken from the input pixas. Input pixas1 and pixas2 must have the same count of pix. (2) If fontsize != 0, text is displayed below each pair, and the output depth is 32 bpp. If sa is defined, the text is taken sequentially from sa; otherwise, an integer is displayed with numbers chosen consecutively starting with startindex. (3) If fontsize == 0, the output depth is determined by the largest depth required by the pix in the pixa. Colormaps are removed. (4) Start with these values and tune for aesthetics: nx = 5, spacing1 = spacing2 = 15, border1 = border2 = 2, fontsize = 8.
Definition at line 1394 of file pixafunc2.c.
References L_CLONE, L_GET_BLACK_VAL, L_GET_WHITE_VAL, L_INSERT, L_INTEGER_VALUE, numaConvertToSarray(), numaDestroy(), numaMakeSequence(), pixaAddPix(), pixaCreate(), pixAddBlackOrWhiteBorder(), pixaDestroy(), pixaDisplayTiledInColumns(), pixaDisplayTiledWithText(), pixaGetCount(), pixaGetPix(), pixaGetRenderingDepth(), pixaSetText(), pixaSizeRange(), pixClone(), pixConvertTo32(), pixConvertTo8(), pixDestroy(), pixScale(), and sarrayDestroy().
[in] | pixa | 1 bpp regions, with boxa delineating those regions |
[in] | w,h | if set to 0, the size is determined from the bounding box of the components in pixa |
Notes: (1) This uses the boxes to place each pix in the rendered composite. The fg of each pix in pixa, such as a single connected component or a line of text, is given a random color. (2) By default, the background color is black (cmap index 0). This can be changed by pixcmapResetColor()
Definition at line 267 of file pixafunc2.c.
References boxaDestroy(), boxaGetExtent(), L_CLONE, pixaGetBoxa(), pixaGetBoxGeometry(), pixaGetCount(), pixaGetPix(), pixaVerifyDepth(), pixcmapCreateRandom(), pixCreate(), and pixSetColormap().
Referenced by wshedRenderColors().
[in] | pixa | |
[in] | maxwidth | of output image |
[in] | background | 0 for white, 1 for black |
[in] | spacing |
Notes: (1) This renders a pixa to a single image of width not to exceed maxwidth, with background color either white or black, and with each subimage spaced on a regular lattice. (2) The lattice size is determined from the largest width and height, separately, of all pix in the pixa. (3) All pix in the pixa must be of equal depth. (4) If any pix has a colormap, all pix are rendered in rgb. (5) Careful: because no components are omitted, this is dangerous if there are thousands of small components and one or more very large one, because the size of the resulting pix can be huge!
Definition at line 618 of file pixafunc2.c.
References L_CLONE, L_INSERT, pixaAddPix(), pixaAnyColormaps(), pixaCopy(), pixaCreate(), pixaDestroy(), pixaGetCount(), pixaGetDepthInfo(), pixaGetPix(), pixaSizeRange(), pixConvertTo32(), pixCreate(), pixDestroy(), and pixSetAll().
PIX* pixaDisplayTiledAndScaled | ( | PIXA * | pixa, |
l_int32 | outdepth, | ||
l_int32 | tilewidth, | ||
l_int32 | ncols, | ||
l_int32 | background, | ||
l_int32 | spacing, | ||
l_int32 | border | ||
) |
[in] | pixa | |
[in] | outdepth | output depth: 1, 8 or 32 bpp |
[in] | tilewidth | each pix is scaled to this width |
[in] | ncols | number of tiles in each row |
[in] | background | 0 for white, 1 for black; this is the color of the spacing between the images |
[in] | spacing | between images, and on outside |
[in] | border | width of additional black border on each image; use 0 for no border |
Notes: (1) This can be used to tile a number of renderings of an image that are at different scales and depths. (2) Each image, after scaling and optionally adding the black border, has width 'tilewidth'. Thus, the border does not affect the spacing between the image tiles. The maximum allowed border width is tilewidth / 5.
Definition at line 1025 of file pixafunc2.c.
References L_CLONE, L_INSERT, pixaAddPix(), pixaCreate(), pixAddBorder(), pixaDestroy(), pixaGetCount(), pixaGetPix(), pixClone(), pixConvertTo1(), pixConvertTo32(), pixConvertTo8(), pixCreate(), pixDestroy(), pixGetDimensions(), pixScale(), pixScaleToGray(), and pixSetAll().
Referenced by pixaaDisplayTiledAndScaled(), pixacompDisplayTiledAndScaled(), pixaConvertToNUpPixa(), selaAddCrossJunctions(), and selaAddTJunctions().
PIX* pixaDisplayTiledByIndex | ( | PIXA * | pixa, |
NUMA * | na, | ||
l_int32 | width, | ||
l_int32 | spacing, | ||
l_int32 | border, | ||
l_int32 | fontsize, | ||
l_uint32 | textcolor | ||
) |
[in] | pixa | |
[in] | na | numa with indices corresponding to the pix in pixa |
[in] | width | each pix is scaled to this width |
[in] | spacing | between images, and on outside |
[in] | border | width of black border added to each image; use 0 for no border |
[in] | fontsize | 4, 6, ... 20 |
[in] | textcolor | 0xrrggbb00 |
Notes: (1) This renders a pixa to a single image with white background color, where the pix are placed in columns given by the index value in the numa. Each pix is separated by spacing from the adjacent ones, and an optional border is placed around them. (2) Up to 127 chars of text in the pix text field are rendered below each pix. Use newlines in the text field to write the text in multiple lines that fit within the pix width. (3) To avoid having empty columns, if there are N different index values, they should be in [0 ... N-1]. (4) All pix are converted to 32 bpp.
Definition at line 1272 of file pixafunc2.c.
References bmfCreate(), bmfDestroy(), boxCreate(), L_ADD_BELOW, L_CLONE, L_INSERT, lept_roundftoi(), numaDestroy(), numaGetCount(), numaGetIValue(), numaGetMax(), numaMakeConstant(), numaSetValue(), pixaAddBox(), pixaAddPix(), pixaCreate(), pixAddBorderGeneral(), pixAddTextlines(), pixaDestroy(), pixaDisplay(), pixaGetCount(), pixaGetPix(), pixClone(), pixConvertTo32(), pixDestroy(), pixGetDimensions(), pixGetText(), and pixScaleToSize().
PIX* pixaDisplayTiledInColumns | ( | PIXA * | pixas, |
l_int32 | nx, | ||
l_float32 | scalefactor, | ||
l_int32 | spacing, | ||
l_int32 | border | ||
) |
[in] | pixas | |
[in] | nx | number of columns in output image |
[in] | scalefactor | applied to every pix; use 1.0 for no scaling |
[in] | spacing | between images, and on outside; can be < 0 |
[in] | border | width of black border added to each image; use 0 for no border |
Notes: (1) This renders a pixa to a single image with &nx columns of subimages. The background color is white, and each row is tiled such that the top of each pix is aligned and each pix is separated by 'spacing' from the next one. A black border can be added to each pix. (2) The output depth is determined by the largest depth required by the pix in the pixa. Colormaps are removed. (3) A serialized boxa giving the location in pixd of each input pix (without added border) is stored in the text string of pixd. This allows, e.g., regeneration of a pixa from pixd, using pixaCreateFromBoxa(). If there is no scaling and the depth of each input pix in the pixa is the same, this tiling operation can be inverted using the boxa (except for loss of text in each of the input pix): pix1 = pixaDisplayTiledInColumns(pixa1, 3, 1.0, 0, 30, 2); char *boxatxt = pixGetText(pix1); boxa1 = boxaReadMem((l_uint8 *)boxatxt, strlen(boxatxt)); pixa2 = pixaCreateFromBoxa(pix1, boxa1, NULL);
Definition at line 912 of file pixafunc2.c.
References L_CLONE, pixaConvertToSameDepth(), pixaCreate(), pixAddBorder(), pixaGetCount(), pixaGetDepthInfo(), pixaGetPix(), pixClone(), and pixScale().
Referenced by boxaReconcileAllByMedian(), pixaaDisplayByPixa(), pixaDisplayMultiTiled(), pixaDisplayPairTiledInColumns(), pixDisplayColorArray(), and pixMakeGamutRGB().
PIX* pixaDisplayTiledInRows | ( | PIXA * | pixa, |
l_int32 | outdepth, | ||
l_int32 | maxwidth, | ||
l_float32 | scalefactor, | ||
l_int32 | background, | ||
l_int32 | spacing, | ||
l_int32 | border | ||
) |
[in] | pixa | |
[in] | outdepth | output depth: 1, 8 or 32 bpp |
[in] | maxwidth | of output image |
[in] | scalefactor | applied to every pix; use 1.0 for no scaling |
[in] | background | 0 for white, 1 for black; this is the color of the spacing between the images |
[in] | spacing | between images, and on outside |
[in] | border | width of black border added to each image; use 0 for no border |
Notes: (1) This renders a pixa to a single image of width not to exceed maxwidth, with background color either white or black, and with each row tiled such that the top of each pix is aligned and separated by 'spacing' from the next one. A black border can be added to each pix. (2) All pix are converted to outdepth; existing colormaps are removed. (3) This does a reasonably spacewise-efficient job of laying out the individual pix images into a tiled composite. (4) A serialized boxa giving the location in pixd of each input pix (without added border) is stored in the text string of pixd. This allows, e.g., regeneration of a pixa from pixd, using pixaCreateFromBoxa(). If there is no scaling and the depth of each input pix in the pixa is the same, this tiling operation can be inverted using the boxa (except for loss of text in each of the input pix): pix1 = pixaDisplayTiledInRows(pixa1, 1, 1500, 1.0, 0, 30, 0); char *boxatxt = pixGetText(pix1); boxa1 = boxaReadMem((l_uint8 *)boxatxt, strlen(boxatxt)); pixa2 = pixaCreateFromBoxa(pix1, boxa1, 0, 0, NULL);
Definition at line 730 of file pixafunc2.c.
References boxaCreate(), L_CLONE, L_INSERT, numaAddNumber(), numaCreate(), numaDestroy(), numaGetCount(), numaGetIValue(), pixaAddPix(), pixaCreate(), pixAddBorder(), pixaDestroy(), pixaGetCount(), pixaGetPix(), pixaGetPixDimensions(), pixClone(), pixConvertTo1(), pixConvertTo32(), pixConvertTo8(), pixCreate(), pixDestroy(), pixScale(), and pixSetAll().
Referenced by boxaCompareRegions(), boxaDisplayTiled(), dewarpaShowArrays(), pixaDisplayTiledWithText(), pixaSplitIntoFiles(), pixCompareGrayByHisto(), recogDisplayOutlier(), recogShowAverageTemplates(), recogShowMatch(), and selaDisplayInPix().
PIX* pixaDisplayTiledWithText | ( | PIXA * | pixa, |
l_int32 | maxwidth, | ||
l_float32 | scalefactor, | ||
l_int32 | spacing, | ||
l_int32 | border, | ||
l_int32 | fontsize, | ||
l_uint32 | textcolor | ||
) |
[in] | pixa | |
[in] | maxwidth | of output image |
[in] | scalefactor | applied to every pix; use 1.0 for no scaling |
[in] | spacing | between images, and on outside |
[in] | border | width of black border added to each image; use 0 for no border |
[in] | fontsize | 4, 6, ... 20 |
[in] | textcolor | 0xrrggbb00 |
Notes: (1) This is a version of pixaDisplayTiledInRows() that prints, below each pix, the text in the pix text field. Up to 127 chars of text in the pix text field are rendered below each pix. (2) It renders a pixa to a single image of width not to exceed maxwidth, with white background color, with each row tiled such that the top of each pix is aligned and separated by spacing from the next one. (3) All pix are converted to 32 bpp. (4) This does a reasonably spacewise-efficient job of laying out the individual pix images into a tiled composite.
Definition at line 1178 of file pixafunc2.c.
References bmfCreate(), bmfDestroy(), L_ADD_BELOW, L_CLONE, L_INSERT, pixaAddPix(), pixaCreate(), pixAddBorderGeneral(), pixAddSingleTextblock(), pixaDestroy(), pixaDisplayTiledInRows(), pixaGetCount(), pixaGetPix(), pixaSizeRange(), pixClone(), pixConvertTo32(), pixDestroy(), and pixGetText().
Referenced by pixaDisplayPairTiledInColumns(), pixDisplayOutliers(), and recogMakeBootDigitTemplates().
PIX* pixaDisplayUnsplit | ( | PIXA * | pixa, |
l_int32 | nx, | ||
l_int32 | ny, | ||
l_int32 | borderwidth, | ||
l_uint32 | bordercolor | ||
) |
[in] | pixa | |
[in] | nx | number of mosaic cells horizontally |
[in] | ny | number of mosaic cells vertically |
[in] | borderwidth | of added border on all sides |
[in] | bordercolor | in our RGBA format: 0xrrggbbaa |
Notes: (1) This is a logical inverse of pixaSplitPix(). It constructs a pix from a mosaic of tiles, all of equal size. (2) For added generality, a border of arbitrary color can be added to each of the tiles. (3) In use, pixa will typically have either been generated from pixaSplitPix() or will derived from a pixa that was so generated. (4) All pix in the pixa must be of equal depth, and, if colormapped, have the same colormap.
Definition at line 545 of file pixafunc2.c.
References L_CLONE, PIX_SRC, pixaGetCount(), pixaGetPix(), pixaGetPixDimensions(), pixCopyColormap(), pixCreate(), pixDestroy(), pixRasterop(), and pixSetAllArbitrary().
PIXA* pixaMakeFromTiledPix | ( | PIX * | pixs, |
l_int32 | w, | ||
l_int32 | h, | ||
l_int32 | start, | ||
l_int32 | num, | ||
BOXA * | boxa | ||
) |
[in] | pixs | any depth; colormap OK |
[in] | w | width of each tile |
[in] | h | height of each tile |
[in] | start | first tile to use |
[in] | num | number of tiles; use 0 to go to the end |
[in] | boxa | [optional] location of rectangular regions to be extracted |
Notes: (1) Operations that generate a pix by tiling from a pixa, and the inverse that generate a pixa from tiles of a pix, are useful. One such pair is pixaDisplayUnsplit() and pixaSplitPix(). This function is a very simple one that generates a pixa from tiles of a pix. There are two cases:
Definition at line 2143 of file pixafunc2.c.
References pixaCreate(), pixaCreateFromBoxa(), pixGetDimensions(), and pixGetTileCount().
Referenced by pixaMakeFromTiledPixa().
[in] | pixas | of mosaiced templates, one for each digit |
[in] | w | width of samples (use 0 for default = 20) |
[in] | h | height of samples (use 0 for default = 30) |
[in] | nsamp | number of requested samples (use 0 for default = 100) |
Notes: (1) This converts from a compressed representation of 1 bpp digit templates to a pixa where each pix has a single labeled template. (2) The mosaics hold 100 templates each, and the number of templates nsamp selected for each digit can be between 1 and 100. (3) Each mosaic has the number of images written in the text field, and the i-th pix contains samples of the i-th digit. That value is written into the text field of each template in the output.
Definition at line 2065 of file pixafunc2.c.
References L_CLONE, pixaCreate(), pixaDestroy(), pixaGetPix(), pixaJoin(), pixaMakeFromTiledPix(), pixaSetText(), pixDestroy(), and pixGetTileCount().
l_ok pixaSelectToPdf | ( | PIXA * | pixas, |
l_int32 | first, | ||
l_int32 | last, | ||
l_int32 | res, | ||
l_float32 | scalefactor, | ||
l_int32 | type, | ||
l_int32 | quality, | ||
l_uint32 | color, | ||
l_int32 | fontsize, | ||
const char * | fileout | ||
) |
[in] | pixas | |
[in] | first | first index to choose; >= 0 |
[in] | last | biggest possible index to reach; use -1 to go to the end; otherwise, last >= first |
[in] | res | override the resolution of each input image, in ppi; use 0 to respect the resolution embedded in the input |
[in] | scalefactor | scaling factor applied to each image; > 0.0 |
[in] | type | encoding type (L_JPEG_ENCODE, L_G4_ENCODE, L_FLATE_ENCODE, or 0 for default |
[in] | quality | used for JPEG only; 0 for default (75) |
[in] | color | of numbers added to each image (e.g., 0xff000000) |
[in] | fontsize | to print number below each image. The valid set is {4,6,8,10,12,14,16,18,20}. Use 0 to disable. |
[in] | fileout | pdf file of all images |
Notes: (1) This writes a pdf of the selected images from pixas, one to a page. They are optionally scaled and annotated with the index printed to the left of the image. (2) If the input images are 1 bpp and you want the numbers to be in color, first promote each pix to 8 bpp with a colormap: pixa1 = pixaConvertTo8(pixas, 1); and then call this function with the specified color
Definition at line 1988 of file pixafunc2.c.
References bmfCreate(), bmfDestroy(), L_ADD_LEFT, L_CLONE, L_FLATE_ENCODE, numaDestroy(), numaMakeSequence(), pixaAddTextNumber(), pixaConvertToPdf(), pixaCopy(), pixaDestroy(), pixaGetCount(), and pixaSelectRange().
l_ok pixaSplitIntoFiles | ( | PIXA * | pixas, |
l_int32 | nsplit, | ||
l_float32 | scale, | ||
l_int32 | outwidth, | ||
l_int32 | write_pixa, | ||
l_int32 | write_pix, | ||
l_int32 | write_pdf | ||
) |
[in] | pixas | |
[in] | nsplit | split pixas into this number of pixa; >= 2 |
[in] | scale | scalefactor applied to each pix |
[in] | outwidth | the maxwidth parameter of tiled images for write_pix |
[in] | write_pixa | 1 to write the split pixa as separate files |
[in] | write_pix | 1 to write tiled images of the split pixa |
[in] | write_pdf | 1 to write pdfs of the split pixa |
Notes: (1) For each requested output, nsplit files are written into directory /tmp/lept/split/. (2) This is useful when a pixa is so large that the images are not conveniently displayed as a single tiled image at full resolution.
Definition at line 2339 of file pixafunc2.c.
References L_CLONE, L_INSERT, lept_mkdir(), lept_stderr(), pixaAddPix(), pixaCreate(), pixaDisplayTiledInRows(), pixaGetCount(), pixaGetPix(), pixaWriteDebug(), pixDestroy(), and pixScale().
l_ok pixGetTileCount | ( | PIX * | pix, |
l_int32 * | pn | ||
) |
[in] | pix | |
[out] | *pn | number embedded in pix text field |
Notes: (1) If the pix was made by pixaDisplayOnLattice(), the number of tiled images is written into the text field, in the format n = <number>. (2) This returns 0 if the data is not in the text field, or on error.
Definition at line 2216 of file pixafunc2.c.
References pixGetText().
Referenced by pixaMakeFromTiledPix(), and pixaMakeFromTiledPixa().