Leptonica 1.68
C Image Processing Library

graphics.c File Reference

Rendering shapes from lines (using Pta representation) More...

#include <stdio.h>
#include <string.h>
#include <math.h>
#include "allheaders.h"

Go to the source code of this file.

Functions

PTAgeneratePtaLine (l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2)
PTAgeneratePtaWideLine (l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width)
PTAgeneratePtaBox (BOX *box, l_int32 width)
PTAgeneratePtaHashBox (BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline)
PTAgeneratePtaBoxa (BOXA *boxa, l_int32 width, l_int32 removedups)
PTAAgeneratePtaaBoxa (BOXA *boxa)
PTAAgeneratePtaaHashBoxa (BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline)
PTAgeneratePtaPolyline (PTA *ptas, l_int32 width, l_int32 closeflag, l_int32 removedups)
PTAgeneratePtaFilledCircle (l_int32 radius)
PTAgeneratePtaLineFromPt (l_int32 x, l_int32 y, l_float64 length, l_float64 radang)
l_int32 locatePtRadially (l_int32 xr, l_int32 yr, l_float64 dist, l_float64 radang, l_float64 *px, l_float64 *py)
l_int32 pixRenderPta (PIX *pix, PTA *pta, l_int32 op)
l_int32 pixRenderPtaArb (PIX *pix, PTA *pta, l_uint8 rval, l_uint8 gval, l_uint8 bval)
l_int32 pixRenderPtaBlend (PIX *pix, PTA *pta, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract)
l_int32 pixRenderLine (PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_int32 op)
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)
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)
l_int32 pixRenderBox (PIX *pix, BOX *box, l_int32 width, l_int32 op)
l_int32 pixRenderBoxArb (PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
l_int32 pixRenderBoxBlend (PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract)
l_int32 pixRenderHashBox (PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 op)
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)
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)
l_int32 pixRenderBoxa (PIX *pix, BOXA *boxa, l_int32 width, l_int32 op)
l_int32 pixRenderBoxaArb (PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
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)
l_int32 pixRenderPolyline (PIX *pix, PTA *ptas, l_int32 width, l_int32 op, l_int32 closeflag)
l_int32 pixRenderPolylineArb (PIX *pix, PTA *ptas, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_int32 closeflag)
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)
PIXpixRenderRandomCmapPtaa (PIX *pix, PTAA *ptaa, l_int32 polyflag, l_int32 width, l_int32 closeflag)
PIXpixRenderContours (PIX *pixs, l_int32 startval, l_int32 incr, l_int32 outdepth)
PIXfpixRenderContours (FPIX *fpixs, l_float32 startval, l_float32 incr, l_float32 proxim)

Detailed Description

Rendering shapes from lines (using Pta representation)

    Pta generation for arbitrary shapes built with lines

        PTA        *generatePtaLine()
        PTA        *generatePtaWideLine()
        PTA        *generatePtaBox()
        PTA        *generatePtaHashBox()
        PTA        *generatePtaBoxa()
        PTAA       *generatePtaaBoxa()
        PTAA       *generatePtaaHashBoxa()
        PTA        *generatePtaPolyline()
        PTA        *generatePtaFilledCircle()
        PTA        *generatePtaLineFromPt()
        l_int32     locatePtRadially()

    Pta rendering

        l_int32     pixRenderPta()
        l_int32     pixRenderPtaArb()
        l_int32     pixRenderPtaBlend()

    Rendering of arbitrary shapes built with lines

        l_int32     pixRenderLine()
        l_int32     pixRenderLineArb()
        l_int32     pixRenderLineBlend()

        l_int32     pixRenderBox()
        l_int32     pixRenderBoxArb()
        l_int32     pixRenderBoxBlend()

        l_int32     pixRenderHashBox()
        l_int32     pixRenderHashBoxArb()
        l_int32     pixRenderHashBoxBlend()

        l_int32     pixRenderBoxa()
        l_int32     pixRenderBoxaArb()
        l_int32     pixRenderBoxaBlend()

        l_int32     pixRenderPolyline()
        l_int32     pixRenderPolylineArb()
        l_int32     pixRenderPolylineBlend()

        l_int32     pixRenderRandomCmapPtaa()

    Contour rendering on grayscale images

        PIX        *pixRenderContours()
        PIX        *fpixRenderContours()

