Leptonica 1.85.0
Image processing and image analysis suite
Loading...
Searching...
No Matches
graphics.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
117#ifdef HAVE_CONFIG_H
118#include <config_auto.h>
119#endif /* HAVE_CONFIG_H */
120
121#include <string.h>
122#include <math.h>
123#include "allheaders.h"
124
125/*------------------------------------------------------------------*
126 * Pta generation for arbitrary shapes built with lines *
127 *------------------------------------------------------------------*/
140PTA *
142 l_int32 y1,
143 l_int32 x2,
144 l_int32 y2)
145{
146l_int32 npts, diff, getyofx, sign, i, x, y;
147l_float32 slope;
148PTA *pta;
149
150 /* Generate line parameters */
151 if (x1 == x2 && y1 == y2) { /* same point */
152 getyofx = TRUE;
153 npts = 1;
154 } else if (L_ABS(x2 - x1) >= L_ABS(y2 - y1)) {
155 getyofx = TRUE;
156 npts = L_ABS(x2 - x1) + 1;
157 diff = x2 - x1;
158 sign = L_SIGN(x2 - x1);
159 slope = (l_float32)(sign * (y2 - y1)) / (l_float32)diff;
160 } else {
161 getyofx = FALSE;
162 npts = L_ABS(y2 - y1) + 1;
163 diff = y2 - y1;
164 sign = L_SIGN(y2 - y1);
165 slope = (l_float32)(sign * (x2 - x1)) / (l_float32)diff;
166 }
167
168 if ((pta = ptaCreate(npts)) == NULL)
169 return (PTA *)ERROR_PTR("pta not made", __func__, NULL);
170
171 if (npts == 1) { /* degenerate case */
172 ptaAddPt(pta, x1, y1);
173 return pta;
174 }
175
176 /* Generate the set of points */
177 if (getyofx) { /* y = y(x) */
178 for (i = 0; i < npts; i++) {
179 x = x1 + sign * i;
180 y = (l_int32)(y1 + (l_float32)i * slope + 0.5);
181 ptaAddPt(pta, x, y);
182 }
183 } else { /* x = x(y) */
184 for (i = 0; i < npts; i++) {
185 x = (l_int32)(x1 + (l_float32)i * slope + 0.5);
186 y = y1 + sign * i;
187 ptaAddPt(pta, x, y);
188 }
189 }
190
191 return pta;
192}
193
194
203PTA *
205 l_int32 y1,
206 l_int32 x2,
207 l_int32 y2,
208 l_int32 width)
209{
210l_int32 i, x1a, x2a, y1a, y2a;
211PTA *pta, *ptaj;
212
213 if (width < 1) {
214 L_WARNING("width < 1; setting to 1\n", __func__);
215 width = 1;
216 }
217
218 if ((ptaj = generatePtaLine(x1, y1, x2, y2)) == NULL)
219 return (PTA *)ERROR_PTR("ptaj not made", __func__, NULL);
220 if (width == 1)
221 return ptaj;
222
223 /* width > 1; estimate line direction & join */
224 if (L_ABS(x1 - x2) > L_ABS(y1 - y2)) { /* "horizontal" line */
225 for (i = 1; i < width; i++) {
226 if ((i & 1) == 1) { /* place above */
227 y1a = y1 - (i + 1) / 2;
228 y2a = y2 - (i + 1) / 2;
229 } else { /* place below */
230 y1a = y1 + (i + 1) / 2;
231 y2a = y2 + (i + 1) / 2;
232 }
233 if ((pta = generatePtaLine(x1, y1a, x2, y2a)) != NULL) {
234 ptaJoin(ptaj, pta, 0, -1);
235 ptaDestroy(&pta);
236 }
237 }
238 } else { /* "vertical" line */
239 for (i = 1; i < width; i++) {
240 if ((i & 1) == 1) { /* place to left */
241 x1a = x1 - (i + 1) / 2;
242 x2a = x2 - (i + 1) / 2;
243 } else { /* place to right */
244 x1a = x1 + (i + 1) / 2;
245 x2a = x2 + (i + 1) / 2;
246 }
247 if ((pta = generatePtaLine(x1a, y1, x2a, y2)) != NULL) {
248 ptaJoin(ptaj, pta, 0, -1);
249 ptaDestroy(&pta);
250 }
251 }
252 }
253
254 return ptaj;
255}
256
257
271PTA *
273 l_int32 width)
274{
275l_int32 x, y, w, h;
276PTA *ptad, *pta;
277
278 if (!box)
279 return (PTA *)ERROR_PTR("box not defined", __func__, NULL);
280 if (width < 1) {
281 L_WARNING("width < 1; setting to 1\n", __func__);
282 width = 1;
283 }
284
285 /* Generate line points and add them to the pta. */
286 boxGetGeometry(box, &x, &y, &w, &h);
287 if (w == 0 || h == 0)
288 return (PTA *)ERROR_PTR("box has w = 0 or h = 0", __func__, NULL);
289 ptad = ptaCreate(0);
290 if ((width & 1) == 1) { /* odd width */
291 pta = generatePtaWideLine(x - width / 2, y,
292 x + w - 1 + width / 2, y, width);
293 ptaJoin(ptad, pta, 0, -1);
294 ptaDestroy(&pta);
295 pta = generatePtaWideLine(x + w - 1, y + 1 + width / 2,
296 x + w - 1, y + h - 2 - width / 2, width);
297 ptaJoin(ptad, pta, 0, -1);
298 ptaDestroy(&pta);
299 pta = generatePtaWideLine(x + w - 1 + width / 2, y + h - 1,
300 x - width / 2, y + h - 1, width);
301 ptaJoin(ptad, pta, 0, -1);
302 ptaDestroy(&pta);
303 pta = generatePtaWideLine(x, y + h - 2 - width / 2,
304 x, y + 1 + width / 2, width);
305 ptaJoin(ptad, pta, 0, -1);
306 ptaDestroy(&pta);
307 } else { /* even width */
308 pta = generatePtaWideLine(x - width / 2, y,
309 x + w - 2 + width / 2, y, width);
310 ptaJoin(ptad, pta, 0, -1);
311 ptaDestroy(&pta);
312 pta = generatePtaWideLine(x + w - 1, y + 0 + width / 2,
313 x + w - 1, y + h - 2 - width / 2, width);
314 ptaJoin(ptad, pta, 0, -1);
315 ptaDestroy(&pta);
316 pta = generatePtaWideLine(x + w - 2 + width / 2, y + h - 1,
317 x - width / 2, y + h - 1, width);
318 ptaJoin(ptad, pta, 0, -1);
319 ptaDestroy(&pta);
320 pta = generatePtaWideLine(x, y + h - 2 - width / 2,
321 x, y + 0 + width / 2, width);
322 ptaJoin(ptad, pta, 0, -1);
323 ptaDestroy(&pta);
324 }
325
326 return ptad;
327}
328
329
346PTA *
348 l_int32 width,
349 l_int32 removedups)
350{
351l_int32 i, n;
352BOX *box;
353PTA *ptad, *ptat, *pta;
354
355 if (!boxa)
356 return (PTA *)ERROR_PTR("boxa not defined", __func__, NULL);
357 if (width < 1) {
358 L_WARNING("width < 1; setting to 1\n", __func__);
359 width = 1;
360 }
361
362 n = boxaGetCount(boxa);
363 ptat = ptaCreate(0);
364 for (i = 0; i < n; i++) {
365 box = boxaGetBox(boxa, i, L_CLONE);
366 pta = generatePtaBox(box, width);
367 ptaJoin(ptat, pta, 0, -1);
368 ptaDestroy(&pta);
369 boxDestroy(&box);
370 }
371
372 if (removedups)
373 ptaRemoveDupsByAset(ptat, &ptad);
374 else
375 ptad = ptaClone(ptat);
376
377 ptaDestroy(&ptat);
378 return ptad;
379}
380
381
401PTA *
403 l_int32 spacing,
404 l_int32 width,
405 l_int32 orient,
406 l_int32 outline)
407{
408l_int32 bx, by, bh, bw, x, y, x1, y1, x2, y2, i, n, npts;
409PTA *ptad, *pta;
410
411 if (!box)
412 return (PTA *)ERROR_PTR("box not defined", __func__, NULL);
413 if (spacing <= 1)
414 return (PTA *)ERROR_PTR("spacing not > 1", __func__, NULL);
415 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
416 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
417 return (PTA *)ERROR_PTR("invalid line orientation", __func__, NULL);
418 boxGetGeometry(box, &bx, &by, &bw, &bh);
419 if (bw == 0 || bh == 0)
420 return (PTA *)ERROR_PTR("box has bw = 0 or bh = 0", __func__, NULL);
421 if (width < 1) {
422 L_WARNING("width < 1; setting to 1\n", __func__);
423 width = 1;
424 }
425
426 /* Generate line points and add them to the pta. */
427 ptad = ptaCreate(0);
428 if (outline) {
429 pta = generatePtaBox(box, width);
430 ptaJoin(ptad, pta, 0, -1);
431 ptaDestroy(&pta);
432 }
433 if (orient == L_HORIZONTAL_LINE) {
434 n = 1 + bh / spacing;
435 for (i = 0; i < n; i++) {
436 y = by + (i * (bh - 1)) / (n - 1);
437 pta = generatePtaWideLine(bx, y, bx + bw - 1, y, width);
438 ptaJoin(ptad, pta, 0, -1);
439 ptaDestroy(&pta);
440 }
441 } else if (orient == L_VERTICAL_LINE) {
442 n = 1 + bw / spacing;
443 for (i = 0; i < n; i++) {
444 x = bx + (i * (bw - 1)) / (n - 1);
445 pta = generatePtaWideLine(x, by, x, by + bh - 1, width);
446 ptaJoin(ptad, pta, 0, -1);
447 ptaDestroy(&pta);
448 }
449 } else if (orient == L_POS_SLOPE_LINE) {
450 n = 2 + (l_int32)((bw + bh) / (1.4 * spacing));
451 for (i = 0; i < n; i++) {
452 x = (l_int32)(bx + (i + 0.5) * 1.4 * spacing);
453 boxIntersectByLine(box, x, by - 1, 1.0, &x1, &y1, &x2, &y2, &npts);
454 if (npts == 2) {
455 pta = generatePtaWideLine(x1, y1, x2, y2, width);
456 ptaJoin(ptad, pta, 0, -1);
457 ptaDestroy(&pta);
458 }
459 }
460 } else { /* orient == L_NEG_SLOPE_LINE */
461 n = 2 + (l_int32)((bw + bh) / (1.4 * spacing));
462 for (i = 0; i < n; i++) {
463 x = (l_int32)(bx - bh + (i + 0.5) * 1.4 * spacing);
464 boxIntersectByLine(box, x, by - 1, -1.0, &x1, &y1, &x2, &y2, &npts);
465 if (npts == 2) {
466 pta = generatePtaWideLine(x1, y1, x2, y2, width);
467 ptaJoin(ptad, pta, 0, -1);
468 ptaDestroy(&pta);
469 }
470 }
471 }
472
473 return ptad;
474}
475
476
502PTA *
504 l_int32 spacing,
505 l_int32 width,
506 l_int32 orient,
507 l_int32 outline,
508 l_int32 removedups)
509{
510l_int32 i, n;
511BOX *box;
512PTA *ptad, *ptat, *pta;
513
514 if (!boxa)
515 return (PTA *)ERROR_PTR("boxa not defined", __func__, NULL);
516 if (spacing <= 1)
517 return (PTA *)ERROR_PTR("spacing not > 1", __func__, NULL);
518 if (width < 1) {
519 L_WARNING("width < 1; setting to 1\n", __func__);
520 width = 1;
521 }
522 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
523 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
524 return (PTA *)ERROR_PTR("invalid line orientation", __func__, NULL);
525
526 n = boxaGetCount(boxa);
527 ptat = ptaCreate(0);
528 for (i = 0; i < n; i++) {
529 box = boxaGetBox(boxa, i, L_CLONE);
530 pta = generatePtaHashBox(box, spacing, width, orient, outline);
531 ptaJoin(ptat, pta, 0, -1);
532 ptaDestroy(&pta);
533 boxDestroy(&box);
534 }
535
536 if (removedups)
537 ptaRemoveDupsByAset(ptat, &ptad);
538 else
539 ptad = ptaClone(ptat);
540
541 ptaDestroy(&ptat);
542 return ptad;
543}
544
545
560PTAA *
562{
563l_int32 i, n, x, y, w, h;
564BOX *box;
565PTA *pta;
566PTAA *ptaa;
567
568 if (!boxa)
569 return (PTAA *)ERROR_PTR("boxa not defined", __func__, NULL);
570
571 n = boxaGetCount(boxa);
572 ptaa = ptaaCreate(n);
573 for (i = 0; i < n; i++) {
574 box = boxaGetBox(boxa, i, L_CLONE);
575 boxGetGeometry(box, &x, &y, &w, &h);
576 pta = ptaCreate(4);
577 ptaAddPt(pta, x, y);
578 ptaAddPt(pta, x + w - 1, y);
579 ptaAddPt(pta, x + w - 1, y + h - 1);
580 ptaAddPt(pta, x, y + h - 1);
581 ptaaAddPta(ptaa, pta, L_INSERT);
582 boxDestroy(&box);
583 }
584
585 return ptaa;
586}
587
588
611PTAA *
613 l_int32 spacing,
614 l_int32 width,
615 l_int32 orient,
616 l_int32 outline)
617{
618l_int32 i, n;
619BOX *box;
620PTA *pta;
621PTAA *ptaa;
622
623 if (!boxa)
624 return (PTAA *)ERROR_PTR("boxa not defined", __func__, NULL);
625 if (spacing <= 1)
626 return (PTAA *)ERROR_PTR("spacing not > 1", __func__, NULL);
627 if (width < 1) {
628 L_WARNING("width < 1; setting to 1\n", __func__);
629 width = 1;
630 }
631 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
632 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
633 return (PTAA *)ERROR_PTR("invalid line orientation", __func__, NULL);
634
635 n = boxaGetCount(boxa);
636 ptaa = ptaaCreate(n);
637 for (i = 0; i < n; i++) {
638 box = boxaGetBox(boxa, i, L_CLONE);
639 pta = generatePtaHashBox(box, spacing, width, orient, outline);
640 ptaaAddPta(ptaa, pta, L_INSERT);
641 boxDestroy(&box);
642 }
643
644 return ptaa;
645}
646
647
657PTA *
659 l_int32 width,
660 l_int32 closeflag,
661 l_int32 removedups)
662{
663l_int32 i, n, x1, y1, x2, y2;
664PTA *ptad, *ptat, *pta;
665
666 if (!ptas)
667 return (PTA *)ERROR_PTR("ptas not defined", __func__, NULL);
668 if (width < 1) {
669 L_WARNING("width < 1; setting to 1\n", __func__);
670 width = 1;
671 }
672
673 n = ptaGetCount(ptas);
674 ptat = ptaCreate(0);
675 if (n < 2) /* nothing to do */
676 return ptat;
677
678 ptaGetIPt(ptas, 0, &x1, &y1);
679 for (i = 1; i < n; i++) {
680 ptaGetIPt(ptas, i, &x2, &y2);
681 pta = generatePtaWideLine(x1, y1, x2, y2, width);
682 ptaJoin(ptat, pta, 0, -1);
683 ptaDestroy(&pta);
684 x1 = x2;
685 y1 = y2;
686 }
687
688 if (closeflag) {
689 ptaGetIPt(ptas, 0, &x2, &y2);
690 pta = generatePtaWideLine(x1, y1, x2, y2, width);
691 ptaJoin(ptat, pta, 0, -1);
692 ptaDestroy(&pta);
693 }
694
695 if (removedups)
696 ptaRemoveDupsByAset(ptat, &ptad);
697 else
698 ptad = ptaClone(ptat);
699
700 ptaDestroy(&ptat);
701 return ptad;
702}
703
704
713PTA *
715 l_int32 h,
716 l_int32 nx,
717 l_int32 ny,
718 l_int32 width)
719{
720l_int32 i, j, bx, by, x1, x2, y1, y2;
721BOX *box;
722BOXA *boxa;
723PTA *pta;
724
725 if (nx < 1 || ny < 1)
726 return (PTA *)ERROR_PTR("nx and ny must be > 0", __func__, NULL);
727 if (w < 2 * nx || h < 2 * ny)
728 return (PTA *)ERROR_PTR("w and/or h too small", __func__, NULL);
729 if (width < 1) {
730 L_WARNING("width < 1; setting to 1\n", __func__);
731 width = 1;
732 }
733
734 boxa = boxaCreate(nx * ny);
735 bx = (w + nx - 1) / nx;
736 by = (h + ny - 1) / ny;
737 for (i = 0; i < ny; i++) {
738 y1 = by * i;
739 y2 = L_MIN(y1 + by, h - 1);
740 for (j = 0; j < nx; j++) {
741 x1 = bx * j;
742 x2 = L_MIN(x1 + bx, w - 1);
743 box = boxCreate(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
744 boxaAddBox(boxa, box, L_INSERT);
745 }
746 }
747
748 pta = generatePtaBoxa(boxa, width, 1);
749 boxaDestroy(&boxa);
750 return pta;
751}
752
753
769PTA *
771{
772l_int32 i, n, x, y, xp, yp;
773PTA *ptad;
774
775 if (!ptas)
776 return (PTA *)ERROR_PTR("ptas not defined", __func__, NULL);
777
778 n = ptaGetCount(ptas);
779 ptad = ptaCreate(n);
780 ptaGetIPt(ptas, 0, &xp, &yp);
781 ptaAddPt(ptad, xp, yp);
782 for (i = 1; i < n; i++) {
783 ptaGetIPt(ptas, i, &x, &y);
784 if (x != xp && y != yp) /* diagonal */
785 ptaAddPt(ptad, x, yp);
786 ptaAddPt(ptad, x, y);
787 xp = x;
788 yp = y;
789 }
790
791 return ptad;
792}
793
794
810PTA *
812{
813l_int32 x, y;
814l_float32 radthresh, sqdist;
815PTA *pta;
816
817 if (radius < 1)
818 return (PTA *)ERROR_PTR("radius must be >= 1", __func__, NULL);
819
820 pta = ptaCreate(0);
821 radthresh = (radius + 0.5) * (radius + 0.5);
822 for (y = 0; y <= 2 * radius; y++) {
823 for (x = 0; x <= 2 * radius; x++) {
824 sqdist = (l_float32)((y - radius) * (y - radius) +
825 (x - radius) * (x - radius));
826 if (sqdist <= radthresh)
827 ptaAddPt(pta, x, y);
828 }
829 }
830
831 return pta;
832}
833
834
848PTA *
850{
851l_int32 x, y;
852PTA *pta;
853
854 if (side < 1)
855 return (PTA *)ERROR_PTR("side must be > 0", __func__, NULL);
856
857 pta = ptaCreate(0);
858 for (y = 0; y < side; y++)
859 for (x = 0; x < side; x++)
860 ptaAddPt(pta, x, y);
861
862 return pta;
863}
864
865
881PTA *
883 l_int32 y,
884 l_float64 length,
885 l_float64 radang)
886{
887l_int32 x2, y2; /* the point at the other end of the line */
888
889 x2 = x + (l_int32)((length - 1.0) * cos(radang));
890 y2 = y + (l_int32)((length - 1.0) * sin(radang));
891 return generatePtaLine(x, y, x2, y2);
892}
893
894
905l_ok
907 l_int32 yr,
908 l_float64 dist,
909 l_float64 radang,
910 l_float64 *px,
911 l_float64 *py)
912{
913 if (!px || !py)
914 return ERROR_INT("&x and &y not both defined", __func__, 1);
915
916 *px = xr + dist * cos(radang);
917 *py = yr + dist * sin(radang);
918 return 0;
919}
920
921
922/*------------------------------------------------------------------*
923 * Rendering function plots directly on images *
924 *------------------------------------------------------------------*/
945l_ok
947 NUMA *na,
948 l_int32 plotloc,
949 l_int32 linewidth,
950 l_int32 max,
951 l_uint32 color)
952{
953l_int32 w, h, size, rval, gval, bval;
954PIX *pix1;
955PTA *pta;
956
957 if (!ppix)
958 return ERROR_INT("&pix not defined", __func__, 1);
959 if (*ppix == NULL)
960 return ERROR_INT("pix not defined", __func__, 1);
961
962 pixGetDimensions(*ppix, &w, &h, NULL);
963 size = (plotloc == L_PLOT_AT_TOP || plotloc == L_PLOT_AT_MID_HORIZ ||
964 plotloc == L_PLOT_AT_BOT) ? h : w;
965 pta = makePlotPtaFromNuma(na, size, plotloc, linewidth, max);
966 if (!pta)
967 return ERROR_INT("pta not made", __func__, 1);
968
969 if (pixGetDepth(*ppix) != 32) {
970 pix1 = pixConvertTo32(*ppix);
971 pixDestroy(ppix);
972 *ppix = pix1;
973 }
974 extractRGBValues(color, &rval, &gval, &bval);
975 pixRenderPtaArb(*ppix, pta, rval, gval, bval);
976 ptaDestroy(&pta);
977 return 0;
978}
979
980
1002PTA *
1004 l_int32 size,
1005 l_int32 plotloc,
1006 l_int32 linewidth,
1007 l_int32 max)
1008{
1009l_int32 orient, refpos;
1010
1011 if (!na)
1012 return (PTA *)ERROR_PTR("na not defined", __func__, NULL);
1013 if (plotloc == L_PLOT_AT_TOP || plotloc == L_PLOT_AT_MID_HORIZ ||
1014 plotloc == L_PLOT_AT_BOT) {
1015 orient = L_HORIZONTAL_LINE;
1016 } else if (plotloc == L_PLOT_AT_LEFT || plotloc == L_PLOT_AT_MID_VERT ||
1017 plotloc == L_PLOT_AT_RIGHT) {
1018 orient = L_VERTICAL_LINE;
1019 } else {
1020 return (PTA *)ERROR_PTR("invalid plotloc", __func__, NULL);
1021 }
1022
1023 if (plotloc == L_PLOT_AT_LEFT || plotloc == L_PLOT_AT_TOP)
1024 refpos = max;
1025 else if (plotloc == L_PLOT_AT_MID_VERT || plotloc == L_PLOT_AT_MID_HORIZ)
1026 refpos = size / 2;
1027 else /* L_PLOT_AT_RIGHT || L_PLOT_AT_BOT */
1028 refpos = size - max - 1;
1029
1030 return makePlotPtaFromNumaGen(na, orient, linewidth, refpos, max, 1);
1031}
1032
1033
1057l_ok
1059 NUMA *na,
1060 l_int32 orient,
1061 l_int32 linewidth,
1062 l_int32 refpos,
1063 l_int32 max,
1064 l_int32 drawref,
1065 l_uint32 color)
1066{
1067l_int32 rval, gval, bval;
1068PIX *pix1;
1069PTA *pta;
1070
1071 if (!ppix)
1072 return ERROR_INT("&pix not defined", __func__, 1);
1073 if (*ppix == NULL)
1074 return ERROR_INT("pix not defined", __func__, 1);
1075
1076 pta = makePlotPtaFromNumaGen(na, orient, linewidth, refpos, max, drawref);
1077 if (!pta)
1078 return ERROR_INT("pta not made", __func__, 1);
1079
1080 if (pixGetDepth(*ppix) != 32) {
1081 pix1 = pixConvertTo32(*ppix);
1082 pixDestroy(ppix);
1083 *ppix = pix1;
1084 }
1085 extractRGBValues(color, &rval, &gval, &bval);
1086 pixRenderPtaArb(*ppix, pta, rval, gval, bval);
1087 ptaDestroy(&pta);
1088 return 0;
1089}
1090
1091
1121PTA *
1123 l_int32 orient,
1124 l_int32 linewidth,
1125 l_int32 refpos,
1126 l_int32 max,
1127 l_int32 drawref)
1128{
1129l_int32 i, n, maxw, maxh;
1130l_float32 minval, maxval, absval, val, scale, start, del;
1131PTA *pta1, *pta2, *ptad;
1132
1133 if (!na)
1134 return (PTA *)ERROR_PTR("na not defined", __func__, NULL);
1135 if (orient != L_HORIZONTAL_LINE && orient != L_VERTICAL_LINE)
1136 return (PTA *)ERROR_PTR("invalid orient", __func__, NULL);
1137 if (linewidth < 1) {
1138 L_WARNING("linewidth < 1; setting to 1\n", __func__);
1139 linewidth = 1;
1140 }
1141 if (linewidth > 7) {
1142 L_WARNING("linewidth > 7; setting to 7\n", __func__);
1143 linewidth = 7;
1144 }
1145
1146 numaGetMin(na, &minval, NULL);
1147 numaGetMax(na, &maxval, NULL);
1148 absval = L_MAX(L_ABS(minval), L_ABS(maxval));
1149 scale = (l_float32)max / (l_float32)absval;
1150 n = numaGetCount(na);
1151 numaGetParameters(na, &start, &del);
1152
1153 /* Generate the plot points */
1154 pta1 = ptaCreate(n);
1155 maxw = maxh = 0;
1156 for (i = 0; i < n; i++) {
1157 numaGetFValue(na, i, &val);
1158 if (orient == L_HORIZONTAL_LINE) {
1159 ptaAddPt(pta1, start + i * del, refpos + scale * val);
1160 maxw = (del >= 0) ? start + n * del + linewidth
1161 : start + linewidth;
1162 maxh = refpos + max + linewidth;
1163 } else { /* vertical line */
1164 ptaAddPt(pta1, refpos + scale * val, start + i * del);
1165 maxw = refpos + max + linewidth;
1166 maxh = (del >= 0) ? start + n * del + linewidth
1167 : start + linewidth;
1168 }
1169 }
1170
1171 /* Optionally, widen the plot */
1172 if (linewidth > 1) {
1173 if (linewidth % 2 == 0) /* even linewidth; use side of a square */
1174 pta2 = generatePtaFilledSquare(linewidth);
1175 else /* odd linewidth; use radius of a circle */
1176 pta2 = generatePtaFilledCircle(linewidth / 2);
1177 ptad = ptaReplicatePattern(pta1, NULL, pta2, linewidth / 2,
1178 linewidth / 2, maxw, maxh);
1179 ptaDestroy(&pta2);
1180 } else {
1181 ptad = ptaClone(pta1);
1182 }
1183 ptaDestroy(&pta1);
1184
1185 /* Optionally, add the reference lines */
1186 if (drawref) {
1187 if (orient == L_HORIZONTAL_LINE) {
1188 pta1 = generatePtaLine(start, refpos, start + n * del, refpos);
1189 ptaJoin(ptad, pta1, 0, -1);
1190 ptaDestroy(&pta1);
1191 pta1 = generatePtaLine(start, refpos - max,
1192 start, refpos + max);
1193 ptaJoin(ptad, pta1, 0, -1);
1194 } else { /* vertical line */
1195 pta1 = generatePtaLine(refpos, start, refpos, start + n * del);
1196 ptaJoin(ptad, pta1, 0, -1);
1197 ptaDestroy(&pta1);
1198 pta1 = generatePtaLine(refpos - max, start,
1199 refpos + max, start);
1200 ptaJoin(ptad, pta1, 0, -1);
1201 }
1202 ptaDestroy(&pta1);
1203 }
1204
1205 return ptad;
1206}
1207
1208
1209/*------------------------------------------------------------------*
1210 * Pta generation for arbitrary shapes built with lines *
1211 *------------------------------------------------------------------*/
1232l_ok
1234 PTA *pta,
1235 l_int32 op)
1236{
1237l_int32 i, n, x, y, w, h, d, maxval;
1238
1239 if (!pix)
1240 return ERROR_INT("pix not defined", __func__, 1);
1241 if (pixGetColormap(pix))
1242 return ERROR_INT("pix is colormapped", __func__, 1);
1243 if (!pta)
1244 return ERROR_INT("pta not defined", __func__, 1);
1245 if (op != L_SET_PIXELS && op != L_CLEAR_PIXELS && op != L_FLIP_PIXELS)
1246 return ERROR_INT("invalid op", __func__, 1);
1247
1248 pixGetDimensions(pix, &w, &h, &d);
1249 maxval = 1;
1250 if (op == L_SET_PIXELS) {
1251 switch (d)
1252 {
1253 case 2:
1254 maxval = 0x3;
1255 break;
1256 case 4:
1257 maxval = 0xf;
1258 break;
1259 case 8:
1260 maxval = 0xff;
1261 break;
1262 case 16:
1263 maxval = 0xffff;
1264 break;
1265 case 32:
1266 maxval = 0xffffffff;
1267 break;
1268 }
1269 }
1270
1271 n = ptaGetCount(pta);
1272 for (i = 0; i < n; i++) {
1273 ptaGetIPt(pta, i, &x, &y);
1274 if (x < 0 || x >= w)
1275 continue;
1276 if (y < 0 || y >= h)
1277 continue;
1278 switch (op)
1279 {
1280 case L_SET_PIXELS:
1281 pixSetPixel(pix, x, y, maxval);
1282 break;
1283 case L_CLEAR_PIXELS:
1284 pixClearPixel(pix, x, y);
1285 break;
1286 case L_FLIP_PIXELS:
1287 pixFlipPixel(pix, x, y);
1288 break;
1289 default:
1290 break;
1291 }
1292 }
1293
1294 return 0;
1295}
1296
1297
1319l_ok
1321 PTA *pta,
1322 l_uint8 rval,
1323 l_uint8 gval,
1324 l_uint8 bval)
1325{
1326l_int32 i, n, x, y, w, h, d, index;
1327l_uint8 val;
1328l_uint32 val32;
1329PIXCMAP *cmap;
1330
1331 if (!pix)
1332 return ERROR_INT("pix not defined", __func__, 1);
1333 if (!pta)
1334 return ERROR_INT("pta not defined", __func__, 1);
1335 d = pixGetDepth(pix);
1336 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 32)
1337 return ERROR_INT("depth not in {1,2,4,8,32}", __func__, 1);
1338
1339 if (d == 1) {
1340 pixRenderPta(pix, pta, L_SET_PIXELS);
1341 return 0;
1342 }
1343
1344 cmap = pixGetColormap(pix);
1345 pixGetDimensions(pix, &w, &h, &d);
1346 if (cmap) {
1347 pixcmapAddNearestColor(cmap, rval, gval, bval, &index);
1348 } else {
1349 if (d == 2)
1350 val = (rval + gval + bval) / (3 * 64);
1351 else if (d == 4)
1352 val = (rval + gval + bval) / (3 * 16);
1353 else if (d == 8)
1354 val = (rval + gval + bval) / 3;
1355 else /* d == 32 */
1356 composeRGBPixel(rval, gval, bval, &val32);
1357 }
1358
1359 n = ptaGetCount(pta);
1360 for (i = 0; i < n; i++) {
1361 ptaGetIPt(pta, i, &x, &y);
1362 if (x < 0 || x >= w)
1363 continue;
1364 if (y < 0 || y >= h)
1365 continue;
1366 if (cmap)
1367 pixSetPixel(pix, x, y, index);
1368 else if (d == 32)
1369 pixSetPixel(pix, x, y, val32);
1370 else
1371 pixSetPixel(pix, x, y, val);
1372 }
1373
1374 return 0;
1375}
1376
1377
1392l_ok
1394 PTA *pta,
1395 l_uint8 rval,
1396 l_uint8 gval,
1397 l_uint8 bval,
1398 l_float32 fract)
1399{
1400l_int32 i, n, x, y, w, h;
1401l_uint8 nrval, ngval, nbval;
1402l_uint32 val32;
1403l_float32 frval, fgval, fbval;
1404
1405 if (!pix)
1406 return ERROR_INT("pix not defined", __func__, 1);
1407 if (!pta)
1408 return ERROR_INT("pta not defined", __func__, 1);
1409 if (pixGetDepth(pix) != 32)
1410 return ERROR_INT("depth not 32 bpp", __func__, 1);
1411 if (fract < 0.0 || fract > 1.0) {
1412 L_WARNING("fract must be in [0.0, 1.0]; setting to 0.5\n", __func__);
1413 fract = 0.5;
1414 }
1415
1416 pixGetDimensions(pix, &w, &h, NULL);
1417 n = ptaGetCount(pta);
1418 frval = fract * rval;
1419 fgval = fract * gval;
1420 fbval = fract * bval;
1421 for (i = 0; i < n; i++) {
1422 ptaGetIPt(pta, i, &x, &y);
1423 if (x < 0 || x >= w)
1424 continue;
1425 if (y < 0 || y >= h)
1426 continue;
1427 pixGetPixel(pix, x, y, &val32);
1428 nrval = GET_DATA_BYTE(&val32, COLOR_RED);
1429 nrval = (l_uint8)((1. - fract) * nrval + frval);
1430 ngval = GET_DATA_BYTE(&val32, COLOR_GREEN);
1431 ngval = (l_uint8)((1. - fract) * ngval + fgval);
1432 nbval = GET_DATA_BYTE(&val32, COLOR_BLUE);
1433 nbval = (l_uint8)((1. - fract) * nbval + fbval);
1434 composeRGBPixel(nrval, ngval, nbval, &val32);
1435 pixSetPixel(pix, x, y, val32);
1436 }
1437
1438 return 0;
1439}
1440
1441
1442/*------------------------------------------------------------------*
1443 * Rendering of arbitrary shapes built with lines *
1444 *------------------------------------------------------------------*/
1455l_ok
1457 l_int32 x1,
1458 l_int32 y1,
1459 l_int32 x2,
1460 l_int32 y2,
1461 l_int32 width,
1462 l_int32 op)
1463{
1464PTA *pta;
1465
1466 if (!pix)
1467 return ERROR_INT("pix not defined", __func__, 1);
1468 if (width < 1) {
1469 L_WARNING("width must be > 0; setting to 1\n", __func__);
1470 width = 1;
1471 }
1472 if (op != L_SET_PIXELS && op != L_CLEAR_PIXELS && op != L_FLIP_PIXELS)
1473 return ERROR_INT("invalid op", __func__, 1);
1474
1475 if ((pta = generatePtaWideLine(x1, y1, x2, y2, width)) == NULL)
1476 return ERROR_INT("pta not made", __func__, 1);
1477 pixRenderPta(pix, pta, op);
1478 ptaDestroy(&pta);
1479 return 0;
1480}
1481
1482
1493l_ok
1495 l_int32 x1,
1496 l_int32 y1,
1497 l_int32 x2,
1498 l_int32 y2,
1499 l_int32 width,
1500 l_uint8 rval,
1501 l_uint8 gval,
1502 l_uint8 bval)
1503{
1504PTA *pta;
1505
1506 if (!pix)
1507 return ERROR_INT("pix not defined", __func__, 1);
1508 if (width < 1) {
1509 L_WARNING("width must be > 0; setting to 1\n", __func__);
1510 width = 1;
1511 }
1512
1513 if ((pta = generatePtaWideLine(x1, y1, x2, y2, width)) == NULL)
1514 return ERROR_INT("pta not made", __func__, 1);
1515 pixRenderPtaArb(pix, pta, rval, gval, bval);
1516 ptaDestroy(&pta);
1517 return 0;
1518}
1519
1520
1532l_ok
1534 l_int32 x1,
1535 l_int32 y1,
1536 l_int32 x2,
1537 l_int32 y2,
1538 l_int32 width,
1539 l_uint8 rval,
1540 l_uint8 gval,
1541 l_uint8 bval,
1542 l_float32 fract)
1543{
1544PTA *pta;
1545
1546 if (!pix)
1547 return ERROR_INT("pix not defined", __func__, 1);
1548 if (width < 1) {
1549 L_WARNING("width must be > 0; setting to 1\n", __func__);
1550 width = 1;
1551 }
1552
1553 if ((pta = generatePtaWideLine(x1, y1, x2, y2, width)) == NULL)
1554 return ERROR_INT("pta not made", __func__, 1);
1555 pixRenderPtaBlend(pix, pta, rval, gval, bval, fract);
1556 ptaDestroy(&pta);
1557 return 0;
1558}
1559
1560
1570l_ok
1572 BOX *box,
1573 l_int32 width,
1574 l_int32 op)
1575{
1576PTA *pta;
1577
1578 if (!pix)
1579 return ERROR_INT("pix not defined", __func__, 1);
1580 if (!box)
1581 return ERROR_INT("box not defined", __func__, 1);
1582 if (width < 1) {
1583 L_WARNING("width < 1; setting to 1\n", __func__);
1584 width = 1;
1585 }
1586 if (op != L_SET_PIXELS && op != L_CLEAR_PIXELS && op != L_FLIP_PIXELS)
1587 return ERROR_INT("invalid op", __func__, 1);
1588
1589 if ((pta = generatePtaBox(box, width)) == NULL)
1590 return ERROR_INT("pta not made", __func__, 1);
1591 pixRenderPta(pix, pta, op);
1592 ptaDestroy(&pta);
1593 return 0;
1594}
1595
1596
1606l_ok
1608 BOX *box,
1609 l_int32 width,
1610 l_uint8 rval,
1611 l_uint8 gval,
1612 l_uint8 bval)
1613{
1614PTA *pta;
1615
1616 if (!pix)
1617 return ERROR_INT("pix not defined", __func__, 1);
1618 if (!box)
1619 return ERROR_INT("box not defined", __func__, 1);
1620 if (width < 1) {
1621 L_WARNING("width < 1; setting to 1\n", __func__);
1622 width = 1;
1623 }
1624
1625 if ((pta = generatePtaBox(box, width)) == NULL)
1626 return ERROR_INT("pta not made", __func__, 1);
1627 pixRenderPtaArb(pix, pta, rval, gval, bval);
1628 ptaDestroy(&pta);
1629 return 0;
1630}
1631
1632
1644l_ok
1646 BOX *box,
1647 l_int32 width,
1648 l_uint8 rval,
1649 l_uint8 gval,
1650 l_uint8 bval,
1651 l_float32 fract)
1652{
1653PTA *pta;
1654
1655 if (!pix)
1656 return ERROR_INT("pix not defined", __func__, 1);
1657 if (!box)
1658 return ERROR_INT("box not defined", __func__, 1);
1659 if (width < 1) {
1660 L_WARNING("width < 1; setting to 1\n", __func__);
1661 width = 1;
1662 }
1663
1664 if ((pta = generatePtaBox(box, width)) == NULL)
1665 return ERROR_INT("pta not made", __func__, 1);
1666 pixRenderPtaBlend(pix, pta, rval, gval, bval, fract);
1667 ptaDestroy(&pta);
1668 return 0;
1669}
1670
1671
1681l_ok
1683 BOXA *boxa,
1684 l_int32 width,
1685 l_int32 op)
1686{
1687PTA *pta;
1688
1689 if (!pix)
1690 return ERROR_INT("pix not defined", __func__, 1);
1691 if (!boxa)
1692 return ERROR_INT("boxa not defined", __func__, 1);
1693 if (width < 1) {
1694 L_WARNING("width < 1; setting to 1\n", __func__);
1695 width = 1;
1696 }
1697 if (op != L_SET_PIXELS && op != L_CLEAR_PIXELS && op != L_FLIP_PIXELS)
1698 return ERROR_INT("invalid op", __func__, 1);
1699
1700 if ((pta = generatePtaBoxa(boxa, width, 0)) == NULL)
1701 return ERROR_INT("pta not made", __func__, 1);
1702 pixRenderPta(pix, pta, op);
1703 ptaDestroy(&pta);
1704 return 0;
1705}
1706
1707
1717l_ok
1719 BOXA *boxa,
1720 l_int32 width,
1721 l_uint8 rval,
1722 l_uint8 gval,
1723 l_uint8 bval)
1724{
1725PTA *pta;
1726
1727 if (!pix)
1728 return ERROR_INT("pix not defined", __func__, 1);
1729 if (!boxa)
1730 return ERROR_INT("boxa not defined", __func__, 1);
1731 if (width < 1) {
1732 L_WARNING("width < 1; setting to 1\n", __func__);
1733 width = 1;
1734 }
1735
1736 if ((pta = generatePtaBoxa(boxa, width, 0)) == NULL)
1737 return ERROR_INT("pta not made", __func__, 1);
1738 pixRenderPtaArb(pix, pta, rval, gval, bval);
1739 ptaDestroy(&pta);
1740 return 0;
1741}
1742
1743
1756l_ok
1758 BOXA *boxa,
1759 l_int32 width,
1760 l_uint8 rval,
1761 l_uint8 gval,
1762 l_uint8 bval,
1763 l_float32 fract,
1764 l_int32 removedups)
1765{
1766PTA *pta;
1767
1768 if (!pix)
1769 return ERROR_INT("pix not defined", __func__, 1);
1770 if (!boxa)
1771 return ERROR_INT("boxa not defined", __func__, 1);
1772 if (width < 1) {
1773 L_WARNING("width < 1; setting to 1\n", __func__);
1774 width = 1;
1775 }
1776
1777 if ((pta = generatePtaBoxa(boxa, width, removedups)) == NULL)
1778 return ERROR_INT("pta not made", __func__, 1);
1779 pixRenderPtaBlend(pix, pta, rval, gval, bval, fract);
1780 ptaDestroy(&pta);
1781 return 0;
1782}
1783
1784
1797l_ok
1799 BOX *box,
1800 l_int32 spacing,
1801 l_int32 width,
1802 l_int32 orient,
1803 l_int32 outline,
1804 l_int32 op)
1805{
1806PTA *pta;
1807
1808 if (!pix)
1809 return ERROR_INT("pix not defined", __func__, 1);
1810 if (!box)
1811 return ERROR_INT("box not defined", __func__, 1);
1812 if (spacing <= 1)
1813 return ERROR_INT("spacing not > 1", __func__, 1);
1814 if (width < 1) {
1815 L_WARNING("width < 1; setting to 1\n", __func__);
1816 width = 1;
1817 }
1818 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
1819 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
1820 return ERROR_INT("invalid line orientation", __func__, 1);
1821 if (op != L_SET_PIXELS && op != L_CLEAR_PIXELS && op != L_FLIP_PIXELS)
1822 return ERROR_INT("invalid op", __func__, 1);
1823
1824 pta = generatePtaHashBox(box, spacing, width, orient, outline);
1825 if (!pta)
1826 return ERROR_INT("pta not made", __func__, 1);
1827 pixRenderPta(pix, pta, op);
1828 ptaDestroy(&pta);
1829 return 0;
1830}
1831
1832
1845l_ok
1847 BOX *box,
1848 l_int32 spacing,
1849 l_int32 width,
1850 l_int32 orient,
1851 l_int32 outline,
1852 l_int32 rval,
1853 l_int32 gval,
1854 l_int32 bval)
1855{
1856PTA *pta;
1857
1858 if (!pix)
1859 return ERROR_INT("pix not defined", __func__, 1);
1860 if (!box)
1861 return ERROR_INT("box not defined", __func__, 1);
1862 if (spacing <= 1)
1863 return ERROR_INT("spacing not > 1", __func__, 1);
1864 if (width < 1) {
1865 L_WARNING("width < 1; setting to 1\n", __func__);
1866 width = 1;
1867 }
1868 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
1869 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
1870 return ERROR_INT("invalid line orientation", __func__, 1);
1871
1872 pta = generatePtaHashBox(box, spacing, width, orient, outline);
1873 if (!pta)
1874 return ERROR_INT("pta not made", __func__, 1);
1875 pixRenderPtaArb(pix, pta, rval, gval, bval);
1876 ptaDestroy(&pta);
1877 return 0;
1878}
1879
1880
1895l_ok
1897 BOX *box,
1898 l_int32 spacing,
1899 l_int32 width,
1900 l_int32 orient,
1901 l_int32 outline,
1902 l_int32 rval,
1903 l_int32 gval,
1904 l_int32 bval,
1905 l_float32 fract)
1906{
1907PTA *pta;
1908
1909 if (!pix)
1910 return ERROR_INT("pix not defined", __func__, 1);
1911 if (!box)
1912 return ERROR_INT("box not defined", __func__, 1);
1913 if (spacing <= 1)
1914 return ERROR_INT("spacing not > 1", __func__, 1);
1915 if (width < 1) {
1916 L_WARNING("width < 1; setting to 1\n", __func__);
1917 width = 1;
1918 }
1919 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
1920 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
1921 return ERROR_INT("invalid line orientation", __func__, 1);
1922
1923 pta = generatePtaHashBox(box, spacing, width, orient, outline);
1924 if (!pta)
1925 return ERROR_INT("pta not made", __func__, 1);
1926 pixRenderPtaBlend(pix, pta, rval, gval, bval, fract);
1927 ptaDestroy(&pta);
1928 return 0;
1929}
1930
1931
1953l_ok
1955 PIX *pixm,
1956 l_int32 x,
1957 l_int32 y,
1958 l_int32 spacing,
1959 l_int32 width,
1960 l_int32 orient,
1961 l_int32 outline,
1962 l_int32 rval,
1963 l_int32 gval,
1964 l_int32 bval)
1965{
1966l_int32 w, h;
1967BOX *box1, *box2;
1968PIX *pix1;
1969PTA *pta1, *pta2;
1970
1971 if (!pix)
1972 return ERROR_INT("pix not defined", __func__, 1);
1973 if (!pixm || pixGetDepth(pixm) != 1)
1974 return ERROR_INT("pixm not defined or not 1 bpp", __func__, 1);
1975 if (spacing <= 1)
1976 return ERROR_INT("spacing not > 1", __func__, 1);
1977 if (width < 1) {
1978 L_WARNING("width < 1; setting to 1\n", __func__);
1979 width = 1;
1980 }
1981 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
1982 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
1983 return ERROR_INT("invalid line orientation", __func__, 1);
1984
1985 /* Get the points for masked hash lines */
1986 pixGetDimensions(pixm, &w, &h, NULL);
1987 box1 = boxCreate(0, 0, w, h);
1988 pta1 = generatePtaHashBox(box1, spacing, width, orient, outline);
1989 pta2 = ptaCropToMask(pta1, pixm);
1990 boxDestroy(&box1);
1991 ptaDestroy(&pta1);
1992
1993 /* Clip out the region and apply the hash lines */
1994 box2 = boxCreate(x, y, w, h);
1995 pix1 = pixClipRectangle(pix, box2, NULL);
1996 pixRenderPtaArb(pix1, pta2, rval, gval, bval);
1997 ptaDestroy(&pta2);
1998 boxDestroy(&box2);
1999
2000 /* Rasterop the altered rectangle back in place */
2001 pixRasterop(pix, x, y, w, h, PIX_SRC, pix1, 0, 0);
2002 pixDestroy(&pix1);
2003 return 0;
2004}
2005
2006
2021l_ok
2023 BOXA *boxa,
2024 l_int32 spacing,
2025 l_int32 width,
2026 l_int32 orient,
2027 l_int32 outline,
2028 l_int32 op)
2029 {
2030PTA *pta;
2031
2032 if (!pix)
2033 return ERROR_INT("pix not defined", __func__, 1);
2034 if (!boxa)
2035 return ERROR_INT("boxa not defined", __func__, 1);
2036 if (spacing <= 1)
2037 return ERROR_INT("spacing not > 1", __func__, 1);
2038 if (width < 1) {
2039 L_WARNING("width < 1; setting to 1\n", __func__);
2040 width = 1;
2041 }
2042 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
2043 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
2044 return ERROR_INT("invalid line orientation", __func__, 1);
2045 if (op != L_SET_PIXELS && op != L_CLEAR_PIXELS && op != L_FLIP_PIXELS)
2046 return ERROR_INT("invalid op", __func__, 1);
2047
2048 pta = generatePtaHashBoxa(boxa, spacing, width, orient, outline, 1);
2049 if (!pta)
2050 return ERROR_INT("pta not made", __func__, 1);
2051 pixRenderPta(pix, pta, op);
2052 ptaDestroy(&pta);
2053 return 0;
2054}
2055
2056
2071l_ok
2073 BOXA *boxa,
2074 l_int32 spacing,
2075 l_int32 width,
2076 l_int32 orient,
2077 l_int32 outline,
2078 l_int32 rval,
2079 l_int32 gval,
2080 l_int32 bval)
2081{
2082PTA *pta;
2083
2084 if (!pix)
2085 return ERROR_INT("pix not defined", __func__, 1);
2086 if (!boxa)
2087 return ERROR_INT("boxa not defined", __func__, 1);
2088 if (spacing <= 1)
2089 return ERROR_INT("spacing not > 1", __func__, 1);
2090 if (width < 1) {
2091 L_WARNING("width < 1; setting to 1\n", __func__);
2092 width = 1;
2093 }
2094 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
2095 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
2096 return ERROR_INT("invalid line orientation", __func__, 1);
2097
2098 pta = generatePtaHashBoxa(boxa, spacing, width, orient, outline, 1);
2099 if (!pta)
2100 return ERROR_INT("pta not made", __func__, 1);
2101 pixRenderPtaArb(pix, pta, rval, gval, bval);
2102 ptaDestroy(&pta);
2103 return 0;
2104}
2105
2106
2123l_ok
2125 BOXA *boxa,
2126 l_int32 spacing,
2127 l_int32 width,
2128 l_int32 orient,
2129 l_int32 outline,
2130 l_int32 rval,
2131 l_int32 gval,
2132 l_int32 bval,
2133 l_float32 fract)
2134{
2135PTA *pta;
2136
2137 if (!pix)
2138 return ERROR_INT("pix not defined", __func__, 1);
2139 if (!boxa)
2140 return ERROR_INT("boxa not defined", __func__, 1);
2141 if (spacing <= 1)
2142 return ERROR_INT("spacing not > 1", __func__, 1);
2143 if (width < 1) {
2144 L_WARNING("width < 1; setting to 1\n", __func__);
2145 width = 1;
2146 }
2147 if (orient != L_HORIZONTAL_LINE && orient != L_POS_SLOPE_LINE &&
2148 orient != L_VERTICAL_LINE && orient != L_NEG_SLOPE_LINE)
2149 return ERROR_INT("invalid line orientation", __func__, 1);
2150
2151 pta = generatePtaHashBoxa(boxa, spacing, width, orient, outline, 1);
2152 if (!pta)
2153 return ERROR_INT("pta not made", __func__, 1);
2154 pixRenderPtaBlend(pix, pta, rval, gval, bval, fract);
2155 ptaDestroy(&pta);
2156 return 0;
2157}
2158
2159
2175l_ok
2177 PTA *ptas,
2178 l_int32 width,
2179 l_int32 op,
2180 l_int32 closeflag)
2181{
2182PTA *pta;
2183
2184 if (!pix)
2185 return ERROR_INT("pix not defined", __func__, 1);
2186 if (!ptas)
2187 return ERROR_INT("ptas not defined", __func__, 1);
2188 if (width < 1) {
2189 L_WARNING("width < 1; setting to 1\n", __func__);
2190 width = 1;
2191 }
2192 if (op != L_SET_PIXELS && op != L_CLEAR_PIXELS && op != L_FLIP_PIXELS)
2193 return ERROR_INT("invalid op", __func__, 1);
2194
2195 if ((pta = generatePtaPolyline(ptas, width, closeflag, 0)) == NULL)
2196 return ERROR_INT("pta not made", __func__, 1);
2197 pixRenderPta(pix, pta, op);
2198 ptaDestroy(&pta);
2199 return 0;
2200}
2201
2202
2218l_ok
2220 PTA *ptas,
2221 l_int32 width,
2222 l_uint8 rval,
2223 l_uint8 gval,
2224 l_uint8 bval,
2225 l_int32 closeflag)
2226{
2227PTA *pta;
2228
2229 if (!pix)
2230 return ERROR_INT("pix not defined", __func__, 1);
2231 if (!ptas)
2232 return ERROR_INT("ptas not defined", __func__, 1);
2233 if (width < 1) {
2234 L_WARNING("width < 1; setting to 1\n", __func__);
2235 width = 1;
2236 }
2237
2238 if ((pta = generatePtaPolyline(ptas, width, closeflag, 0)) == NULL)
2239 return ERROR_INT("pta not made", __func__, 1);
2240 pixRenderPtaArb(pix, pta, rval, gval, bval);
2241 ptaDestroy(&pta);
2242 return 0;
2243}
2244
2245
2259l_ok
2261 PTA *ptas,
2262 l_int32 width,
2263 l_uint8 rval,
2264 l_uint8 gval,
2265 l_uint8 bval,
2266 l_float32 fract,
2267 l_int32 closeflag,
2268 l_int32 removedups)
2269{
2270PTA *pta;
2271
2272 if (!pix)
2273 return ERROR_INT("pix not defined", __func__, 1);
2274 if (!ptas)
2275 return ERROR_INT("ptas not defined", __func__, 1);
2276 if (width < 1) {
2277 L_WARNING("width < 1; setting to 1\n", __func__);
2278 width = 1;
2279 }
2280
2281 if ((pta = generatePtaPolyline(ptas, width, closeflag, removedups)) == NULL)
2282 return ERROR_INT("pta not made", __func__, 1);
2283 pixRenderPtaBlend(pix, pta, rval, gval, bval, fract);
2284 ptaDestroy(&pta);
2285 return 0;
2286}
2287
2288
2298l_ok
2300 l_int32 nx,
2301 l_int32 ny,
2302 l_int32 width,
2303 l_uint8 rval,
2304 l_uint8 gval,
2305 l_uint8 bval)
2306{
2307l_int32 w, h;
2308PTA *pta;
2309
2310 if (!pix)
2311 return ERROR_INT("pix not defined", __func__, 1);
2312 if (nx < 1 || ny < 1)
2313 return ERROR_INT("nx, ny must be > 0", __func__, 1);
2314 if (width < 1) {
2315 L_WARNING("width < 1; setting to 1\n", __func__);
2316 width = 1;
2317 }
2318
2319 pixGetDimensions(pix, &w, &h, NULL);
2320 if ((pta = generatePtaGrid(w, h, nx, ny, width)) == NULL)
2321 return ERROR_INT("pta not made", __func__, 1);
2322 pixRenderPtaArb(pix, pta, rval, gval, bval);
2323 ptaDestroy(&pta);
2324 return 0;
2325}
2326
2327
2356PIX *
2358 PTAA *ptaa,
2359 l_int32 polyflag,
2360 l_int32 width,
2361 l_int32 closeflag)
2362{
2363l_int32 i, n, index, rval, gval, bval;
2364PIXCMAP *cmap;
2365PTA *pta, *ptat;
2366PIX *pixd;
2367
2368 if (!pix)
2369 return (PIX *)ERROR_PTR("pix not defined", __func__, NULL);
2370 if (!ptaa)
2371 return (PIX *)ERROR_PTR("ptaa not defined", __func__, NULL);
2372 if (polyflag != 0 && width < 1) {
2373 L_WARNING("width < 1; setting to 1\n", __func__);
2374 width = 1;
2375 }
2376
2377 pixd = pixConvertTo8(pix, FALSE);
2378 cmap = pixcmapCreateRandom(8, 1, 1);
2379 pixSetColormap(pixd, cmap);
2380
2381 if ((n = ptaaGetCount(ptaa)) == 0)
2382 return pixd;
2383
2384 for (i = 0; i < n; i++) {
2385 index = 1 + (i % 254);
2386 pixcmapGetColor(cmap, index, &rval, &gval, &bval);
2387 pta = ptaaGetPta(ptaa, i, L_CLONE);
2388 if (polyflag)
2389 ptat = generatePtaPolyline(pta, width, closeflag, 0);
2390 else
2391 ptat = ptaClone(pta);
2392 pixRenderPtaArb(pixd, ptat, rval, gval, bval);
2393 ptaDestroy(&pta);
2394 ptaDestroy(&ptat);
2395 }
2396
2397 return pixd;
2398}
2399
2400
2401
2402/*------------------------------------------------------------------*
2403 * Rendering and filling of polygons *
2404 *------------------------------------------------------------------*/
2423PIX *
2425 l_int32 width,
2426 l_int32 *pxmin,
2427 l_int32 *pymin)
2428{
2429l_float32 fxmin, fxmax, fymin, fymax;
2430PIX *pixd;
2431PTA *pta1, *pta2;
2432
2433 if (pxmin) *pxmin = 0;
2434 if (pymin) *pymin = 0;
2435 if (!ptas)
2436 return (PIX *)ERROR_PTR("ptas not defined", __func__, NULL);
2437
2438 /* Generate a 4-connected polygon line */
2439 if ((pta1 = generatePtaPolyline(ptas, width, 1, 0)) == NULL)
2440 return (PIX *)ERROR_PTR("pta1 not made", __func__, NULL);
2441 if (width < 2)
2442 pta2 = convertPtaLineTo4cc(pta1);
2443 else
2444 pta2 = ptaClone(pta1);
2445
2446 /* Render onto a minimum-sized pix */
2447 ptaGetRange(pta2, &fxmin, &fxmax, &fymin, &fymax);
2448 if (pxmin) *pxmin = (l_int32)(fxmin + 0.5);
2449 if (pymin) *pymin = (l_int32)(fymin + 0.5);
2450 pixd = pixCreate((l_int32)(fxmax + 0.5) + 1, (l_int32)(fymax + 0.5) + 1, 1);
2451 pixRenderPolyline(pixd, pta2, width, L_SET_PIXELS, 1);
2452 ptaDestroy(&pta1);
2453 ptaDestroy(&pta2);
2454 return pixd;
2455}
2456
2457
2476PIX *
2478 PTA *pta,
2479 l_int32 xmin,
2480 l_int32 ymin)
2481{
2482l_int32 w, h, i, n, inside, found;
2483l_int32 *xstart, *xend;
2484PIX *pixi, *pixd;
2485
2486 if (!pixs || (pixGetDepth(pixs) != 1))
2487 return (PIX *)ERROR_PTR("pixs undefined or not 1 bpp", __func__, NULL);
2488 if (!pta)
2489 return (PIX *)ERROR_PTR("pta not defined", __func__, NULL);
2490 if (ptaGetCount(pta) < 2)
2491 return (PIX *)ERROR_PTR("pta has < 2 pts", __func__, NULL);
2492
2493 pixGetDimensions(pixs, &w, &h, NULL);
2494 xstart = (l_int32 *)LEPT_CALLOC(L_MAX(1, w / 2), sizeof(l_int32));
2495 xend = (l_int32 *)LEPT_CALLOC(L_MAX(1, w / 2), sizeof(l_int32));
2496 if (!xstart || !xend) {
2497 LEPT_FREE(xstart);
2498 LEPT_FREE(xend);
2499 return (PIX *)ERROR_PTR("xstart and xend not made", __func__, NULL);
2500 }
2501
2502 /* Find a raster with 2 or more black runs. The first background
2503 * pixel after the end of the first run is likely to be inside
2504 * the polygon, and can be used as a seed pixel. */
2505 found = FALSE;
2506 for (i = ymin + 1; i < h; i++) {
2507 pixFindHorizontalRuns(pixs, i, xstart, xend, &n);
2508 if (n > 1) {
2509 ptaPtInsidePolygon(pta, xend[0] + 1, i, &inside);
2510 if (inside) {
2511 found = TRUE;
2512 break;
2513 }
2514 }
2515 }
2516 if (!found) {
2517 L_WARNING("nothing found to fill\n", __func__);
2518 LEPT_FREE(xstart);
2519 LEPT_FREE(xend);
2520 return 0;
2521 }
2522
2523 /* Place the seed pixel in the output image */
2524 pixd = pixCreateTemplate(pixs);
2525 pixSetPixel(pixd, xend[0] + 1, i, 1);
2526
2527 /* Invert pixs to make a filling mask, and fill from the seed */
2528 pixi = pixInvert(NULL, pixs);
2529 pixSeedfillBinary(pixd, pixd, pixi, 4);
2530
2531 /* Add the pixels of the original polygon outline */
2532 pixOr(pixd, pixd, pixs);
2533
2534 pixDestroy(&pixi);
2535 LEPT_FREE(xstart);
2536 LEPT_FREE(xend);
2537 return pixd;
2538}
2539
2540
2541/*------------------------------------------------------------------*
2542 * Contour rendering on grayscale images *
2543 *------------------------------------------------------------------*/
2560PIX *
2562 l_int32 startval,
2563 l_int32 incr,
2564 l_int32 outdepth)
2565{
2566l_int32 w, h, d, maxval, wpls, wpld, i, j, val, test;
2567l_uint32 *datas, *datad, *lines, *lined;
2568PIX *pixd;
2569
2570 if (!pixs)
2571 return (PIX *)ERROR_PTR("pixs not defined", __func__, NULL);
2572 if (pixGetColormap(pixs))
2573 return (PIX *)ERROR_PTR("pixs has colormap", __func__, NULL);
2574 pixGetDimensions(pixs, &w, &h, &d);
2575 if (d != 8 && d != 16)
2576 return (PIX *)ERROR_PTR("pixs not 8 or 16 bpp", __func__, NULL);
2577 if (outdepth != 1 && outdepth != d) {
2578 L_WARNING("invalid outdepth; setting to 1\n", __func__);
2579 outdepth = 1;
2580 }
2581 maxval = (1 << d) - 1;
2582 if (startval < 0 || startval > maxval)
2583 return (PIX *)ERROR_PTR("startval not in [0 ... maxval]",
2584 __func__, NULL);
2585 if (incr < 1)
2586 return (PIX *)ERROR_PTR("incr < 1", __func__, NULL);
2587
2588 if (outdepth == d)
2589 pixd = pixCopy(NULL, pixs);
2590 else
2591 pixd = pixCreate(w, h, 1);
2592
2593 pixCopyResolution(pixd, pixs);
2594 datad = pixGetData(pixd);
2595 wpld = pixGetWpl(pixd);
2596 datas = pixGetData(pixs);
2597 wpls = pixGetWpl(pixs);
2598
2599 switch (d)
2600 {
2601 case 8:
2602 if (outdepth == 1) {
2603 for (i = 0; i < h; i++) {
2604 lines = datas + i * wpls;
2605 lined = datad + i * wpld;
2606 for (j = 0; j < w; j++) {
2607 val = GET_DATA_BYTE(lines, j);
2608 if (val < startval)
2609 continue;
2610 test = (val - startval) % incr;
2611 if (!test)
2612 SET_DATA_BIT(lined, j);
2613 }
2614 }
2615 } else { /* outdepth == d */
2616 for (i = 0; i < h; i++) {
2617 lines = datas + i * wpls;
2618 lined = datad + i * wpld;
2619 for (j = 0; j < w; j++) {
2620 val = GET_DATA_BYTE(lines, j);
2621 if (val < startval)
2622 continue;
2623 test = (val - startval) % incr;
2624 if (!test)
2625 SET_DATA_BYTE(lined, j, 0);
2626 }
2627 }
2628 }
2629 break;
2630
2631 case 16:
2632 if (outdepth == 1) {
2633 for (i = 0; i < h; i++) {
2634 lines = datas + i * wpls;
2635 lined = datad + i * wpld;
2636 for (j = 0; j < w; j++) {
2637 val = GET_DATA_TWO_BYTES(lines, j);
2638 if (val < startval)
2639 continue;
2640 test = (val - startval) % incr;
2641 if (!test)
2642 SET_DATA_BIT(lined, j);
2643 }
2644 }
2645 } else { /* outdepth == d */
2646 for (i = 0; i < h; i++) {
2647 lines = datas + i * wpls;
2648 lined = datad + i * wpld;
2649 for (j = 0; j < w; j++) {
2650 val = GET_DATA_TWO_BYTES(lines, j);
2651 if (val < startval)
2652 continue;
2653 test = (val - startval) % incr;
2654 if (!test)
2655 SET_DATA_TWO_BYTES(lined, j, 0);
2656 }
2657 }
2658 }
2659 break;
2660
2661 default:
2662 return (PIX *)ERROR_PTR("pixs not 8 or 16 bpp", __func__, NULL);
2663 }
2664
2665 return pixd;
2666}
2667
2668
2684PIX *
2686 l_int32 ncontours)
2687{
2688l_float32 minval, maxval, incr;
2689
2690 if (!fpix)
2691 return (PIX *)ERROR_PTR("fpix not defined", __func__, NULL);
2692 if (ncontours < 2 || ncontours > 500)
2693 return (PIX *)ERROR_PTR("ncontours < 2 or > 500", __func__, NULL);
2694
2695 fpixGetMin(fpix, &minval, NULL, NULL);
2696 fpixGetMax(fpix, &maxval, NULL, NULL);
2697 if (minval == maxval)
2698 return (PIX *)ERROR_PTR("all values in fpix are equal", __func__, NULL);
2699 incr = (maxval - minval) / ((l_float32)ncontours - 1);
2700 return fpixRenderContours(fpix, incr, 0.15f);
2701}
2702
2703
2720PIX *
2722 l_float32 incr,
2723 l_float32 proxim)
2724{
2725l_int32 i, j, w, h, wpls, wpld;
2726l_float32 val, invincr, finter, above, below, diff;
2727l_uint32 *datad, *lined;
2728l_float32 *datas, *lines;
2729PIX *pixd;
2730PIXCMAP *cmap;
2731
2732 if (!fpixs)
2733 return (PIX *)ERROR_PTR("fpixs not defined", __func__, NULL);
2734 if (incr <= 0.0)
2735 return (PIX *)ERROR_PTR("incr <= 0.0", __func__, NULL);
2736 if (proxim <= 0.0)
2737 proxim = 0.15f; /* default */
2738
2739 fpixGetDimensions(fpixs, &w, &h);
2740 if ((pixd = pixCreate(w, h, 8)) == NULL)
2741 return (PIX *)ERROR_PTR("pixd not made", __func__, NULL);
2742 cmap = pixcmapCreate(8);
2743 pixSetColormap(pixd, cmap);
2744 pixcmapAddColor(cmap, 255, 255, 255); /* white */
2745 pixcmapAddColor(cmap, 0, 0, 0); /* black */
2746 pixcmapAddColor(cmap, 255, 0, 0); /* red */
2747
2748 datas = fpixGetData(fpixs);
2749 wpls = fpixGetWpl(fpixs);
2750 datad = pixGetData(pixd);
2751 wpld = pixGetWpl(pixd);
2752 invincr = 1.0 / incr;
2753 for (i = 0; i < h; i++) {
2754 lines = datas + i * wpls;
2755 lined = datad + i * wpld;
2756 for (j = 0; j < w; j++) {
2757 val = lines[j];
2758 finter = invincr * val;
2759 above = finter - floorf(finter);
2760 below = ceilf(finter) - finter;
2761 diff = L_MIN(above, below);
2762 if (diff <= proxim) {
2763 if (val < 0.0)
2764 SET_DATA_BYTE(lined, j, 2);
2765 else
2766 SET_DATA_BYTE(lined, j, 1);
2767 }
2768 }
2769 }
2770
2771 return pixd;
2772}
2773
2774
2775/*------------------------------------------------------------------*
2776 * Boundary pt generation on 1 bpp images *
2777 *------------------------------------------------------------------*/
2797PTA *
2799 l_int32 width)
2800{
2801PIX *pix1;
2802PTA *pta;
2803
2804 if (!pixs || pixGetDepth(pixs) != 1)
2805 return (PTA *)ERROR_PTR("pixs undefined or not 1 bpp", __func__, NULL);
2806 if (width < 1) {
2807 L_WARNING("width < 1; setting to 1\n", __func__);
2808 width = 1;
2809 }
2810
2811 pix1 = pixErodeBrick(NULL, pixs, 2 * width + 1, 2 * width + 1);
2812 pixXor(pix1, pix1, pixs);
2813 pta = ptaGetPixelsFromPix(pix1, NULL);
2814 pixDestroy(&pix1);
2815 return pta;
2816}
#define GET_DATA_TWO_BYTES(pdata, n)
#define SET_DATA_BIT(pdata, n)
#define SET_DATA_TWO_BYTES(pdata, n, val)
#define GET_DATA_BYTE(pdata, n)
#define SET_DATA_BYTE(pdata, n, val)
l_ok pixRenderPolyline(PIX *pix, PTA *ptas, l_int32 width, l_int32 op, l_int32 closeflag)
pixRenderPolyline()
Definition graphics.c:2176
l_ok pixRenderHashBoxaBlend(PIX *pix, BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval, l_float32 fract)
pixRenderHashBoxaBlend()
Definition graphics.c:2124
l_ok pixRenderGridArb(PIX *pix, l_int32 nx, l_int32 ny, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderGridArb()
Definition graphics.c:2299
l_ok 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()
Definition graphics.c:1896
PTA * generatePtaHashBoxa(BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 removedups)
generatePtaHashBoxa()
Definition graphics.c:503
l_ok pixRenderHashBox(PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 op)
pixRenderHashBox()
Definition graphics.c:1798
l_ok pixRenderPtaArb(PIX *pix, PTA *pta, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderPtaArb()
Definition graphics.c:1320
PTA * generatePtaLineFromPt(l_int32 x, l_int32 y, l_float64 length, l_float64 radang)
generatePtaLineFromPt()
Definition graphics.c:882
l_ok locatePtRadially(l_int32 xr, l_int32 yr, l_float64 dist, l_float64 radang, l_float64 *px, l_float64 *py)
locatePtRadially()
Definition graphics.c:906
l_ok pixRenderBoxBlend(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract)
pixRenderBoxBlend()
Definition graphics.c:1645
l_ok pixRenderPtaBlend(PIX *pix, PTA *pta, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract)
pixRenderPtaBlend()
Definition graphics.c:1393
l_ok pixRenderLine(PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_int32 op)
pixRenderLine()
Definition graphics.c:1456
PTA * generatePtaLine(l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2)
generatePtaLine()
Definition graphics.c:141
PTA * makePlotPtaFromNumaGen(NUMA *na, l_int32 orient, l_int32 linewidth, l_int32 refpos, l_int32 max, l_int32 drawref)
makePlotPtaFromNumaGen()
Definition graphics.c:1122
PIX * fpixRenderContours(FPIX *fpixs, l_float32 incr, l_float32 proxim)
fpixRenderContours()
Definition graphics.c:2721
l_ok pixRenderHashBoxa(PIX *pix, BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 op)
pixRenderHashBoxa()
Definition graphics.c:2022
l_ok pixRenderHashBoxaArb(PIX *pix, BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval)
pixRenderHashBoxaArb()
Definition graphics.c:2072
PIX * pixFillPolygon(PIX *pixs, PTA *pta, l_int32 xmin, l_int32 ymin)
pixFillPolygon()
Definition graphics.c:2477
l_ok pixRenderBox(PIX *pix, BOX *box, l_int32 width, l_int32 op)
pixRenderBox()
Definition graphics.c:1571
PTA * generatePtaPolyline(PTA *ptas, l_int32 width, l_int32 closeflag, l_int32 removedups)
generatePtaPolyline()
Definition graphics.c:658
l_ok pixRenderPolylineArb(PIX *pix, PTA *ptas, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_int32 closeflag)
pixRenderPolylineArb()
Definition graphics.c:2219
PTA * generatePtaBoxa(BOXA *boxa, l_int32 width, l_int32 removedups)
generatePtaBoxa()
Definition graphics.c:347
l_ok 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()
Definition graphics.c:2260
l_ok pixRenderPlotFromNuma(PIX **ppix, NUMA *na, l_int32 plotloc, l_int32 linewidth, l_int32 max, l_uint32 color)
pixRenderPlotFromNuma()
Definition graphics.c:946
PTA * generatePtaFilledCircle(l_int32 radius)
generatePtaFilledCircle()
Definition graphics.c:811
PTA * pixGeneratePtaBoundary(PIX *pixs, l_int32 width)
pixGeneratePtaBoundary()
Definition graphics.c:2798
PIX * fpixAutoRenderContours(FPIX *fpix, l_int32 ncontours)
fpixAutoRenderContours()
Definition graphics.c:2685
PTAA * generatePtaaBoxa(BOXA *boxa)
generatePtaaBoxa()
Definition graphics.c:561
PTA * generatePtaGrid(l_int32 w, l_int32 h, l_int32 nx, l_int32 ny, l_int32 width)
generatePtaGrid()
Definition graphics.c:714
l_ok pixRenderPlotFromNumaGen(PIX **ppix, NUMA *na, l_int32 orient, l_int32 linewidth, l_int32 refpos, l_int32 max, l_int32 drawref, l_uint32 color)
pixRenderPlotFromNumaGen()
Definition graphics.c:1058
l_ok 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)
pixRenderHashBoxArb()
Definition graphics.c:1846
PTAA * generatePtaaHashBoxa(BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline)
generatePtaaHashBoxa()
Definition graphics.c:612
PTA * convertPtaLineTo4cc(PTA *ptas)
convertPtaLineTo4cc()
Definition graphics.c:770
l_ok pixRenderHashMaskArb(PIX *pix, PIX *pixm, l_int32 x, l_int32 y, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval)
pixRenderHashMaskArb()
Definition graphics.c:1954
l_ok 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()
Definition graphics.c:1494
l_ok 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()
Definition graphics.c:1533
l_ok pixRenderBoxaBlend(PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract, l_int32 removedups)
pixRenderBoxaBlend()
Definition graphics.c:1757
l_ok pixRenderBoxArb(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxArb()
Definition graphics.c:1607
PIX * pixRenderContours(PIX *pixs, l_int32 startval, l_int32 incr, l_int32 outdepth)
pixRenderContours()
Definition graphics.c:2561
l_ok pixRenderBoxa(PIX *pix, BOXA *boxa, l_int32 width, l_int32 op)
pixRenderBoxa()
Definition graphics.c:1682
PIX * pixRenderPolygon(PTA *ptas, l_int32 width, l_int32 *pxmin, l_int32 *pymin)
pixRenderPolygon()
Definition graphics.c:2424
PTA * generatePtaHashBox(BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline)
generatePtaHashBox()
Definition graphics.c:402
PTA * generatePtaFilledSquare(l_int32 side)
generatePtaFilledSquare()
Definition graphics.c:849
l_ok pixRenderBoxaArb(PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxaArb()
Definition graphics.c:1718
PIX * pixRenderRandomCmapPtaa(PIX *pix, PTAA *ptaa, l_int32 polyflag, l_int32 width, l_int32 closeflag)
pixRenderRandomCmapPtaa()
Definition graphics.c:2357
PTA * generatePtaWideLine(l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width)
generatePtaWideLine()
Definition graphics.c:204
PTA * generatePtaBox(BOX *box, l_int32 width)
generatePtaBox()
Definition graphics.c:272
PTA * makePlotPtaFromNuma(NUMA *na, l_int32 size, l_int32 plotloc, l_int32 linewidth, l_int32 max)
makePlotPtaFromNuma()
Definition graphics.c:1003
l_ok pixRenderPta(PIX *pix, PTA *pta, l_int32 op)
pixRenderPta()
Definition graphics.c:1233
@ COLOR_BLUE
Definition pix.h:330
@ COLOR_RED
Definition pix.h:328
@ COLOR_GREEN
Definition pix.h:329
@ L_FLIP_PIXELS
Definition pix.h:567
@ L_SET_PIXELS
Definition pix.h:565
@ L_CLEAR_PIXELS
Definition pix.h:566
@ L_POS_SLOPE_LINE
Definition pix.h:807
@ L_HORIZONTAL_LINE
Definition pix.h:806
@ L_NEG_SLOPE_LINE
Definition pix.h:809
@ L_VERTICAL_LINE
Definition pix.h:808
@ L_CLONE
Definition pix.h:506
@ L_INSERT
Definition pix.h:504
@ L_PLOT_AT_BOT
Definition pix.h:1019
@ L_PLOT_AT_LEFT
Definition pix.h:1020
@ L_PLOT_AT_MID_VERT
Definition pix.h:1021
@ L_PLOT_AT_MID_HORIZ
Definition pix.h:1018
@ L_PLOT_AT_TOP
Definition pix.h:1017
@ L_PLOT_AT_RIGHT
Definition pix.h:1022
#define PIX_SRC
Definition pix.h:444