Leptonica  1.83.1
Image processing and image analysis suite
quadtree.c
Go to the documentation of this file.
1 /*====================================================================*
2  - Copyright (C) 2001 Leptonica. All rights reserved.
3  -
4  - Redistribution and use in source and binary forms, with or without
5  - modification, are permitted provided that the following conditions
6  - are met:
7  - 1. Redistributions of source code must retain the above copyright
8  - notice, this list of conditions and the following disclaimer.
9  - 2. Redistributions in binary form must reproduce the above
10  - copyright notice, this list of conditions and the following
11  - disclaimer in the documentation and/or other materials
12  - provided with the distribution.
13  -
14  - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
18  - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *====================================================================*/
26 
64 #ifdef HAVE_CONFIG_H
65 #include <config_auto.h>
66 #endif /* HAVE_CONFIG_H */
67 
68 #include <math.h>
69 #include "allheaders.h"
70 
71 #ifndef NO_CONSOLE_IO
72 #define DEBUG_BOXES 0
73 #endif /* !NO_CONSOLE_IO */
74 
75 
76 /*----------------------------------------------------------------------*
77  * Top-level quadtree linear statistics *
78  *----------------------------------------------------------------------*/
95 l_ok
97  l_int32 nlevels,
98  PIX *pix_ma,
99  FPIXA **pfpixa)
100 {
101 l_int32 i, j, w, h, size, n;
102 l_float32 val;
103 BOX *box;
104 BOXA *boxa;
105 BOXAA *baa;
106 FPIX *fpix;
107 PIX *pix_mac;
108 
109  if (!pfpixa)
110  return ERROR_INT("&fpixa not defined", __func__, 1);
111  *pfpixa = NULL;
112  if (!pixs || pixGetDepth(pixs) != 8)
113  return ERROR_INT("pixs not defined or not 8 bpp", __func__, 1);
114  pixGetDimensions(pixs, &w, &h, NULL);
115  if (nlevels > quadtreeMaxLevels(w, h))
116  return ERROR_INT("nlevels too large for image", __func__, 1);
117 
118  if (!pix_ma)
119  pix_mac = pixBlockconvAccum(pixs);
120  else
121  pix_mac = pixClone(pix_ma);
122  if (!pix_mac)
123  return ERROR_INT("pix_mac not made", __func__, 1);
124 
125  if ((baa = boxaaQuadtreeRegions(w, h, nlevels)) == NULL) {
126  pixDestroy(&pix_mac);
127  return ERROR_INT("baa not made", __func__, 1);
128  }
129 
130  *pfpixa = fpixaCreate(nlevels);
131  for (i = 0; i < nlevels; i++) {
132  boxa = boxaaGetBoxa(baa, i, L_CLONE);
133  size = 1 << i;
134  n = boxaGetCount(boxa); /* n == size * size */
135  fpix = fpixCreate(size, size);
136  for (j = 0; j < n; j++) {
137  box = boxaGetBox(boxa, j, L_CLONE);
138  pixMeanInRectangle(pixs, box, pix_mac, &val);
139  fpixSetPixel(fpix, j % size, j / size, val);
140  boxDestroy(&box);
141  }
142  fpixaAddFPix(*pfpixa, fpix, L_INSERT);
143  boxaDestroy(&boxa);
144  }
145 
146  pixDestroy(&pix_mac);
147  boxaaDestroy(&baa);
148  return 0;
149 }
150 
151 
170 l_ok
172  l_int32 nlevels,
173  PIX *pix_ma,
174  DPIX *dpix_msa,
175  FPIXA **pfpixa_v,
176  FPIXA **pfpixa_rv)
177 {
178 l_int32 i, j, w, h, size, n;
179 l_float32 var, rvar;
180 BOX *box;
181 BOXA *boxa;
182 BOXAA *baa;
183 FPIX *fpixv, *fpixrv;
184 PIX *pix_mac; /* copy of mean accumulator */
185 DPIX *dpix_msac; /* msa clone */
186 
187  if (!pfpixa_v && !pfpixa_rv)
188  return ERROR_INT("neither &fpixav nor &fpixarv defined", __func__, 1);
189  if (pfpixa_v) *pfpixa_v = NULL;
190  if (pfpixa_rv) *pfpixa_rv = NULL;
191  if (!pixs || pixGetDepth(pixs) != 8)
192  return ERROR_INT("pixs not defined or not 8 bpp", __func__, 1);
193  pixGetDimensions(pixs, &w, &h, NULL);
194  if (nlevels > quadtreeMaxLevels(w, h))
195  return ERROR_INT("nlevels too large for image", __func__, 1);
196 
197  if (!pix_ma)
198  pix_mac = pixBlockconvAccum(pixs);
199  else
200  pix_mac = pixClone(pix_ma);
201  if (!pix_mac)
202  return ERROR_INT("pix_mac not made", __func__, 1);
203  if (!dpix_msa)
204  dpix_msac = pixMeanSquareAccum(pixs);
205  else
206  dpix_msac = dpixClone(dpix_msa);
207  if (!dpix_msac) {
208  pixDestroy(&pix_mac);
209  return ERROR_INT("dpix_msac not made", __func__, 1);
210  }
211 
212  if ((baa = boxaaQuadtreeRegions(w, h, nlevels)) == NULL) {
213  pixDestroy(&pix_mac);
214  dpixDestroy(&dpix_msac);
215  return ERROR_INT("baa not made", __func__, 1);
216  }
217 
218  if (pfpixa_v) *pfpixa_v = fpixaCreate(nlevels);
219  if (pfpixa_rv) *pfpixa_rv = fpixaCreate(nlevels);
220  for (i = 0; i < nlevels; i++) {
221  boxa = boxaaGetBoxa(baa, i, L_CLONE);
222  size = 1 << i;
223  n = boxaGetCount(boxa); /* n == size * size */
224  if (pfpixa_v) fpixv = fpixCreate(size, size);
225  if (pfpixa_rv) fpixrv = fpixCreate(size, size);
226  for (j = 0; j < n; j++) {
227  box = boxaGetBox(boxa, j, L_CLONE);
228  pixVarianceInRectangle(pixs, box, pix_mac, dpix_msac, &var, &rvar);
229  if (pfpixa_v) fpixSetPixel(fpixv, j % size, j / size, var);
230  if (pfpixa_rv) fpixSetPixel(fpixrv, j % size, j / size, rvar);
231  boxDestroy(&box);
232  }
233  if (pfpixa_v) fpixaAddFPix(*pfpixa_v, fpixv, L_INSERT);
234  if (pfpixa_rv) fpixaAddFPix(*pfpixa_rv, fpixrv, L_INSERT);
235  boxaDestroy(&boxa);
236  }
237 
238  pixDestroy(&pix_mac);
239  dpixDestroy(&dpix_msac);
240  boxaaDestroy(&baa);
241  return 0;
242 }
243 
244 
245 /*----------------------------------------------------------------------*
246  * Statistics in an arbitrary rectangle *
247  *----------------------------------------------------------------------*/
264 l_ok
266  BOX *box,
267  PIX *pixma,
268  l_float32 *pval)
269 {
270 l_int32 w, h, bx, by, bw, bh;
271 l_uint32 val00, val01, val10, val11;
272 l_float32 norm;
273 BOX *boxc;
274 
275  if (!pval)
276  return ERROR_INT("&val not defined", __func__, 1);
277  *pval = 0.0;
278  if (!pixs || pixGetDepth(pixs) != 8)
279  return ERROR_INT("pixs not defined", __func__, 1);
280  if (!box)
281  return ERROR_INT("box not defined", __func__, 1);
282  if (!pixma)
283  return ERROR_INT("pixma not defined", __func__, 1);
284 
285  /* Clip rectangle to image */
286  pixGetDimensions(pixs, &w, &h, NULL);
287  boxc = boxClipToRectangle(box, w, h);
288  boxGetGeometry(boxc, &bx, &by, &bw, &bh);
289  boxDestroy(&boxc);
290 
291  if (bw == 0 || bh == 0)
292  return ERROR_INT("no pixels in box", __func__, 1);
293 
294  /* Use up to 4 points in the accumulator */
295  norm = 1.0 / ((l_float32)(bw) * bh);
296  if (bx > 0 && by > 0) {
297  pixGetPixel(pixma, bx + bw - 1, by + bh - 1, &val11);
298  pixGetPixel(pixma, bx + bw - 1, by - 1, &val10);
299  pixGetPixel(pixma, bx - 1, by + bh - 1, &val01);
300  pixGetPixel(pixma, bx - 1, by - 1, &val00);
301  *pval = norm * (val11 - val01 + val00 - val10);
302  } else if (by > 0) { /* bx == 0 */
303  pixGetPixel(pixma, bw - 1, by + bh - 1, &val11);
304  pixGetPixel(pixma, bw - 1, by - 1, &val10);
305  *pval = norm * (val11 - val10);
306  } else if (bx > 0) { /* by == 0 */
307  pixGetPixel(pixma, bx + bw - 1, bh - 1, &val11);
308  pixGetPixel(pixma, bx - 1, bh - 1, &val01);
309  *pval = norm * (val11 - val01);
310  } else { /* bx == 0 && by == 0 */
311  pixGetPixel(pixma, bw - 1, bh - 1, &val11);
312  *pval = norm * val11;
313  }
314 
315  return 0;
316 }
317 
318 
338 l_ok
340  BOX *box,
341  PIX *pix_ma,
342  DPIX *dpix_msa,
343  l_float32 *pvar,
344  l_float32 *prvar)
345 {
346 l_int32 w, h, bx, by, bw, bh;
347 l_uint32 val00, val01, val10, val11;
348 l_float64 dval00, dval01, dval10, dval11, mval, msval, var, norm;
349 BOX *boxc;
350 
351  if (!pvar && !prvar)
352  return ERROR_INT("neither &var nor &rvar defined", __func__, 1);
353  if (pvar) *pvar = 0.0;
354  if (prvar) *prvar = 0.0;
355  if (!pixs || pixGetDepth(pixs) != 8)
356  return ERROR_INT("pixs not defined", __func__, 1);
357  if (!box)
358  return ERROR_INT("box not defined", __func__, 1);
359  if (!pix_ma)
360  return ERROR_INT("pix_ma not defined", __func__, 1);
361  if (!dpix_msa)
362  return ERROR_INT("dpix_msa not defined", __func__, 1);
363 
364  /* Clip rectangle to image */
365  pixGetDimensions(pixs, &w, &h, NULL);
366  boxc = boxClipToRectangle(box, w, h);
367  boxGetGeometry(boxc, &bx, &by, &bw, &bh);
368  boxDestroy(&boxc);
369 
370  if (bw == 0 || bh == 0)
371  return ERROR_INT("no pixels in box", __func__, 1);
372 
373  /* Use up to 4 points in the accumulators */
374  norm = 1.0 / ((l_float32)(bw) * bh);
375  if (bx > 0 && by > 0) {
376  pixGetPixel(pix_ma, bx + bw - 1, by + bh - 1, &val11);
377  pixGetPixel(pix_ma, bx + bw - 1, by - 1, &val10);
378  pixGetPixel(pix_ma, bx - 1, by + bh - 1, &val01);
379  pixGetPixel(pix_ma, bx - 1, by - 1, &val00);
380  dpixGetPixel(dpix_msa, bx + bw - 1, by + bh - 1, &dval11);
381  dpixGetPixel(dpix_msa, bx + bw - 1, by - 1, &dval10);
382  dpixGetPixel(dpix_msa, bx - 1, by + bh - 1, &dval01);
383  dpixGetPixel(dpix_msa, bx - 1, by - 1, &dval00);
384  mval = norm * (val11 - val01 + val00 - val10);
385  msval = norm * (dval11 - dval01 + dval00 - dval10);
386  var = (msval - mval * mval);
387  if (pvar) *pvar = (l_float32)var;
388  if (prvar) *prvar = (l_float32)(sqrt(var));
389  } else if (by > 0) { /* bx == 0 */
390  pixGetPixel(pix_ma, bw - 1, by + bh - 1, &val11);
391  pixGetPixel(pix_ma, bw - 1, by - 1, &val10);
392  dpixGetPixel(dpix_msa, bw - 1, by + bh - 1, &dval11);
393  dpixGetPixel(dpix_msa, bw - 1, by - 1, &dval10);
394  mval = norm * (val11 - val10);
395  msval = norm * (dval11 - dval10);
396  var = (msval - mval * mval);
397  if (pvar) *pvar = (l_float32)var;
398  if (prvar) *prvar = (l_float32)(sqrt(var));
399  } else if (bx > 0) { /* by == 0 */
400  pixGetPixel(pix_ma, bx + bw - 1, bh - 1, &val11);
401  pixGetPixel(pix_ma, bx - 1, bh - 1, &val01);
402  dpixGetPixel(dpix_msa, bx + bw - 1, bh - 1, &dval11);
403  dpixGetPixel(dpix_msa, bx - 1, bh - 1, &dval01);
404  mval = norm * (val11 - val01);
405  msval = norm * (dval11 - dval01);
406  var = (msval - mval * mval);
407  if (pvar) *pvar = (l_float32)var;
408  if (prvar) *prvar = (l_float32)(sqrt(var));
409  } else { /* bx == 0 && by == 0 */
410  pixGetPixel(pix_ma, bw - 1, bh - 1, &val11);
411  dpixGetPixel(dpix_msa, bw - 1, bh - 1, &dval11);
412  mval = norm * val11;
413  msval = norm * dval11;
414  var = (msval - mval * mval);
415  if (pvar) *pvar = (l_float32)var;
416  if (prvar) *prvar = (l_float32)(sqrt(var));
417  }
418 
419  return 0;
420 }
421 
422 
423 /*----------------------------------------------------------------------*
424  * Quadtree regions *
425  *----------------------------------------------------------------------*/
444 BOXAA *
446  l_int32 h,
447  l_int32 nlevels)
448 {
449 l_int32 i, j, k, maxpts, nside, nbox, bw, bh;
450 l_int32 *xstart, *xend, *ystart, *yend;
451 BOX *box;
452 BOXA *boxa;
453 BOXAA *baa;
454 
455  if (nlevels < 1)
456  return (BOXAA *)ERROR_PTR("nlevels must be >= 1", __func__, NULL);
457  if (w < (1 << (nlevels - 1)))
458  return (BOXAA *)ERROR_PTR("w doesn't support nlevels", __func__, NULL);
459  if (h < (1 << (nlevels - 1)))
460  return (BOXAA *)ERROR_PTR("h doesn't support nlevels", __func__, NULL);
461 
462  baa = boxaaCreate(nlevels);
463  maxpts = 1 << (nlevels - 1);
464  xstart = (l_int32 *)LEPT_CALLOC(maxpts, sizeof(l_int32));
465  xend = (l_int32 *)LEPT_CALLOC(maxpts, sizeof(l_int32));
466  ystart = (l_int32 *)LEPT_CALLOC(maxpts, sizeof(l_int32));
467  yend = (l_int32 *)LEPT_CALLOC(maxpts, sizeof(l_int32));
468  for (k = 0; k < nlevels; k++) {
469  nside = 1 << k; /* number of boxes in each direction */
470  for (i = 0; i < nside; i++) {
471  xstart[i] = (w - 1) * i / nside;
472  if (i > 0) xstart[i]++;
473  xend[i] = (w - 1) * (i + 1) / nside;
474  ystart[i] = (h - 1) * i / nside;
475  if (i > 0) ystart[i]++;
476  yend[i] = (h - 1) * (i + 1) / nside;
477 #if DEBUG_BOXES
478  lept_stderr(
479  "k = %d, xs[%d] = %d, xe[%d] = %d, ys[%d] = %d, ye[%d] = %d\n",
480  k, i, xstart[i], i, xend[i], i, ystart[i], i, yend[i]);
481 #endif /* DEBUG_BOXES */
482  }
483  nbox = 1 << (2 * k);
484  boxa = boxaCreate(nbox);
485  for (i = 0; i < nside; i++) {
486  bh = yend[i] - ystart[i] + 1;
487  for (j = 0; j < nside; j++) {
488  bw = xend[j] - xstart[j] + 1;
489  box = boxCreate(xstart[j], ystart[i], bw, bh);
490  boxaAddBox(boxa, box, L_INSERT);
491  }
492  }
493  boxaaAddBoxa(baa, boxa, L_INSERT);
494  }
495 
496  LEPT_FREE(xstart);
497  LEPT_FREE(xend);
498  LEPT_FREE(ystart);
499  LEPT_FREE(yend);
500  return baa;
501 }
502 
503 
504 /*----------------------------------------------------------------------*
505  * Quadtree access *
506  *----------------------------------------------------------------------*/
523 l_ok
525  l_int32 level,
526  l_int32 x,
527  l_int32 y,
528  l_float32 *pval)
529 {
530 l_int32 n;
531 
532  if (!pval)
533  return ERROR_INT("&val not defined", __func__, 1);
534  *pval = 0.0;
535  if (!fpixa)
536  return ERROR_INT("fpixa not defined", __func__, 1);
537  n = fpixaGetCount(fpixa);
538  if (level < 1 || level >= n)
539  return ERROR_INT("invalid level", __func__, 1);
540 
541  if (fpixaGetPixel(fpixa, level - 1, x / 2, y / 2, pval) != 0)
542  return ERROR_INT("invalid coordinates", __func__, 1);
543  return 0;
544 }
545 
546 
564 l_ok
566  l_int32 level,
567  l_int32 x,
568  l_int32 y,
569  l_float32 *pval00,
570  l_float32 *pval10,
571  l_float32 *pval01,
572  l_float32 *pval11)
573 {
574 l_int32 n;
575 
576  if (!pval00 || !pval01 || !pval10 || !pval11)
577  return ERROR_INT("&val* not all defined", __func__, 1);
578  *pval00 = *pval10 = *pval01 = *pval11 = 0.0;
579  if (!fpixa)
580  return ERROR_INT("fpixa not defined", __func__, 1);
581  n = fpixaGetCount(fpixa);
582  if (level < 0 || level >= n - 1)
583  return ERROR_INT("invalid level", __func__, 1);
584 
585  if (fpixaGetPixel(fpixa, level + 1, 2 * x, 2 * y, pval00) != 0)
586  return ERROR_INT("invalid coordinates", __func__, 1);
587  fpixaGetPixel(fpixa, level + 1, 2 * x + 1, 2 * y, pval10);
588  fpixaGetPixel(fpixa, level + 1, 2 * x, 2 * y + 1, pval01);
589  fpixaGetPixel(fpixa, level + 1, 2 * x + 1, 2 * y + 1, pval11);
590  return 0;
591 }
592 
593 
608 l_int32
610  l_int32 h)
611 {
612 l_int32 i, minside;
613 
614  minside = L_MIN(w, h);
615  for (i = 0; i < 20; i++) { /* 2^10 = one million */
616  if (minside < (1.5 * (1 << i)))
617  return i - 1;
618  }
619 
620  return -1; /* fail if the image has over a trillion pixels! */
621 }
622 
623 
624 /*----------------------------------------------------------------------*
625  * Display quadtree *
626  *----------------------------------------------------------------------*/
643 PIX *
645  l_int32 factor,
646  l_int32 fontsize)
647 {
648 char buf[256];
649 l_int32 nlevels, i, mag, w;
650 L_BMF *bmf;
651 FPIX *fpix;
652 PIX *pixt1, *pixt2, *pixt3, *pixt4, *pixd;
653 PIXA *pixat;
654 
655  if (!fpixa)
656  return (PIX *)ERROR_PTR("fpixa not defined", __func__, NULL);
657 
658  if ((nlevels = fpixaGetCount(fpixa)) == 0)
659  return (PIX *)ERROR_PTR("pixas empty", __func__, NULL);
660 
661  if ((bmf = bmfCreate(NULL, fontsize)) == NULL)
662  L_ERROR("bmf not made; text will not be added", __func__);
663  pixat = pixaCreate(nlevels);
664  for (i = 0; i < nlevels; i++) {
665  fpix = fpixaGetFPix(fpixa, i, L_CLONE);
666  pixt1 = fpixConvertToPix(fpix, 8, L_CLIP_TO_ZERO, 0);
667  mag = factor * (1 << (nlevels - i - 1));
668  pixt2 = pixExpandReplicate(pixt1, mag);
669  pixt3 = pixConvertTo32(pixt2);
670  snprintf(buf, sizeof(buf), "Level %d\n", i);
671  pixt4 = pixAddSingleTextblock(pixt3, bmf, buf, 0xff000000,
672  L_ADD_BELOW, NULL);
673  pixaAddPix(pixat, pixt4, L_INSERT);
674  fpixDestroy(&fpix);
675  pixDestroy(&pixt1);
676  pixDestroy(&pixt2);
677  pixDestroy(&pixt3);
678  }
679  w = pixGetWidth(pixt4);
680  pixd = pixaDisplayTiledInRows(pixat, 32, nlevels * (w + 80), 1.0, 0, 30, 2);
681 
682  pixaDestroy(&pixat);
683  bmfDestroy(&bmf);
684  return pixd;
685 }
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
Definition: bmf.c:168
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()
Definition: bmf.c:118
l_ok boxGetGeometry(const BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
Definition: boxbasic.c:301
void boxDestroy(BOX **pbox)
boxDestroy()
Definition: boxbasic.c:273
BOXAA * boxaaCreate(l_int32 n)
boxaaCreate()
Definition: boxbasic.c:1145
l_ok boxaaAddBoxa(BOXAA *baa, BOXA *ba, l_int32 copyflag)
boxaaAddBoxa()
Definition: boxbasic.c:1241
l_ok boxaAddBox(BOXA *boxa, BOX *box, l_int32 copyflag)
boxaAddBox()
Definition: boxbasic.c:553
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
Definition: boxbasic.c:519
l_int32 boxaGetCount(const BOXA *boxa)
boxaGetCount()
Definition: boxbasic.c:661
BOXA * boxaaGetBoxa(BOXAA *baa, l_int32 index, l_int32 accessflag)
boxaaGetBoxa()
Definition: boxbasic.c:1386
BOX * boxaGetBox(BOXA *boxa, l_int32 index, l_int32 accessflag)
boxaGetBox()
Definition: boxbasic.c:702
void boxaaDestroy(BOXAA **pbaa)
boxaaDestroy()
Definition: boxbasic.c:1207
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
Definition: boxbasic.c:171
BOXA * boxaCreate(l_int32 n)
boxaCreate()
Definition: boxbasic.c:442
BOX * boxClipToRectangle(BOX *box, l_int32 wi, l_int32 hi)
boxClipToRectangle()
Definition: boxfunc1.c:1679
PIX * pixBlockconvAccum(PIX *pixs)
pixBlockconvAccum()
Definition: convolve.c:454
DPIX * pixMeanSquareAccum(PIX *pixs)
pixMeanSquareAccum()
Definition: convolve.c:1353
l_ok fpixaAddFPix(FPIXA *fpixa, FPIX *fpix, l_int32 copyflag)
fpixaAddFPix()
Definition: fpix1.c:669
void dpixDestroy(DPIX **pdpix)
dpixDestroy()
Definition: fpix1.c:1085
l_ok fpixaGetPixel(FPIXA *fpixa, l_int32 index, l_int32 x, l_int32 y, l_float32 *pval)
fpixaGetPixel()
Definition: fpix1.c:885
DPIX * dpixClone(DPIX *dpix)
dpixClone()
Definition: fpix1.c:1034
l_ok dpixGetPixel(DPIX *dpix, l_int32 x, l_int32 y, l_float64 *pval)
dpixGetPixel()
Definition: fpix1.c:1297
FPIX * fpixaGetFPix(FPIXA *fpixa, l_int32 index, l_int32 accesstype)
fpixaGetFPix()
Definition: fpix1.c:796
FPIXA * fpixaCreate(l_int32 n)
fpixaCreate()
Definition: fpix1.c:556
l_ok fpixSetPixel(FPIX *fpix, l_int32 x, l_int32 y, l_float32 val)
fpixSetPixel()
Definition: fpix1.c:527
void fpixDestroy(FPIX **pfpix)
fpixDestroy()
Definition: fpix1.c:280
l_int32 fpixaGetCount(FPIXA *fpixa)
fpixaGetCount()
Definition: fpix1.c:778
FPIX * fpixCreate(l_int32 width, l_int32 height)
fpixCreate()
Definition: fpix1.c:152
PIX * fpixConvertToPix(FPIX *fpixs, l_int32 outdepth, l_int32 negvals, l_int32 errorflag)
fpixConvertToPix()
Definition: fpix2.c:320
void pixDestroy(PIX **ppix)
pixDestroy()
Definition: pix1.c:608
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
Definition: pix1.c:1074
PIX * pixClone(PIX *pixs)
pixClone()
Definition: pix1.c:582
l_ok pixGetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval)
pixGetPixel()
Definition: pix2.c:192
@ L_ADD_BELOW
Definition: pix.h:1003
@ L_CLONE
Definition: pix.h:506
@ L_INSERT
Definition: pix.h:504
@ L_CLIP_TO_ZERO
Definition: pix.h:1062
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
Definition: pixabasic.c:493
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
Definition: pixabasic.c:404
PIXA * pixaCreate(l_int32 n)
pixaCreate()
Definition: pixabasic.c:167
PIX * pixaDisplayTiledInRows(PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledInRows()
Definition: pixafunc2.c:730
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
Definition: pixconv.c:3246
l_ok pixMeanInRectangle(PIX *pixs, BOX *box, PIX *pixma, l_float32 *pval)
pixMeanInRectangle()
Definition: quadtree.c:265
BOXAA * boxaaQuadtreeRegions(l_int32 w, l_int32 h, l_int32 nlevels)
boxaaQuadtreeRegions()
Definition: quadtree.c:445
l_int32 quadtreeMaxLevels(l_int32 w, l_int32 h)
quadtreeMaxLevels()
Definition: quadtree.c:609
l_ok pixQuadtreeVariance(PIX *pixs, l_int32 nlevels, PIX *pix_ma, DPIX *dpix_msa, FPIXA **pfpixa_v, FPIXA **pfpixa_rv)
pixQuadtreeVariance()
Definition: quadtree.c:171
l_ok quadtreeGetParent(FPIXA *fpixa, l_int32 level, l_int32 x, l_int32 y, l_float32 *pval)
quadtreeGetParent()
Definition: quadtree.c:524
PIX * fpixaDisplayQuadtree(FPIXA *fpixa, l_int32 factor, l_int32 fontsize)
fpixaDisplayQuadtree()
Definition: quadtree.c:644
l_ok quadtreeGetChildren(FPIXA *fpixa, l_int32 level, l_int32 x, l_int32 y, l_float32 *pval00, l_float32 *pval10, l_float32 *pval01, l_float32 *pval11)
quadtreeGetChildren()
Definition: quadtree.c:565
l_ok pixVarianceInRectangle(PIX *pixs, BOX *box, PIX *pix_ma, DPIX *dpix_msa, l_float32 *pvar, l_float32 *prvar)
pixVarianceInRectangle()
Definition: quadtree.c:339
l_ok pixQuadtreeMean(PIX *pixs, l_int32 nlevels, PIX *pix_ma, FPIXA **pfpixa)
pixQuadtreeMean()
Definition: quadtree.c:96
PIX * pixExpandReplicate(PIX *pixs, l_int32 factor)
pixExpandReplicate()
Definition: scale2.c:852
Definition: bmf.h:47
PIX * pixAddSingleTextblock(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location, l_int32 *poverflow)
pixAddSingleTextblock()
Definition: textops.c:120
void lept_stderr(const char *fmt,...)
lept_stderr()
Definition: utils1.c:306