The line rendering functions are relatively crude, but they
get the job done for most simple situations.  We use the pta
as an intermediate data structure.  A pta is generated
for a line.  One of two rendering functions are used to
render this onto a Pix.

Definition in file graphics.c.


Function Documentation

PTA* generatePtaLine ( l_int32  x1,
l_int32  y1,
l_int32  x2,
l_int32  y2 
)

generatePtaLine()

Input: x1, y1 (end point 1) x2, y2 (end point 2) Return: pta, or null on error

Definition at line 93 of file graphics.c.

References ERROR_PTR, FALSE, L_ABS, L_SIGN, NULL, PROCNAME, ptaAddPt(), ptaCreate(), TRUE, x1, and y1.

Referenced by generatePtaLineFromPt(), generatePtaWideLine(), pixExtractOnLine(), and pixGetRunsOnLine().

PTA* generatePtaWideLine ( l_int32  x1,
l_int32  y1,
l_int32  x2,
l_int32  y2,
l_int32  width 
)

generatePtaWideLine()

Input: x1, y1 (end point 1) x2, y2 (end point 2) width Return: ptaj, or null on error

Definition at line 157 of file graphics.c.

References ERROR_PTR, generatePtaLine(), L_ABS, L_WARNING, NULL, PROCNAME, ptaDestroy(), and ptaJoin().

Referenced by generatePtaBox(), generatePtaHashBox(), generatePtaPolyline(), pixRenderLine(), pixRenderLineArb(), and pixRenderLineBlend().

PTA* generatePtaBox ( BOX box,
l_int32  width 
)

generatePtaBox()

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.

Definition at line 228 of file graphics.c.

References boxGetGeometry(), ERROR_PTR, generatePtaWideLine(), NULL, PROCNAME, ptaCreate(), ptaDestroy(), and ptaJoin().

Referenced by generatePtaBoxa(), generatePtaHashBox(), pixRenderBox(), pixRenderBoxArb(), and pixRenderBoxBlend().

PTA* generatePtaHashBox ( BOX box,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline 
)

generatePtaHashBox()

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.

Definition at line 301 of file graphics.c.

References boxGetGeometry(), boxIntersectByLine(), ERROR_PTR, generatePtaBox(), generatePtaWideLine(), L_HORIZONTAL_LINE, L_NEG_SLOPE_LINE, L_POS_SLOPE_LINE, L_VERTICAL_LINE, NULL, PROCNAME, ptaCreate(), ptaDestroy(), ptaJoin(), x1, x2, y1, and y2.

Referenced by generatePtaaHashBoxa(), pixRenderHashBox(), pixRenderHashBoxArb(), and pixRenderHashBoxBlend().

PTA* generatePtaBoxa ( BOXA boxa,
l_int32  width,
l_int32  removedups 
)

generatePtaBoxa()

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.

Definition at line 392 of file graphics.c.

References boxaGetBox(), boxaGetCount(), boxDestroy(), ERROR_PTR, generatePtaBox(), L_CLONE, NULL, PROCNAME, ptaClone(), ptaCreate(), ptaDestroy(), ptaJoin(), and ptaRemoveDuplicates().

Referenced by pixRenderBoxa(), pixRenderBoxaArb(), and pixRenderBoxaBlend().

PTAA* generatePtaaBoxa ( BOXA boxa)

generatePtaaBoxa()

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.

Definition at line 438 of file graphics.c.

References boxaGetBox(), boxaGetCount(), boxDestroy(), boxGetGeometry(), ERROR_PTR, L_CLONE, L_INSERT, NULL, PROCNAME, ptaaAddPta(), ptaaCreate(), ptaAddPt(), and ptaCreate().

Referenced by pixDrawBoxaRandom().

PTAA* generatePtaaHashBoxa ( BOXA boxa,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline 
)

generatePtaaHashBoxa()

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.

Definition at line 487 of file graphics.c.

