Leptonica
1.54
|
PIX* fpixAutoRenderContours | ( | FPIX * | fpix, |
l_int32 | ncontours | ||
) |
Input: pixs (8 or 16 bpp; no colormap) ncontours (> 1, < 500, typ. about 50) Return: pixd (8 bpp), or null on error
Notes: (1) The increment is set to get approximately . (2) The proximity to the target value for contour display is set at 0.1 * increment. (3) Negative contours are rendered in red; 0 or positive contours are rendered in black.
PIX* fpixRenderContours | ( | FPIX * | fpixs, |
l_float32 | incr, | ||
l_float32 | proxim | ||
) |
Input: fpixs incr (increment between contours; must be > 0.0) proxim (required proximity to target value; typ. 0.1 * incr) Return: pixd (8 bpp), or null on error
Notes: (1) Values are displayed when val/incr is close to an integer. (2) Negative contours are rendered in red; 0 or positive contours are rendered in black.
PTAA* generatePtaaBoxa | ( | BOXA * | boxa | ) |
Input: boxa Return: ptaa, or null on error
Notes: (1) This generates a pta of the four corners for each box in the boxa. (2) Each of these pta can be rendered onto a pix with random colors, by using pixRenderRandomCmapPtaa() with closeflag = 1.
PTAA* generatePtaaHashBoxa | ( | BOXA * | boxa, |
l_int32 | spacing, | ||
l_int32 | width, | ||
l_int32 | orient, | ||
l_int32 | outline | ||
) |
Input: boxa spacing (spacing between hash lines; must be > 1) width (hash line width) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) Return: ptaa, or null on error
Notes: (1) The orientation takes on one of 4 orientations (horiz, vertical, slope +1, slope -1). (2) The full outline is also drawn if = 1. (3) Each of these pta can be rendered onto a pix with random colors, by using pixRenderRandomCmapPtaa() with closeflag = 1.
PTA* generatePtaBox | ( | BOX * | box, |
l_int32 | width | ||
) |
Input: box width (of line) Return: ptad, or null on error
Notes: (1) Because the box is constructed so that we don't have any overlapping lines, there is no need to remove duplicates.
PTA* generatePtaBoxa | ( | BOXA * | boxa, |
l_int32 | width, | ||
l_int32 | removedups | ||
) |
Input: boxa width removedups (1 to remove, 0 to leave) Return: ptad, or null on error
Notes: (1) If the boxa has overlapping boxes, and if blending will be used to give a transparent effect, transparency artifacts at line intersections can be removed using removedups = 1.
PTA* generatePtaFilledCircle | ( | l_int32 | radius | ) |
Input: radius Return: pta, or null on error
Notes: (1) The circle is has diameter = 2 * radius + 1. (2) It is located with the center of the circle at the point (radius, radius). (3) Consequently, it typically must be translated if it is to represent a set of pixels in an image.
PTA* generatePtaHashBox | ( | BOX * | box, |
l_int32 | spacing, | ||
l_int32 | width, | ||
l_int32 | orient, | ||
l_int32 | outline | ||
) |
Input: box spacing (spacing between lines; must be > 1) width (of line) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) Return: ptad, or null on error
Notes: (1) The orientation takes on one of 4 orientations (horiz, vertical, slope +1, slope -1). (2) The full outline is also drawn if = 1.
Input: x1, y1 (end point 1) x2, y2 (end point 2) Return: pta, or null on error
Input: x, y (point of origination) length (of line, including starting point) radang (angle in radians, CW from horizontal) Return: pta, or null on error
Notes: (1) The of the line is 1 greater than the distance used in locatePtRadially(). Example: a distance of 1 gives rise to a length of 2.
Input: pta (vertices of polyline) width closeflag (1 to close the contour; 0 otherwise) removedups (1 to remove, 0 to leave) Return: ptad, or null on error
Notes: (1) If the boxa has overlapping boxes, and if blending will be used to give a transparent effect, transparency artifacts at line intersections can be removed using removedups = 1.
Input: x1, y1 (end point 1) x2, y2 (end point 2) width Return: ptaj, or null on error
l_int32 locatePtRadially | ( | l_int32 | xr, |
l_int32 | yr, | ||
l_float64 | dist, | ||
l_float64 | radang, | ||
l_float64 * | px, | ||
l_float64 * | py | ||
) |
Input: xr, yr (reference point) radang (angle in radians, CW from horizontal) dist (distance of point from reference point along line given by the specified angle) &x, &y (<return> location of point) Return: 0 if OK, 1 on error
Input: pix box width (thickness of box lines) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error
Input: pix boxa width (thickness of line) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error
l_int32 pixRenderBoxaArb | ( | PIX * | pix, |
BOXA * | boxa, | ||
l_int32 | width, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval | ||
) |
Input: pix boxa width (thickness of line) rval, gval, bval Return: 0 if OK, 1 on error
l_int32 pixRenderBoxaBlend | ( | PIX * | pix, |
BOXA * | boxa, | ||
l_int32 | width, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval, | ||
l_float32 | fract, | ||
l_int32 | removedups | ||
) |
Input: pix boxa width (thickness of line) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) removedups (1 to remove; 0 otherwise) Return: 0 if OK, 1 on error
l_int32 pixRenderBoxArb | ( | PIX * | pix, |
BOX * | box, | ||
l_int32 | width, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval | ||
) |
Input: pix (any depth, cmapped ok) box width (thickness of box lines) rval, gval, bval Return: 0 if OK, 1 on error
l_int32 pixRenderBoxBlend | ( | PIX * | pix, |
BOX * | box, | ||
l_int32 | width, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval, | ||
l_float32 | fract | ||
) |
Input: pix box width (thickness of box lines) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) Return: 0 if OK, 1 on error
Input: pixs (8 or 16 bpp; no colormap) startval (value of lowest contour; must be in [0 ... maxval]) incr (increment to next contour; must be > 0) outdepth (either 1 or depth of pixs) Return: pixd, or null on error
Notes: (1) The output can be either 1 bpp, showing just the contour lines, or a copy of the input pixs with the contour lines superposed.
l_int32 pixRenderHashBox | ( | PIX * | pix, |
BOX * | box, | ||
l_int32 | spacing, | ||
l_int32 | width, | ||
l_int32 | orient, | ||
l_int32 | outline, | ||
l_int32 | op | ||
) |
Input: pix box spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error
l_int32 pixRenderHashBoxArb | ( | PIX * | pix, |
BOX * | box, | ||
l_int32 | spacing, | ||
l_int32 | width, | ||
l_int32 | orient, | ||
l_int32 | outline, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval | ||
) |
Input: pix box spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) rval, gval, bval Return: 0 if OK, 1 on error
l_int32 pixRenderHashBoxBlend | ( | PIX * | pix, |
BOX * | box, | ||
l_int32 | spacing, | ||
l_int32 | width, | ||
l_int32 | orient, | ||
l_int32 | outline, | ||
l_int32 | rval, | ||
l_int32 | gval, | ||
l_int32 | bval, | ||
l_float32 | fract | ||
) |
Input: pix box spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) Return: 0 if OK, 1 on error
l_int32 pixRenderLine | ( | PIX * | pix, |
l_int32 | x1, | ||
l_int32 | y1, | ||
l_int32 | x2, | ||
l_int32 | y2, | ||
l_int32 | width, | ||
l_int32 | op | ||
) |
Input: pix x1, y1 x2, y2 width (thickness of line) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error
l_int32 pixRenderLineArb | ( | PIX * | pix, |
l_int32 | x1, | ||
l_int32 | y1, | ||
l_int32 | x2, | ||
l_int32 | y2, | ||
l_int32 | width, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval | ||
) |
Input: pix x1, y1 x2, y2 width (thickness of line) rval, gval, bval Return: 0 if OK, 1 on error
l_int32 pixRenderLineBlend | ( | PIX * | pix, |
l_int32 | x1, | ||
l_int32 | y1, | ||
l_int32 | x2, | ||
l_int32 | y2, | ||
l_int32 | width, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval, | ||
l_float32 | fract | ||
) |
Input: pix x1, y1 x2, y2 width (thickness of line) rval, gval, bval fract Return: 0 if OK, 1 on error
Input: pix ptas width (thickness of line) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) closeflag (1 to close the contour; 0 otherwise) Return: 0 if OK, 1 on error
Note: this renders a closed contour.
l_int32 pixRenderPolylineArb | ( | PIX * | pix, |
PTA * | ptas, | ||
l_int32 | width, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval, | ||
l_int32 | closeflag | ||
) |
Input: pix ptas width (thickness of line) rval, gval, bval closeflag (1 to close the contour; 0 otherwise) Return: 0 if OK, 1 on error
Note: this renders a closed contour.
l_int32 pixRenderPolylineBlend | ( | PIX * | pix, |
PTA * | ptas, | ||
l_int32 | width, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval, | ||
l_float32 | fract, | ||
l_int32 | closeflag, | ||
l_int32 | removedups | ||
) |
Input: pix ptas width (thickness of line) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) closeflag (1 to close the contour; 0 otherwise) removedups (1 to remove; 0 otherwise) Return: 0 if OK, 1 on error
l_int32 pixRenderPta | ( | PIX * | pix, |
PTA * | pta, | ||
l_int32 | op | ||
) |
Input: pix pta (arbitrary set of points) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error
Notes: (1) L_SET_PIXELS puts all image bits in each pixel to 1 (black for 1 bpp; white for depth > 1) (2) L_CLEAR_PIXELS puts all image bits in each pixel to 0 (white for 1 bpp; black for depth > 1) (3) L_FLIP_PIXELS reverses all image bits in each pixel (4) This function clips the rendering to the pix. It performs clipping for functions such as pixRenderLine(), pixRenderBox() and pixRenderBoxa(), that call pixRenderPta().
Input: pix (any depth, cmapped ok) pta (arbitrary set of points) rval, gval, bval Return: 0 if OK, 1 on error
Notes: (1) If pix is colormapped, render this color on each pixel. (2) If pix is not colormapped, do the best job you can using the input colors:
l_int32 pixRenderPtaBlend | ( | PIX * | pix, |
PTA * | pta, | ||
l_uint8 | rval, | ||
l_uint8 | gval, | ||
l_uint8 | bval, | ||
l_float32 | fract | ||
) |
Input: pix (32 bpp rgb) pta (arbitrary set of points) rval, gval, bval Return: 0 if OK, 1 on error
Notes: (1) This function clips the rendering to the pix.
PIX* pixRenderRandomCmapPtaa | ( | PIX * | pix, |
PTAA * | ptaa, | ||
l_int32 | polyflag, | ||
l_int32 | width, | ||
l_int32 | closeflag | ||
) |
Input: pix (1, 2, 4, 8, 16, 32 bpp) ptaa polyflag (1 to interpret each Pta as a polyline; 0 to simply render the Pta as a set of pixels) width (thickness of line; use only for polyline) closeflag (1 to close the contour; 0 otherwise; use only for polyline mode) Return: pixd (cmapped, 8 bpp) or null on error
Notes: (1) This is a debugging routine, that displays a set of pixels, selected by the set of Ptas in a Ptaa, in a random color in a pix. (2) If == 1, each Pta is considered to be a polyline, and is rendered using and . Each polyline is rendered in a random color. (3) If == 0, all points in each Pta are rendered in a random color. The and parameters are ignored. (4) The output pix is 8 bpp and colormapped. Up to 254 different, randomly selected colors, can be used. (5) The rendered pixels replace the input pixels. They will be clipped silently to the input pix.