![]() |
Leptonica 1.85.0
Image processing and image analysis suite
|
#include "allheaders.h"Go to the source code of this file.
Data Structures | |
| struct | ColorEl |
Typedefs | |
| typedef struct ColorEl | COLOREL |
Functions | |
| static COLOREL * | colorelCreate (l_int32 x, l_int32 y, l_uint32 color) |
| static void | pixColorFillFromSeed (PIX *pixs, PIX *pixv, PTA **ppta, l_int32 x, l_int32 y, L_QUEUE *lq, l_int32 maxdiff, l_int32 minarea, l_int32 debug) |
| static void | pixGetVisitedNeighbors (PIX *pixs, l_int32 x, l_int32 y, l_uint32 *visited) |
| static l_int32 | findNextUnvisited (PIX *pixv, l_int32 *px, l_int32 *py) |
| static l_int32 | colorsAreSimilarForFill (l_uint32 val1, l_uint32 val2, l_int32 maxdiff) |
| static l_int32 | pixelColorIsValid (l_uint32 val, l_int32 minmax) |
| static l_int32 | pixelIsOnColorBoundary (PIX *pixs, l_int32 x, l_int32 y) |
| static l_int32 | evalColorfillData (L_COLORFILL *cf, l_int32 debug) |
| L_COLORFILL * | l_colorfillCreate (PIX *pixs, l_int32 nx, l_int32 ny) |
| void | l_colorfillDestroy (L_COLORFILL **pcf) |
| l_ok | pixColorContentByLocation (L_COLORFILL *cf, l_int32 rref, l_int32 gref, l_int32 bref, l_int32 minmax, l_int32 maxdiff, l_int32 minarea, l_int32 smooth, l_int32 debug) |
| PIX * | pixColorFill (PIX *pixs, l_int32 minmax, l_int32 maxdiff, l_int32 smooth, l_int32 minarea, l_int32 debug) |
| PIXA * | makeColorfillTestData (l_int32 w, l_int32 h, l_int32 nseeds, l_int32 range) |
Variables | |
| static l_int32 | DefaultMinMax = 70 |
Determine color content using proximity. What can we say about the
color in an image from growing regions with nearly the same color?
L_COLORFILL *l_colorfillCreate()
void l_colorfillDestroy()
L_COLORFILL *pixColorContentByLocation()
PIX *pixColorFill()
Generate data for testing
PIXA *makeColorfillTestData()
Static helpers
static COLOREL *colorelCreate()
static void pixColorFillFromSeed()
static void pixGetVisitedNeighbors()
static l_int32 findNextUnvisited()
static l_int32 colorsAreSimilarForFill()
static void pixelColorIsValid()
static l_int32 pixelIsOnColorBoundary()
static l_int32 evalColorfillData()
See colorcontent.c for location-independent measures of the amount
of color in an image.
Definition in file colorfill.c.
Definition at line 69 of file colorfill.c.
|
static |
Definition at line 491 of file colorfill.c.
|
static |
| [in] | val1 | color of pixel 1, as 0xrrggbb00 |
| [in] | val2 | color of pixel 2, as 0xrrggbb00 |
| [in] | maxdiff | max of difference function to be similar |
Notes:
(1) An example will explain the approach. Suppose we have:
val1 = {100, 130, 70}
val2 = {90, 135, 62}
First find that red is the color with largest abs(difference):
rdiff = val1 - val2 = 10
Find the green and blue differences
gdiff = 130 - 135 = -5
bdiff = 70 - 62 = 8
and subtract each from rdiff:
rdiff - gdiff = 15
rdiff - bdiff = 7
The max of these is 15, which is then compared with maxdiff
Definition at line 750 of file colorfill.c.
Referenced by pixColorFillFromSeed().
|
static |
| [in] | cf | colorfill with masks generated for all tiles |
| [in] | debug | show segmented regions with their median color |
Definition at line 842 of file colorfill.c.
References L_Colorfill::dnaa, L_CLONE, L_COPY, L_INSERT, L_Colorfill::naa, L_Colorfill::nx, L_Colorfill::ny, L_Colorfill::pixadb, L_Colorfill::pixam, and L_Colorfill::pixas.
Referenced by pixColorContentByLocation().
|
static |
| [in] | pixv | visited pixels |
| [in,out] | py | input start scanline; output y-coord of next seed |
| [out] | px | x-coord of next seed |
Notes:
(1) Start the search at the beginning of the raster line
for the pixel that ended the previous search.
Definition at line 710 of file colorfill.c.
Referenced by pixColorFill().
| L_COLORFILL * l_colorfillCreate | ( | PIX * | pixs, |
| l_int32 | nx, | ||
| l_int32 | ny ) |
| [in] | pixs | input RGB image |
| [in] | nx | requested number of tiles in each row |
| [in] | ny | requested number of tiles in each column |
Notes:
(1) Tiles must at least 10 pixels in each dimension.
Definition at line 107 of file colorfill.c.
References L_Colorfill::boxas, L_Colorfill::dnaa, L_INSERT, L_Colorfill::naa, L_Colorfill::nx, L_Colorfill::ny, L_Colorfill::pixadb, L_Colorfill::pixs, L_Colorfill::th, and L_Colorfill::tw.
| void l_colorfillDestroy | ( | L_COLORFILL ** | pcf | ) |
| [in,out] | pcf | will be set to null before returning |
Definition at line 156 of file colorfill.c.
References L_Colorfill::boxas, L_Colorfill::dnaa, L_Colorfill::naa, L_Colorfill::pixadb, L_Colorfill::pixam, L_Colorfill::pixas, L_Colorfill::pixs, and L_Colorfill::pixst.
| PIXA * makeColorfillTestData | ( | l_int32 | w, |
| l_int32 | h, | ||
| l_int32 | nseeds, | ||
| l_int32 | range ) |
| [in] | w | width of generated pix |
| [in] | h | height of generated pix |
| [in] | nseeds | number of regions |
| [in] | range | of color component values |
Notes:
(1) The seeds are random points. The colors are assigned
randomly from a restricted range of component values,
in [128 - range/2 ... 128 + range/2]
(2) Output is pixa:
* pixa[0] cmapped, with color regions shown
- pixa[1] cmapped, additionally with boundary pixels set to black
- pixa[2] cmapped, as in pixa[1] with all non-black pixels
in the same color
Definition at line 404 of file colorfill.c.
References L_COPY, L_INSERT, and pixelIsOnColorBoundary().
| l_ok pixColorContentByLocation | ( | L_COLORFILL * | cf, |
| l_int32 | rref, | ||
| l_int32 | gref, | ||
| l_int32 | bref, | ||
| l_int32 | minmax, | ||
| l_int32 | maxdiff, | ||
| l_int32 | minarea, | ||
| l_int32 | smooth, | ||
| l_int32 | debug ) |
| [in] | cf | colorfill |
| [in] | rref | reference value for red component |
| [in] | gref | reference value for green component |
| [in] | bref | reference value for blue component |
| [in] | minmax | min of max component for possible color region |
| [in] | maxdiff | max component diff to be in same color region |
| [in] | minarea | min number of pixels for a color region |
| [in] | smooth | low-pass kernel size (1,3,5); use 1 to skip |
| [in] | debug | generates debug images and fill info |
Notes:
(1) This computes color fill information in each tile, identifying
regions of approximately constant color. It does this
independently for each tile, using flood fills. Regions
of low intensity are considered 'not colorful'.
(2) The three numbers (rref, gref and bref) can be thought
of in two ways:
(a) as rgb values in the image corresponding to white,
to compensate for an unbalanced color white point.
(b) as the median or mean values of the background color
of a scan.
The gamma TRC transformation, which does not change hue, is used
to modify all colors so that these reference values become white.
These three numbers must either be all 0 or all non-zero.
To skip the TRC transform, set them all to 0.
(3) If the maximum component after white point correction,
max(r,g,b), is less than minmax, the pixel color is invalid, and it
is assigned its neighbor's value in the filling operation.
Use minmax = 0 for a default value.
Definition at line 222 of file colorfill.c.
References L_Colorfill::boxas, evalColorfillData(), L_COPY, L_INSERT, L_Colorfill::pixam, L_Colorfill::pixas, pixColorFill(), L_Colorfill::pixs, and L_Colorfill::pixst.
| PIX * pixColorFill | ( | PIX * | pixs, |
| l_int32 | minmax, | ||
| l_int32 | maxdiff, | ||
| l_int32 | smooth, | ||
| l_int32 | minarea, | ||
| l_int32 | debug ) |
| [in] | pixs | 32 bpp RGB |
| [in] | minmax | min of max component for possible color region |
| [in] | maxdiff | max component diff to be in same color region |
| [in] | smooth | low-pass kernel size (1,3,5); use 1 to skip |
| [in] | minarea | min number of pixels for a color region |
| [in] | debug | generates debug images and fill info |
Notes:
(1) This is the basic color filling operation. It sets the
non-color pixel to black, optionally does a low-pass filter,
and grows the 8-connected color components. Finally, it
removes components that have a small area.
Definition at line 293 of file colorfill.c.
References findNextUnvisited(), L_SELECT_IF_GTE, pixColorFillFromSeed(), and pixelColorIsValid().
Referenced by pixColorContentByLocation().
|
static |
| [in] | pixs | 32 bpp rgb |
| [in] | pixv | 1 bpp labeling visited pixels |
| [out] | ppta | points visited with similar colors during fill |
| [in] | x | starting x coord for fill (seed) |
| [in] | y | starting y coord for fill (seed) |
| [in] | lq | head of queue holding pixels |
| [in] | maxdiff | max component diff allowed for similar pixels |
| [in] | minarea | min size of component to keep |
| [in] | debug | output some text data |
Notes:
(1) Use 8-connected filling. It is faster because it reduces the
number of single-pixel noise components near color boundaries.
(2) The seed pixel at (x,y) is unvisited, and can never be on the
exterior boundary of the tile pixs.
(3) If the size of the connected component >= minarea, we return
the array of pixel locations; otherwise, return NULL for the pta.
Definition at line 529 of file colorfill.c.
References colorsAreSimilarForFill(), and pixGetVisitedNeighbors().
Referenced by pixColorFill().
|
static |
| [in] | val | color, as 0xrrggbb00 |
| [in] | minmax | max component must be < minmax to be valid |
Definition at line 783 of file colorfill.c.
Referenced by pixColorFill().
|
static |
| [in] | pixs | 32 bpp rgb or 8 bpp with colormap |
| [in] | x,y | location of pixel of interest |
Definition at line 805 of file colorfill.c.
Referenced by makeColorfillTestData().
|
static |
| [in] | pixs | 1 bpp, representing visited locations |
| [in] | x | x coord of pixel |
| [in] | y | y coord of pixel |
| [in,out] | visited | array of 8 int |
Notes:
(1) The values of the neighbors of (x,y) in pixs, given in
order {W,N,E,S,NW,NE,SW,SE}, are returned in visited.
A "1" value means that pixel has been visited. Initialize
each neighbor to 1 (visited).
(2) The input point (x,y) is never on the outer boundary of pixs,
(e.g., x >= 1, y >= 1), so no checking is required.
Definition at line 679 of file colorfill.c.
Referenced by pixColorFillFromSeed().
|
static |
Definition at line 72 of file colorfill.c.