References boxaGetBox(), boxaGetCount(), boxDestroy(), ERROR_PTR, generatePtaHashBox(), L_CLONE, L_HORIZONTAL_LINE, L_INSERT, L_NEG_SLOPE_LINE, L_POS_SLOPE_LINE, L_VERTICAL_LINE, NULL, PROCNAME, ptaaAddPta(), and ptaaCreate().

PTA* generatePtaPolyline ( PTA ptas,
l_int32  width,
l_int32  closeflag,
l_int32  removedups 
)

generatePtaPolyline()

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.

Definition at line 537 of file graphics.c.

References ERROR_PTR, generatePtaWideLine(), NULL, PROCNAME, ptaClone(), ptaCreate(), ptaDestroy(), ptaGetCount(), ptaGetIPt(), ptaJoin(), ptaRemoveDuplicates(), x1, x2, y1, and y2.

Referenced by pixRenderPolyline(), pixRenderPolylineArb(), pixRenderPolylineBlend(), and pixRenderRandomCmapPtaa().

PTA* generatePtaFilledCircle ( l_int32  radius)

generatePtaFilledCircle()

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.

Definition at line 596 of file graphics.c.

References ERROR_PTR, NULL, PROCNAME, ptaAddPt(), and ptaCreate().

Referenced by selDisplayInPix().

PTA* generatePtaLineFromPt ( l_int32  x,
l_int32  y,
l_float64  length,
l_float64  radang 
)

generatePtaLineFromPt()

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.

Definition at line 636 of file graphics.c.

References generatePtaLine(), x2, and y2.

Referenced by main(), selaAddCrossJunctions(), and selaAddTJunctions().

l_int32 locatePtRadially ( l_int32  xr,
l_int32  yr,
l_float64  dist,
l_float64  radang,
l_float64 px,
l_float64 py 
)

locatePtRadially()

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

Definition at line 660 of file graphics.c.

References ERROR_INT, and PROCNAME.

l_int32 pixRenderPta ( PIX pix,
PTA pta,
l_int32  op 
)

pixRenderPta()

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().

Definition at line 700 of file graphics.c.

References ERROR_INT, L_CLEAR_PIXELS, L_FLIP_PIXELS, L_SET_PIXELS, pixClearPixel(), pixFlipPixel(), pixGetDimensions(), pixSetPixel(), PROCNAME, ptaGetCount(), and ptaGetIPt().

Referenced by main(), pixRenderBox(), pixRenderBoxa(), pixRenderHashBox(), pixRenderLine(), pixRenderPolyline(), pixRenderPtaArb(), selaAddCrossJunctions(), and selaAddTJunctions().

l_int32 pixRenderPtaArb ( PIX pix,
PTA pta,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval 
)

pixRenderPtaArb()

Input: pix 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:

  • d = 1: set the pixels
  • d = 2, 4, 8: average the input rgb value
  • d = 32: use the input rgb value (3) This function clips the rendering to the pix.

Definition at line 783 of file graphics.c.

References composeRGBPixel(), ERROR_INT, L_SET_PIXELS, pixcmapAddNewColor(), pixGetColormap(), pixGetDepth(), pixGetDimensions(), pixRenderPta(), pixSetPixel(), PROCNAME, ptaGetCount(), and ptaGetIPt().

Referenced by pixRenderBoxaArb(), pixRenderBoxArb(), pixRenderHashBoxArb(), pixRenderLineArb(), pixRenderPolylineArb(), and pixRenderRandomCmapPtaa().

l_int32 pixRenderPtaBlend ( PIX pix,
PTA pta,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_float32  fract 
)

pixRenderPtaBlend()

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.

Definition at line 857 of file graphics.c.

References COLOR_BLUE, COLOR_GREEN, COLOR_RED, composeRGBPixel(), ERROR_INT, GET_DATA_BYTE, L_WARNING, NULL, pixGetDepth(), pixGetDimensions(), pixGetPixel(), pixSetPixel(), PROCNAME, ptaGetCount(), and ptaGetIPt().

Referenced by pixRenderBoxaBlend(), pixRenderBoxBlend(), pixRenderHashBoxBlend(), pixRenderLineBlend(), and pixRenderPolylineBlend().

l_int32 pixRenderLine ( PIX pix,
l_int32  x1,
l_int32  y1,
l_int32  x2,
l_int32  y2,
l_int32  width,
l_int32  op 
)

pixRenderLine()

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

Definition at line 922 of file graphics.c.

References ERROR_INT, generatePtaWideLine(), L_CLEAR_PIXELS, L_FLIP_PIXELS, L_SET_PIXELS, L_WARNING, NULL, pixRenderPta(), PROCNAME, and ptaDestroy().

Referenced by kernelDisplayInPix(), main(), pixaGenerateFont(), and selDisplayInPix().

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 
)

pixRenderLineArb()

Input: pix x1, y1 x2, y2 width (thickness of line) rval, gval, bval Return: 0 if OK, 1 on error

Definition at line 962 of file graphics.c.

References ERROR_INT, generatePtaWideLine(), L_WARNING, NULL, pixRenderPtaArb(), PROCNAME, and ptaDestroy().

Referenced by main(), and pixFindBaselines().

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 
)

pixRenderLineBlend()

Input: pix x1, y1 x2, y2 width (thickness of line) rval, gval, bval fract Return: 0 if OK, 1 on error

Definition at line 1003 of file graphics.c.

References ERROR_INT, generatePtaWideLine(), L_WARNING, NULL, pixRenderPtaBlend(), PROCNAME, and ptaDestroy().

Referenced by main().

l_int32 pixRenderBox ( PIX pix,
BOX box,
l_int32  width,
l_int32  op 
)

pixRenderBox()

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

Definition at line 1043 of file graphics.c.

References ERROR_INT, generatePtaBox(), L_CLEAR_PIXELS, L_FLIP_PIXELS, L_SET_PIXELS, NULL, pixRenderPta(), PROCNAME, and ptaDestroy().

Referenced by main().

l_int32 pixRenderBoxArb ( PIX pix,
BOX box,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval 
)

pixRenderBoxArb()

Input: pix box width (thickness of box lines) rval, gval, bval Return: 0 if OK, 1 on error

Definition at line 1077 of file graphics.c.

References ERROR_INT, generatePtaBox(), NULL, pixRenderPtaArb(), PROCNAME, and ptaDestroy().

Referenced by boxaaDisplay(), jbDataRender(), main(), and pixDrawBoxaRandom().

l_int32 pixRenderBoxBlend ( PIX pix,
BOX box,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_float32  fract 
)

pixRenderBoxBlend()

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

Definition at line 1113 of file graphics.c.

References ERROR_INT, generatePtaBox(), NULL, pixRenderPtaBlend(), PROCNAME, and ptaDestroy().

Referenced by main().

l_int32 pixRenderHashBox ( PIX pix,
BOX box,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline,
l_int32  op 
)

pixRenderHashBox()

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

Definition at line 1151 of file graphics.c.

References ERROR_INT, generatePtaHashBox(), L_CLEAR_PIXELS, L_FLIP_PIXELS, L_HORIZONTAL_LINE, L_NEG_SLOPE_LINE, L_POS_SLOPE_LINE, L_SET_PIXELS, L_VERTICAL_LINE, pixRenderPta(), PROCNAME, and ptaDestroy().

Referenced by main().

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 
)

pixRenderBoxArb()

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

Definition at line 1197 of file graphics.c.

References ERROR_INT, generatePtaHashBox(), L_HORIZONTAL_LINE, L_NEG_SLOPE_LINE, L_POS_SLOPE_LINE, L_VERTICAL_LINE, pixRenderPtaArb(), PROCNAME, and ptaDestroy().

Referenced by main(), pixFindHistoPeaksHSV(), pixFindLargestRectangle(), RenderHashedBoxa(), and RenderTransformedBoxa().

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 
)

pixRenderHashBoxBlend()

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

Definition at line 1245 of file graphics.c.

References ERROR_INT, generatePtaHashBox(), L_HORIZONTAL_LINE, L_NEG_SLOPE_LINE, L_POS_SLOPE_LINE, L_VERTICAL_LINE, pixRenderPtaBlend(), PROCNAME, and ptaDestroy().

Referenced by main().

l_int32 pixRenderBoxa ( PIX pix,
BOXA boxa,
l_int32  width,
l_int32  op 
)

pixRenderBoxa()

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

Definition at line 1289 of file graphics.c.

References ERROR_INT, generatePtaBoxa(), L_CLEAR_PIXELS, L_FLIP_PIXELS, L_SET_PIXELS, NULL, pixRenderPta(), PROCNAME, and ptaDestroy().

Referenced by main().

l_int32 pixRenderBoxaArb ( PIX pix,
BOXA boxa,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval 
)

pixRenderBoxaArb()

Input: pix boxa width (thickness of line) rval, gval, bval Return: 0 if OK, 1 on error

Definition at line 1323 of file graphics.c.

References ERROR_INT, generatePtaBoxa(), NULL, pixRenderPtaArb(), PROCNAME, and ptaDestroy().

Referenced by main(), pixDrawBoxa(), and pixItalicWords().

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 
)

pixRenderBoxaBlend()

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

Definition at line 1360 of file graphics.c.

References ERROR_INT, generatePtaBoxa(), NULL, pixRenderPtaBlend(), PROCNAME, and ptaDestroy().

Referenced by main().

l_int32 pixRenderPolyline ( PIX pix,
PTA ptas,
l_int32  width,
l_int32  op,
l_int32  closeflag 
)

pixRenderPolyline()

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.

Definition at line 1399 of file graphics.c.

References ERROR_INT, generatePtaPolyline(), L_CLEAR_PIXELS, L_FLIP_PIXELS, L_SET_PIXELS, NULL, pixRenderPta(), PROCNAME, and ptaDestroy().

l_int32 pixRenderPolylineArb ( PIX pix,
PTA ptas,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_int32  closeflag 
)

pixRenderPolylineArb()

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.

Definition at line 1437 of file graphics.c.

References ERROR_INT, generatePtaPolyline(), NULL, pixRenderPtaArb(), PROCNAME, and ptaDestroy().

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 
)

pixRenderPolylineBlend()

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

Definition at line 1476 of file graphics.c.

References ERROR_INT, generatePtaPolyline(), NULL, pixRenderPtaBlend(), PROCNAME, and ptaDestroy().

Referenced by main().

PIX* pixRenderRandomCmapPtaa ( PIX pix,
PTAA ptaa,
l_int32  polyflag,
l_int32  width,
l_int32  closeflag 
)

pixRenderRandomCmapPtaa()

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.

Definition at line 1530 of file graphics.c.

References ERROR_PTR, FALSE, generatePtaPolyline(), L_CLONE, NULL, pixcmapCreateRandom(), pixcmapGetColor(), pixConvertTo8(), pixRenderPtaArb(), pixSetColormap(), PROCNAME, ptaaGetCount(), ptaaGetPta(), ptaClone(), and ptaDestroy().

Referenced by DoPageSegmentation(), main(), pixDrawBoxaRandom(), and pixGetRegionsBinary().

PIX* pixRenderContours ( PIX pixs,
l_int32  startval,
l_int32  incr,
l_int32  outdepth 
)

pixRenderContours()

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.

Definition at line 1590 of file graphics.c.

References ERROR_PTR, GET_DATA_BYTE, GET_DATA_TWO_BYTES, L_WARNING, NULL, pixCopy(), pixCopyResolution(), pixCreate(), pixGetColormap(), pixGetData(), pixGetDimensions(), pixGetWpl(), PROCNAME, SET_DATA_BIT, SET_DATA_BYTE, and SET_DATA_TWO_BYTES.

Referenced by TestDistance().

PIX* fpixRenderContours ( FPIX fpixs,
l_float32  startval,
l_float32  incr,
l_float32  proxim 
)

fpixRenderContours()

Input: fpixs startval (value of lowest contour incr (increment to next contour; must be > 0.0) proxim (required proximity to target value; typ. 0.1 * incr) Return: pixd (1 bpp), or null on error

Definition at line 1712 of file graphics.c.

References ERROR_PTR, fpixGetData(), fpixGetDimensions(), fpixGetWpl(), L_ABS, NULL, pixCreate(), pixGetData(), pixGetWpl(), PROCNAME, and SET_DATA_BIT.

Referenced by dewarpBuildModel(), and main().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines