158 #include <config_auto.h>
163 #include "allheaders.h"
167 static l_int32 var_NEUTRAL_BOOST_VAL = 180;
170 #ifndef NO_CONSOLE_IO
171 #define DEBUG_CONVERT_TO_COLORMAP 0
172 #define DEBUG_UNROLLING 0
218 PROCNAME(
"pixThreshold8");
221 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
222 if (pixGetDepth(pixs) != 8)
223 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp", procName, NULL);
224 if (cmapflag && nlevels < 2)
225 return (
PIX *)ERROR_PTR(
"nlevels must be at least 2", procName, NULL);
245 return (
PIX *)ERROR_PTR(
"d must be in {1,2,4,8}", procName, NULL);
249 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
250 pixCopyInputFormat(pixd, pixs);
282 PROCNAME(
"pixRemoveColormapGeneral");
285 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
287 return (
PIX *)ERROR_PTR(
"invalid value for ifnocmap", procName, NULL);
289 if (pixGetColormap(pixs))
331 l_int32 sval, rval, gval, bval, val0, val1;
332 l_int32 i, j, k, w, h, d, wpls, wpld, ncolors, nalloc, count;
333 l_int32 opaque, colorfound, blackwhite;
334 l_int32 *rmap, *gmap, *bmap, *amap;
335 l_uint32 *datas, *lines, *datad, *lined, *lut, *graymap;
336 l_uint32 sword, dword;
340 PROCNAME(
"pixRemoveColormap");
343 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
344 if ((cmap = pixGetColormap(pixs)) == NULL)
351 L_WARNING(
"Invalid type; converting based on src\n", procName);
355 if (d != 1 && d != 2 && d != 4 && d != 8)
356 return (
PIX *)ERROR_PTR(
"pixs must be {1,2,4,8} bpp", procName, NULL);
360 if (ncolors > nalloc)
361 return (
PIX *)ERROR_PTR(
"too many colors for pixel depth",
365 return (
PIX *)ERROR_PTR(
"colormap arrays not made", procName, NULL);
368 L_WARNING(
"not 1 bpp; can't remove cmap to binary\n", procName);
379 }
else if (colorfound) {
382 if (d == 1 && blackwhite)
390 wpls = pixGetWpl(pixs);
392 if ((pixd =
pixCopy(NULL, pixs)) == NULL) {
393 L_ERROR(
"pixd not made\n", procName);
397 val0 = rval + gval + bval;
399 val1 = rval + gval + bval;
404 if ((pixd =
pixCreate(w, h, 8)) == NULL) {
405 L_ERROR(
"pixd not made\n", procName);
408 pixCopyResolution(pixd, pixs);
409 pixCopyInputFormat(pixd, pixs);
411 wpld = pixGetWpl(pixd);
412 graymap = (l_uint32 *)LEPT_CALLOC(nalloc,
sizeof(l_uint32));
413 for (i = 0; i < ncolors; i++) {
418 for (i = 0; i < h; i++) {
419 lines = datas + i * wpls;
420 lined = datad + i * wpld;
425 for (j = 0, count = 0; j + 3 < w; j += 4, count++) {
426 sword = lines[count];
427 dword = (graymap[(sword >> 24) & 0xff] << 24) |
428 (graymap[(sword >> 16) & 0xff] << 16) |
429 (graymap[(sword >> 8) & 0xff] << 8) |
430 graymap[sword & 0xff];
431 lined[count] = dword;
436 gval = graymap[sval];
440 #define CHECK_VALUE(a, b, c) if (GET_DATA_BYTE(a, b) != c) { \
441 lept_stderr("Error: mismatch at %d, %d vs %d\n", \
442 j, GET_DATA_BYTE(a, b), c); }
443 for (j = 0; j < w; j++) {
445 gval = graymap[sval];
446 CHECK_VALUE(lined, j, gval);
452 for (j = 0, count = 0; j + 7 < w; j += 8, count++) {
453 sword = lines[count];
454 dword = (graymap[(sword >> 28) & 0xf] << 24) |
455 (graymap[(sword >> 24) & 0xf] << 16) |
456 (graymap[(sword >> 20) & 0xf] << 8) |
457 graymap[(sword >> 16) & 0xf];
458 lined[2 * count] = dword;
459 dword = (graymap[(sword >> 12) & 0xf] << 24) |
460 (graymap[(sword >> 8) & 0xf] << 16) |
461 (graymap[(sword >> 4) & 0xf] << 8) |
462 graymap[sword & 0xf];
463 lined[2 * count + 1] = dword;
468 gval = graymap[sval];
472 for (j = 0; j < w; j++) {
474 gval = graymap[sval];
475 CHECK_VALUE(lined, j, gval);
481 for (j = 0, count = 0; j + 15 < w; j += 16, count++) {
482 sword = lines[count];
483 dword = (graymap[(sword >> 30) & 0x3] << 24) |
484 (graymap[(sword >> 28) & 0x3] << 16) |
485 (graymap[(sword >> 26) & 0x3] << 8) |
486 graymap[(sword >> 24) & 0x3];
487 lined[4 * count] = dword;
488 dword = (graymap[(sword >> 22) & 0x3] << 24) |
489 (graymap[(sword >> 20) & 0x3] << 16) |
490 (graymap[(sword >> 18) & 0x3] << 8) |
491 graymap[(sword >> 16) & 0x3];
492 lined[4 * count + 1] = dword;
493 dword = (graymap[(sword >> 14) & 0x3] << 24) |
494 (graymap[(sword >> 12) & 0x3] << 16) |
495 (graymap[(sword >> 10) & 0x3] << 8) |
496 graymap[(sword >> 8) & 0x3];
497 lined[4 * count + 2] = dword;
498 dword = (graymap[(sword >> 6) & 0x3] << 24) |
499 (graymap[(sword >> 4) & 0x3] << 16) |
500 (graymap[(sword >> 2) & 0x3] << 8) |
501 graymap[sword & 0x3];
502 lined[4 * count + 3] = dword;
507 gval = graymap[sval];
511 for (j = 0; j < w; j++) {
513 gval = graymap[sval];
514 CHECK_VALUE(lined, j, gval);
520 for (j = 0, count = 0; j + 31 < w; j += 32, count++) {
521 sword = lines[count];
522 for (k = 0; k < 4; k++) {
524 dword = (graymap[(sword >> 31) & 0x1] << 24) |
525 (graymap[(sword >> 30) & 0x1] << 16) |
526 (graymap[(sword >> 29) & 0x1] << 8) |
527 graymap[(sword >> 28) & 0x1];
528 lined[8 * count + 2 * k] = dword;
529 dword = (graymap[(sword >> 27) & 0x1] << 24) |
530 (graymap[(sword >> 26) & 0x1] << 16) |
531 (graymap[(sword >> 25) & 0x1] << 8) |
532 graymap[(sword >> 24) & 0x1];
533 lined[8 * count + 2 * k + 1] = dword;
540 gval = graymap[sval];
544 for (j = 0; j < w; j++) {
546 gval = graymap[sval];
547 CHECK_VALUE(lined, j, gval);
559 if ((pixd =
pixCreate(w, h, 32)) == NULL) {
560 L_ERROR(
"pixd not made\n", procName);
563 pixCopyInputFormat(pixd, pixs);
564 pixCopyResolution(pixd, pixs);
568 wpld = pixGetWpl(pixd);
569 lut = (l_uint32 *)LEPT_CALLOC(nalloc,
sizeof(l_uint32));
570 for (i = 0; i < ncolors; i++) {
577 for (i = 0; i < h; i++) {
578 lines = datas + i * wpls;
579 lined = datad + i * wpld;
580 for (j = 0; j < w; j++) {
590 L_WARNING(
"pixel value out of bounds\n", procName);
592 lined[j] = lut[sval];
626 PROCNAME(
"pixAddGrayColormap8");
628 if (!pixs || pixGetDepth(pixs) != 8)
629 return ERROR_INT(
"pixs not defined or not 8 bpp", procName, 1);
630 if (pixGetColormap(pixs))
655 l_int32 ncolors, w, h, i, j, wpl1, wpld, index, val;
656 l_int32 *inta, *revmap;
657 l_uint32 *data1, *datad, *line1, *lined;
661 PROCNAME(
"pixAddMinimalGrayColormap8");
663 if (!pixs || pixGetDepth(pixs) != 8)
664 return (
PIX *)ERROR_PTR(
"pixs undefined or not 8 bpp", procName, NULL);
668 cmap = pixGetColormap(pixs);
675 if (ncolors == 256) {
686 wpl1 = pixGetWpl(pix1);
687 inta = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
688 for (i = 0; i < h; i++) {
689 line1 = data1 + i * wpl1;
690 for (j = 0; j < w; j++) {
696 revmap = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
697 for (i = 0, index = 0; i < 256; i++) {
707 pixCopyInputFormat(pixd, pixs);
708 pixCopyResolution(pixd, pixs);
710 wpld = pixGetWpl(pixd);
711 for (i = 0; i < h; i++) {
712 line1 = data1 + i * wpl1;
713 lined = datad + i * wpld;
714 for (j = 0; j < w; j++) {
774 PROCNAME(
"pixConvertRGBToGrayGeneral");
776 if (!pixs || pixGetDepth(pixs) != 32)
777 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", procName, NULL);
783 return (
PIX *)ERROR_PTR(
"invalid type", procName, NULL);
802 if (rwt < 0.0 || gwt < 0.0 || bwt < 0.0)
803 return (
PIX *)ERROR_PTR(
"weights not all >= 0.0", procName, NULL);
804 if (rwt + gwt + bwt != 1.0)
805 return (
PIX *)ERROR_PTR(
"weights don't sum to 1.0", procName, NULL);
832 l_int32 i, j, w, h, wpls, wpld, val;
834 l_uint32 *datas, *lines, *datad, *lined;
838 PROCNAME(
"pixConvertRGBToGray");
841 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
842 if (pixGetDepth(pixs) != 32)
843 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
844 if (rwt < 0.0 || gwt < 0.0 || bwt < 0.0)
845 return (
PIX *)ERROR_PTR(
"weights not all >= 0.0", procName, NULL);
849 if (rwt == 0.0 && gwt == 0.0 && bwt == 0.0) {
854 sum = rwt + gwt + bwt;
855 if (L_ABS(sum - 1.0) > 0.0001) {
856 L_WARNING(
"weights don't sum to 1; maintaining ratios\n", procName);
864 wpls = pixGetWpl(pixs);
866 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
867 pixCopyResolution(pixd, pixs);
868 pixCopyInputFormat(pixd, pixs);
870 wpld = pixGetWpl(pixd);
872 for (i = 0; i < h; i++) {
873 lines = datas + i * wpls;
874 lined = datad + i * wpld;
875 for (j = 0; j < w; j++) {
877 val = (l_int32)(rwt * ((word >> L_RED_SHIFT) & 0xff) +
878 gwt * ((word >> L_GREEN_SHIFT) & 0xff) +
879 bwt * ((word >> L_BLUE_SHIFT) & 0xff) + 0.5);
907 l_int32 i, j, w, h, wpls, wpld, val;
908 l_uint32 *datas, *lines, *datad, *lined;
911 PROCNAME(
"pixConvertRGBToGrayFast");
914 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
915 if (pixGetDepth(pixs) != 32)
916 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
920 wpls = pixGetWpl(pixs);
922 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
923 pixCopyResolution(pixd, pixs);
924 pixCopyInputFormat(pixd, pixs);
926 wpld = pixGetWpl(pixd);
928 for (i = 0; i < h; i++) {
929 lines = datas + i * wpls;
930 lined = datad + i * wpld;
931 for (j = 0; j < w; j++, lines++) {
932 val = ((*lines) >> L_GREEN_SHIFT) & 0xff;
966 l_int32 i, j, w, h, wpls, wpld, rval, gval, bval, val, minval, maxval;
967 l_uint32 *datas, *lines, *datad, *lined;
970 PROCNAME(
"pixConvertRGBToGrayMinMax");
973 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
974 if (pixGetDepth(pixs) != 32)
975 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
976 if (type != L_CHOOSE_MIN && type != L_CHOOSE_MAX &&
977 type != L_CHOOSE_MAXDIFF && type != L_CHOOSE_MIN_BOOST &&
978 type != L_CHOOSE_MAX_BOOST)
979 return (
PIX *)ERROR_PTR(
"invalid type", procName, NULL);
983 wpls = pixGetWpl(pixs);
985 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
986 pixCopyResolution(pixd, pixs);
987 pixCopyInputFormat(pixd, pixs);
989 wpld = pixGetWpl(pixd);
991 for (i = 0; i < h; i++) {
992 lines = datas + i * wpls;
993 lined = datad + i * wpld;
994 for (j = 0; j < w; j++) {
996 if (type == L_CHOOSE_MIN || type == L_CHOOSE_MIN_BOOST) {
997 val = L_MIN(rval, gval);
998 val = L_MIN(val, bval);
999 if (type == L_CHOOSE_MIN_BOOST)
1000 val = L_MIN(255, (val * val) / var_NEUTRAL_BOOST_VAL);
1001 }
else if (type == L_CHOOSE_MAX || type == L_CHOOSE_MAX_BOOST) {
1002 val = L_MAX(rval, gval);
1003 val = L_MAX(val, bval);
1004 if (type == L_CHOOSE_MAX_BOOST)
1005 val = L_MIN(255, (val * val) / var_NEUTRAL_BOOST_VAL);
1007 minval = L_MIN(rval, gval);
1008 minval = L_MIN(minval, bval);
1009 maxval = L_MAX(rval, gval);
1010 maxval = L_MAX(maxval, bval);
1011 val = maxval - minval;
1053 l_int32 w, h, d, i, j, wplt, wpld;
1054 l_int32 rval, gval, bval, sval, minrg, maxrg, min, max, delta;
1055 l_int32 fullsat, newval;
1056 l_float32 *invmax, *ratio;
1057 l_uint32 *linet, *lined, *datat, *datad;
1060 PROCNAME(
"pixConvertRGBToGraySatBoost");
1063 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1065 if (d != 32 && !pixGetColormap(pixs))
1066 return (
PIX *)ERROR_PTR(
"pixs not cmapped or rgb", procName, NULL);
1067 if (refval < 1 || refval > 255)
1068 return (
PIX *)ERROR_PTR(
"refval not in [1 ... 255]", procName, NULL);
1072 pixCopyResolution(pixd, pixs);
1073 pixCopyInputFormat(pixd, pixs);
1074 wplt = pixGetWpl(pixt);
1076 wpld = pixGetWpl(pixd);
1078 invmax = (l_float32 *)LEPT_CALLOC(256,
sizeof(l_float32));
1079 ratio = (l_float32 *)LEPT_CALLOC(256,
sizeof(l_float32));
1080 for (i = 1; i < 256; i++) {
1081 invmax[i] = 1.0 / (l_float32)i;
1082 ratio[i] = (l_float32)i / (l_float32)refval;
1084 for (i = 0; i < h; i++) {
1085 linet = datat + i * wplt;
1086 lined = datad + i * wpld;
1087 for (j = 0; j < w; j++) {
1089 minrg = L_MIN(rval, gval);
1090 min = L_MIN(minrg, bval);
1091 maxrg = L_MAX(rval, gval);
1092 max = L_MAX(maxrg, bval);
1097 sval = (l_int32)(255. * (l_float32)delta * invmax[max] + 0.5);
1099 fullsat = L_MIN(255, 255 * ratio[max]);
1100 newval = (sval * fullsat + (255 - sval) * max) / 255;
1133 l_int32 i, j, w, h, wpls, wpld, rval, gval, bval, val;
1134 l_uint32 *datas, *lines, *datad, *lined;
1137 PROCNAME(
"pixConvertRGBToGrayArb");
1140 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1141 if (pixGetDepth(pixs) != 32)
1142 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
1143 if (rc <= 0 && gc <= 0 && bc <= 0)
1144 return (
PIX *)ERROR_PTR(
"all coefficients <= 0", procName, NULL);
1148 wpls = pixGetWpl(pixs);
1149 if ((pixd =
pixCreate(w, h, 8)) == NULL)
1150 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1151 pixCopyResolution(pixd, pixs);
1152 pixCopyInputFormat(pixd, pixs);
1154 wpld = pixGetWpl(pixd);
1156 for (i = 0; i < h; i++) {
1157 lines = datas + i * wpls;
1158 lined = datad + i * wpld;
1159 for (j = 0; j < w; j++) {
1161 val = (l_int32)(rc * rval + gc * gval + bc * bval);
1162 val = L_MIN(255, L_MAX(0, val));
1200 PROCNAME(
"pixConvertRGBToBinaryArb");
1202 if (!pixs || pixGetDepth(pixs) != 32)
1203 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", procName, NULL);
1204 if (rc <= 0 && gc <= 0 && bc <= 0)
1205 return (
PIX *)ERROR_PTR(
"all coefficients <= 0", procName, NULL);
1208 return (
PIX *)ERROR_PTR(
"invalid relation", procName, NULL);
1212 thresh : thresh + 1;
1253 PROCNAME(
"pixConvertGrayToColormap");
1256 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1257 d = pixGetDepth(pixs);
1258 if (d != 2 && d != 4 && d != 8)
1259 return (
PIX *)ERROR_PTR(
"pixs not 2, 4 or 8 bpp", procName, NULL);
1261 if (pixGetColormap(pixs)) {
1262 L_INFO(
"pixs already has a colormap\n", procName);
1274 pixCopyInputFormat(pixd, pixs);
1305 l_int32 ncolors, w, h, depth, i, j, wpls, wpld;
1306 l_int32 index, num, val, newval;
1308 l_uint32 *lines, *lined, *datas, *datad;
1313 PROCNAME(
"pixConvertGrayToColormap8");
1316 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1317 if (pixGetDepth(pixs) != 8)
1318 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp", procName, NULL);
1319 if (mindepth != 2 && mindepth != 4 && mindepth != 8) {
1320 L_WARNING(
"invalid value of mindepth; setting to 8\n", procName);
1324 if (pixGetColormap(pixs)) {
1325 L_INFO(
"pixs already has a colormap\n", procName);
1331 if (mindepth == 8 || ncolors > 16)
1333 else if (mindepth == 4 || ncolors > 4)
1342 pixCopyInputFormat(pixd, pixs);
1343 pixCopyResolution(pixd, pixs);
1346 for (i = 0; i < 256; i++) {
1357 wpls = pixGetWpl(pixs);
1359 wpld = pixGetWpl(pixd);
1360 for (i = 0; i < h; i++) {
1361 lines = datas + i * wpls;
1362 lined = datad + i * wpld;
1363 for (j = 0; j < w; j++) {
1365 newval = array[val];
1368 else if (depth == 4)
1403 l_int32 i, j, w, h, wplt, wpld, val8;
1404 l_uint32 *datad, *datat, *lined, *linet, *tab;
1408 PROCNAME(
"pixColorizeGray");
1411 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1412 if (pixGetDepth(pixs) != 8 && !pixGetColormap(pixs))
1413 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp or cmapped", procName, NULL);
1415 if (pixGetColormap(pixs))
1432 pixCopyResolution(pixd, pixs);
1433 pixCopyInputFormat(pixd, pixs);
1435 wpld = pixGetWpl(pixd);
1437 wplt = pixGetWpl(pixt);
1438 for (i = 0; i < h; i++) {
1439 lined = datad + i * wpld;
1440 linet = datat + i * wplt;
1441 for (j = 0; j < w; j++) {
1443 lined[j] = tab[val8];
1493 PROCNAME(
"pixConvertRGBToColormap");
1496 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1497 if (pixGetDepth(pixs) != 32)
1498 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
1499 if (pixGetSpp(pixs) == 4)
1500 L_WARNING(
"pixs has alpha; removing\n", procName);
1510 if (ncolors <= 256) {
1512 pixCopyInputFormat(pixd, pixs);
1522 L_INFO(
"More than 256 colors; using octree quant with dithering\n",
1525 L_INFO(
"More than 256 colors; using octree quant; no dithering\n",
1552 l_int32 i, j, nc, w, h, imin, imax, factor, wpl1, wpld;
1553 l_int32 index, rmin, gmin, bmin, rmax, gmax, bmax, dmin, dmax;
1554 l_float32 minfract, ifract;
1556 l_uint32 *line1, *lined, *data1, *datad;
1561 PROCNAME(
"pixConvertCmapTo1");
1564 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1565 if ((cmap = pixGetColormap(pixs)) == NULL)
1566 return (
PIX *)ERROR_PTR(
"no colormap", procName, NULL);
1579 if ((lut = (l_int32 *)LEPT_CALLOC(nc,
sizeof(l_int32))) == NULL)
1580 return (
PIX *)ERROR_PTR(
"calloc fail for lut", procName, NULL);
1582 factor = L_MAX(1, (l_int32)sqrt((l_float64)(w * h) / 50000. + 0.5));
1586 for (i = 0; i < nc; i++) {
1603 wpl1 = pixGetWpl(pix1);
1604 wpld = pixGetWpl(pixd);
1605 for (i = 0; i < h; i++) {
1606 line1 = data1 + i * wpl1;
1607 lined = datad + i * wpld;
1608 for (j = 0; j < w; j++) {
1618 if (minfract > 0.5) {
1619 L_INFO(
"minfract = %5.3f; inverting\n", procName, minfract);
1663 l_int32 mingraycolors,
1667 l_int32 d, ncolors, iscolor, graycolors;
1670 PROCNAME(
"pixQuantizeIfFewColors");
1673 return ERROR_INT(
"&pixd not defined", procName, 1);
1676 return ERROR_INT(
"pixs not defined", procName, 1);
1677 d = pixGetDepth(pixs);
1678 if (d != 8 && d != 32)
1679 return ERROR_INT(
"pixs not defined", procName, 1);
1680 if (pixGetColormap(pixs) != NULL) {
1687 L_WARNING(
"maxcolors > 50; very large!\n", procName);
1688 if (mingraycolors <= 0)
1690 if (mingraycolors > 30)
1691 L_WARNING(
"mingraycolors > 30; very large!\n", procName);
1692 if (octlevel != 3 && octlevel != 4) {
1693 L_WARNING(
"invalid octlevel; setting to 3\n", procName);
1700 if (ncolors > maxcolors)
1701 return ERROR_INT(
"too many colors", procName, 1);
1718 L_WARNING(
"quantized at level 2; low quality\n", procName);
1725 graycolors = L_MAX(mingraycolors, (l_int32)(1.5 * ncolors));
1726 graycolors = L_MIN(graycolors, 256);
1727 if (graycolors < 16)
1736 return ERROR_INT(
"pixd not made", procName, 1);
1737 pixCopyInputFormat(pixd, pixs);
1766 l_int32 w, h, wpls, wpld, i, j, val, use_lsb;
1767 l_uint32 sword, first, second;
1768 l_uint32 *datas, *datad, *lines, *lined;
1771 PROCNAME(
"pixConvert16To8");
1774 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1775 if (pixGetDepth(pixs) != 16)
1776 return (
PIX *)ERROR_PTR(
"pixs not 16 bpp", procName, NULL);
1779 return (
PIX *)ERROR_PTR(
"invalid type", procName, NULL);
1782 if ((pixd =
pixCreate(w, h, 8)) == NULL)
1783 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1784 pixCopyInputFormat(pixd, pixs);
1785 pixCopyResolution(pixd, pixs);
1786 wpls = pixGetWpl(pixs);
1788 wpld = pixGetWpl(pixd);
1793 for (i = 0; i < h; i++) {
1794 lines = datas + i * wpls;
1795 for (j = 0; j < wpls; j++) {
1802 if (!use_lsb)
break;
1808 for (i = 0; i < h; i++) {
1809 lines = datas + i * wpls;
1810 lined = datad + i * wpld;
1812 for (j = 0; j < wpls; j++) {
1813 sword = *(lines + j);
1814 dword = ((sword >> 8) & 0xff00) | (sword & 0xff);
1818 for (j = 0; j < wpls; j++) {
1819 sword = *(lines + j);
1820 dword = ((sword >> 16) & 0xff00) | ((sword >> 8) & 0xff);
1824 for (j = 0; j < wpls; j++) {
1825 sword = *(lines + j);
1826 first = (sword >> 24) ? 255 : ((sword >> 16) & 0xff);
1827 second = ((sword >> 8) & 0xff) ? 255 : (sword & 0xff);
1828 dword = (first << 8) | second;
1865 PROCNAME(
"pixConvertGrayToFalseColor");
1868 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1869 d = pixGetDepth(pixs);
1870 if (d != 8 && d != 16)
1871 return (
PIX *)ERROR_PTR(
"pixs not 8 or 16 bpp", procName, NULL);
1876 if (pixGetColormap(pixs))
1882 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1886 pixCopyResolution(pixd, pixs);
1887 pixCopyInputFormat(pixd, pixs);
1919 PROCNAME(
"pixUnpackBinary");
1922 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1923 if (pixGetDepth(pixs) != 1)
1924 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, NULL);
1925 if (depth != 2 && depth != 4 && depth != 8 && depth != 16 && depth != 32)
1926 return (
PIX *)ERROR_PTR(
"depth not 2, 4, 8, 16 or 32 bpp",
1934 }
else if (depth == 4) {
1939 }
else if (depth == 8) {
1944 }
else if (depth == 16) {
1956 pixCopyInputFormat(pixd, pixs);
1983 l_int32 w, h, i, j, dibit, ndibits, wpls, wpld;
1986 l_uint32 *tab, *datas, *datad, *lines, *lined;
1988 PROCNAME(
"pixConvert1To16");
1991 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1992 if (pixGetDepth(pixs) != 1)
1993 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, NULL);
1997 if (w != pixGetWidth(pixd) || h != pixGetHeight(pixd))
1998 return (
PIX *)ERROR_PTR(
"pix sizes unequal", procName, pixd);
1999 if (pixGetDepth(pixd) != 16)
2000 return (
PIX *)ERROR_PTR(
"pixd not 16 bpp", procName, pixd);
2002 if ((pixd =
pixCreate(w, h, 16)) == NULL)
2003 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2005 pixCopyResolution(pixd, pixs);
2006 pixCopyInputFormat(pixd, pixs);
2009 tab = (l_uint32 *)LEPT_CALLOC(4,
sizeof(l_uint32));
2012 for (index = 0; index < 4; index++) {
2013 tab[index] = (val[(index >> 1) & 1] << 16) | val[index & 1];
2017 wpls = pixGetWpl(pixs);
2019 wpld = pixGetWpl(pixd);
2020 ndibits = (w + 1) / 2;
2021 for (i = 0; i < h; i++) {
2022 lines = datas + i * wpls;
2023 lined = datad + i * wpld;
2024 for (j = 0; j < ndibits; j++) {
2026 lined[j] = tab[dibit];
2057 l_int32 w, h, i, j, wpls, wpld, bit;
2059 l_uint32 *datas, *datad, *lines, *lined;
2061 PROCNAME(
"pixConvert1To32");
2064 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2065 if (pixGetDepth(pixs) != 1)
2066 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, NULL);
2070 if (w != pixGetWidth(pixd) || h != pixGetHeight(pixd))
2071 return (
PIX *)ERROR_PTR(
"pix sizes unequal", procName, pixd);
2072 if (pixGetDepth(pixd) != 32)
2073 return (
PIX *)ERROR_PTR(
"pixd not 32 bpp", procName, pixd);
2075 if ((pixd =
pixCreate(w, h, 32)) == NULL)
2076 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2078 pixCopyResolution(pixd, pixs);
2079 pixCopyInputFormat(pixd, pixs);
2084 wpls = pixGetWpl(pixs);
2086 wpld = pixGetWpl(pixd);
2087 for (i = 0; i < h; i++) {
2088 lines = datas + i * wpls;
2089 lined = datad + i * wpld;
2090 for (j = 0; j <w; j++) {
2092 lined[j] = val[bit];
2120 PROCNAME(
"pixConvert1To2Cmap");
2123 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2124 if (pixGetDepth(pixs) != 1)
2125 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, NULL);
2128 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2133 pixCopyInputFormat(pixd, pixs);
2163 l_int32 w, h, i, j, byteval, nbytes, wpls, wpld;
2167 l_uint32 *datas, *datad, *lines, *lined;
2169 PROCNAME(
"pixConvert1To2");
2172 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, pixd);
2173 if (pixGetDepth(pixs) != 1)
2174 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, pixd);
2178 if (w != pixGetWidth(pixd) || h != pixGetHeight(pixd))
2179 return (
PIX *)ERROR_PTR(
"pix sizes unequal", procName, pixd);
2180 if (pixGetDepth(pixd) != 2)
2181 return (
PIX *)ERROR_PTR(
"pixd not 2 bpp", procName, pixd);
2183 if ((pixd =
pixCreate(w, h, 2)) == NULL)
2184 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2186 pixCopyResolution(pixd, pixs);
2187 pixCopyInputFormat(pixd, pixs);
2190 tab = (l_uint16 *)LEPT_CALLOC(256,
sizeof(l_uint16));
2193 for (index = 0; index < 256; index++) {
2194 tab[index] = (val[(index >> 7) & 1] << 14) |
2195 (val[(index >> 6) & 1] << 12) |
2196 (val[(index >> 5) & 1] << 10) |
2197 (val[(index >> 4) & 1] << 8) |
2198 (val[(index >> 3) & 1] << 6) |
2199 (val[(index >> 2) & 1] << 4) |
2200 (val[(index >> 1) & 1] << 2) | val[index & 1];
2204 wpls = pixGetWpl(pixs);
2206 wpld = pixGetWpl(pixd);
2207 nbytes = (w + 7) / 8;
2208 for (i = 0; i < h; i++) {
2209 lines = datas + i * wpls;
2210 lined = datad + i * wpld;
2211 for (j = 0; j < nbytes; j++) {
2242 PROCNAME(
"pixConvert1To4Cmap");
2245 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2246 if (pixGetDepth(pixs) != 1)
2247 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, NULL);
2250 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2255 pixCopyInputFormat(pixd, pixs);
2285 l_int32 w, h, i, j, byteval, nbytes, wpls, wpld;
2288 l_uint32 *tab, *datas, *datad, *lines, *lined;
2290 PROCNAME(
"pixConvert1To4");
2293 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, pixd);
2294 if (pixGetDepth(pixs) != 1)
2295 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, pixd);
2299 if (w != pixGetWidth(pixd) || h != pixGetHeight(pixd))
2300 return (
PIX *)ERROR_PTR(
"pix sizes unequal", procName, pixd);
2301 if (pixGetDepth(pixd) != 4)
2302 return (
PIX *)ERROR_PTR(
"pixd not 4 bpp", procName, pixd);
2304 if ((pixd =
pixCreate(w, h, 4)) == NULL)
2305 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2307 pixCopyResolution(pixd, pixs);
2308 pixCopyInputFormat(pixd, pixs);
2311 tab = (l_uint32 *)LEPT_CALLOC(256,
sizeof(l_uint32));
2314 for (index = 0; index < 256; index++) {
2315 tab[index] = (val[(index >> 7) & 1] << 28) |
2316 (val[(index >> 6) & 1] << 24) |
2317 (val[(index >> 5) & 1] << 20) |
2318 (val[(index >> 4) & 1] << 16) |
2319 (val[(index >> 3) & 1] << 12) |
2320 (val[(index >> 2) & 1] << 8) |
2321 (val[(index >> 1) & 1] << 4) | val[index & 1];
2325 wpls = pixGetWpl(pixs);
2327 wpld = pixGetWpl(pixd);
2328 nbytes = (w + 7) / 8;
2329 for (i = 0; i < h; i++) {
2330 lines = datas + i * wpls;
2331 lined = datad + i * wpld;
2332 for (j = 0; j < nbytes; j++) {
2334 lined[j] = tab[byteval];
2363 PROCNAME(
"pixConvert1To8Cmap");
2366 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2367 if (pixGetDepth(pixs) != 1)
2368 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, NULL);
2371 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2376 pixCopyInputFormat(pixd, pixs);
2406 l_int32 w, h, i, j, qbit, nqbits, wpls, wpld;
2409 l_uint32 *tab, *datas, *datad, *lines, *lined;
2411 PROCNAME(
"pixConvert1To8");
2414 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, pixd);
2415 if (pixGetDepth(pixs) != 1)
2416 return (
PIX *)ERROR_PTR(
"pixs not 1 bpp", procName, pixd);
2420 if (w != pixGetWidth(pixd) || h != pixGetHeight(pixd))
2421 return (
PIX *)ERROR_PTR(
"pix sizes unequal", procName, pixd);
2422 if (pixGetDepth(pixd) != 8)
2423 return (
PIX *)ERROR_PTR(
"pixd not 8 bpp", procName, pixd);
2425 if ((pixd =
pixCreate(w, h, 8)) == NULL)
2426 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2428 pixCopyResolution(pixd, pixs);
2429 pixCopyInputFormat(pixd, pixs);
2433 tab = (l_uint32 *)LEPT_CALLOC(16,
sizeof(l_uint32));
2436 for (index = 0; index < 16; index++) {
2437 tab[index] = ((l_uint32)val[(index >> 3) & 1] << 24) |
2438 (val[(index >> 2) & 1] << 16) |
2439 (val[(index >> 1) & 1] << 8) | val[index & 1];
2443 wpls = pixGetWpl(pixs);
2445 wpld = pixGetWpl(pixd);
2446 nqbits = (w + 3) / 4;
2447 for (i = 0; i < h; i++) {
2448 lines = datas + i * wpls;
2449 lined = datad + i * wpld;
2450 for (j = 0; j < nqbits; j++) {
2452 lined[j] = tab[qbit];
2499 l_int32 w, h, i, j, nbytes, wpls, wpld, dibit, byte;
2502 l_uint32 *tab, *datas, *datad, *lines, *lined;
2506 PROCNAME(
"pixConvert2To8");
2509 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2510 if (pixGetDepth(pixs) != 2)
2511 return (
PIX *)ERROR_PTR(
"pixs not 2 bpp", procName, NULL);
2513 cmaps = pixGetColormap(pixs);
2514 if (cmaps && cmapflag == FALSE)
2518 if ((pixd =
pixCreate(w, h, 8)) == NULL)
2519 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2521 pixCopyResolution(pixd, pixs);
2522 pixCopyInputFormat(pixd, pixs);
2524 wpls = pixGetWpl(pixs);
2526 wpld = pixGetWpl(pixd);
2528 if (cmapflag == TRUE) {
2539 for (i = 0; i < h; i++) {
2540 lines = datas + i * wpls;
2541 lined = datad + i * wpld;
2542 for (j = 0; j < w; j++) {
2553 tab = (l_uint32 *)LEPT_CALLOC(256,
sizeof(l_uint32));
2558 for (index = 0; index < 256; index++) {
2559 tab[index] = (val[(index >> 6) & 3] << 24) |
2560 (val[(index >> 4) & 3] << 16) |
2561 (val[(index >> 2) & 3] << 8) | val[index & 3];
2564 nbytes = (w + 3) / 4;
2565 for (i = 0; i < h; i++) {
2566 lines = datas + i * wpls;
2567 lined = datad + i * wpld;
2568 for (j = 0; j < nbytes; j++) {
2570 lined[j] = tab[byte];
2607 l_int32 w, h, i, j, wpls, wpld, byte, qbit;
2608 l_uint32 *datas, *datad, *lines, *lined;
2612 PROCNAME(
"pixConvert4To8");
2615 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2616 if (pixGetDepth(pixs) != 4)
2617 return (
PIX *)ERROR_PTR(
"pixs not 4 bpp", procName, NULL);
2619 cmaps = pixGetColormap(pixs);
2620 if (cmaps && cmapflag == FALSE)
2624 if ((pixd =
pixCreate(w, h, 8)) == NULL)
2625 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2626 pixCopyResolution(pixd, pixs);
2627 pixCopyInputFormat(pixd, pixs);
2629 wpls = pixGetWpl(pixs);
2631 wpld = pixGetWpl(pixd);
2633 if (cmapflag == TRUE) {
2638 for (i = 0; i < 16; i++)
2642 for (i = 0; i < h; i++) {
2643 lines = datas + i * wpls;
2644 lined = datad + i * wpld;
2645 for (j = 0; j < w; j++) {
2655 for (i = 0; i < h; i++) {
2656 lines = datas + i * wpls;
2657 lined = datad + i * wpld;
2658 for (j = 0; j < w; j++) {
2660 byte = (qbit << 4) | qbit;
2692 l_int32 i, j, w, h, d, wplt, wpld, val;
2693 l_uint32 *datat, *datad, *linet, *lined;
2696 PROCNAME(
"pixConvert8To16");
2699 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2702 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp", procName, NULL);
2703 if (leftshift < 0 || leftshift > 8)
2704 return (
PIX *)ERROR_PTR(
"leftshift not in [0 ... 8]", procName, NULL);
2706 if (pixGetColormap(pixs) != NULL)
2712 pixCopyResolution(pixd, pixs);
2713 pixCopyInputFormat(pixd, pixs);
2716 wplt = pixGetWpl(pixt);
2717 wpld = pixGetWpl(pixd);
2718 for (i = 0; i < h; i++) {
2719 linet = datat + i * wplt;
2720 lined = datad + i * wpld;
2721 for (j = 0; j < w; j++) {
2724 val = val | (val << leftshift);
2758 PIX *pix1, *pix2, *pix3, *pixd;
2760 PROCNAME(
"pixConvertTo2");
2763 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2764 d = pixGetDepth(pixs);
2765 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 24 && d != 32)
2766 return (
PIX *)ERROR_PTR(
"depth not {1,2,4,8,24,32}", procName, NULL);
2768 if (pixGetColormap(pixs) != NULL) {
2770 d = pixGetDepth(pix1);
2774 if (d == 24 || d == 32)
2781 }
else if (d == 2) {
2783 }
else if (d == 4) {
2809 l_int32 i, j, w, h, wpls, wpld;
2811 l_uint32 *datas, *lines, *datad, *lined;
2814 PROCNAME(
"pixConvert8To2");
2816 if (!pix || pixGetDepth(pix) != 8)
2817 return (
PIX *)ERROR_PTR(
"pix undefined or not 8 bpp", procName, NULL);
2819 if (pixGetColormap(pix) != NULL)
2825 wpls = pixGetWpl(pixs);
2828 wpld = pixGetWpl(pixd);
2829 for (i = 0; i < h; i++) {
2830 lines = datas + i * wpls;
2831 lined = datad + i * wpld;
2832 for (j = 0; j < wpls; j++) {
2833 word = lines[j] & 0xc0c0c0c0;
2834 word = (word >> 24) | ((word & 0xff0000) >> 18) |
2835 ((word & 0xff00) >> 12) | ((word & 0xff) >> 6);
2866 PIX *pix1, *pix2, *pix3, *pixd;
2868 PROCNAME(
"pixConvertTo4");
2871 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2872 d = pixGetDepth(pixs);
2873 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 24 && d != 32)
2874 return (
PIX *)ERROR_PTR(
"depth not {1,2,4,8,24,32}", procName, NULL);
2876 if (pixGetColormap(pixs) != NULL) {
2878 d = pixGetDepth(pix1);
2882 if (d == 24 || d == 32)
2889 }
else if (d == 2) {
2893 }
else if (d == 4) {
2917 l_int32 i, j, w, h, wpls, wpld, val;
2918 l_uint32 *datas, *lines, *datad, *lined;
2921 PROCNAME(
"pixConvert8To4");
2923 if (!pix || pixGetDepth(pix) != 8)
2924 return (
PIX *)ERROR_PTR(
"pix undefined or not 8 bpp", procName, NULL);
2926 if (pixGetColormap(pix) != NULL)
2932 wpls = pixGetWpl(pixs);
2935 wpld = pixGetWpl(pixd);
2936 for (i = 0; i < h; i++) {
2937 lines = datas + i * wpls;
2938 lined = datad + i * wpld;
2939 for (j = 0; j < w; j++) {
2969 l_int32 d, color0, color1, rval, gval, bval;
2970 PIX *pix1, *pix2, *pixd;
2973 PROCNAME(
"pixConvertTo1Adaptive");
2976 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2977 d = pixGetDepth(pixs);
2978 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 16 && d != 24 && d != 32)
2979 return (
PIX *)ERROR_PTR(
"depth not {1,2,4,8,16,24,32}", procName, NULL);
2981 cmap = pixGetColormap(pixs);
2988 color0 = rval + gval + bval;
2990 color1 = rval + gval + bval;
2993 if (color1 > color0)
3029 l_int32 d, color0, color1, rval, gval, bval;
3033 PROCNAME(
"pixConvertTo1");
3036 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3037 d = pixGetDepth(pixs);
3038 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 16 && d != 24 && d != 32)
3039 return (
PIX *)ERROR_PTR(
"depth not {1,2,4,8,16,24,32}", procName, NULL);
3041 cmap = pixGetColormap(pixs);
3048 color0 = rval + gval + bval;
3050 color1 = rval + gval + bval;
3053 if (color1 > color0)
3086 l_float32 scalefactor;
3089 PROCNAME(
"pixConvertTo1BySampling");
3092 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3094 return (
PIX *)ERROR_PTR(
"factor must be >= 1", procName, NULL);
3096 scalefactor = 1. / (l_float32)factor;
3140 PROCNAME(
"pixConvertTo8");
3143 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3144 d = pixGetDepth(pixs);
3145 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 16 && d != 24 && d != 32)
3146 return (
PIX *)ERROR_PTR(
"depth not {1,2,4,8,16,24,32}", procName, NULL);
3153 }
else if (d == 2) {
3155 }
else if (d == 4) {
3157 }
else if (d == 8) {
3158 cmap = pixGetColormap(pixs);
3159 if ((cmap && cmapflag) || (!cmap && !cmapflag)) {
3168 }
else if (d == 16) {
3173 }
else if (d == 24) {
3208 l_float32 scalefactor;
3211 PROCNAME(
"pixConvertTo8BySampling");
3214 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3216 return (
PIX *)ERROR_PTR(
"factor must be >= 1", procName, NULL);
3218 scalefactor = 1. / (l_float32)factor;
3253 PROCNAME(
"pixConvertTo8Colormap");
3256 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3257 d = pixGetDepth(pixs);
3258 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 16 && d != 32)
3259 return (
PIX *)ERROR_PTR(
"depth not {1,2,4,8,16,32}", procName, NULL);
3287 PROCNAME(
"pixConvertTo16");
3290 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3292 d = pixGetDepth(pixs);
3298 return (
PIX *)ERROR_PTR(
"src depth not 1 or 8 bpp", procName, NULL);
3337 PROCNAME(
"pixConvertTo32");
3340 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3342 d = pixGetDepth(pixs);
3345 }
else if (d == 2) {
3350 }
else if (d == 4) {
3355 }
else if (d == 8) {
3357 }
else if (d == 16) {
3362 }
else if (d == 24) {
3364 }
else if (d == 32) {
3367 return (
PIX *)ERROR_PTR(
"depth not 1, 2, 4, 8, 16, 32 bpp",
3390 l_float32 scalefactor;
3393 PROCNAME(
"pixConvertTo32BySampling");
3396 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3398 return (
PIX *)ERROR_PTR(
"factor must be >= 1", procName, NULL);
3400 scalefactor = 1. / (l_float32)factor;
3424 l_int32 i, j, w, h, wpls, wpld, val;
3425 l_uint32 *datas, *datad, *lines, *lined;
3429 PROCNAME(
"pixConvert8To32");
3432 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3433 if (pixGetDepth(pixs) != 8)
3434 return (
PIX *)ERROR_PTR(
"pixs not 8 bpp", procName, NULL);
3436 if (pixGetColormap(pixs))
3441 wpls = pixGetWpl(pixs);
3442 if ((pixd =
pixCreate(w, h, 32)) == NULL)
3443 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
3444 pixCopyResolution(pixd, pixs);
3445 pixCopyInputFormat(pixd, pixs);
3447 wpld = pixGetWpl(pixd);
3450 tab = (l_uint32 *)LEPT_CALLOC(256,
sizeof(l_uint32));
3451 for (i = 0; i < 256; i++)
3452 tab[i] = ((l_uint32)i << 24) | (i << 16) | (i << 8);
3455 for (i = 0; i < h; i++) {
3456 lines = datas + i * wpls;
3457 lined = datad + i * wpld;
3458 for (j = 0; j < w; j++) {
3460 lined[j] = tab[val];
3499 PROCNAME(
"pixConvertTo8Or32");
3502 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3504 return (
PIX *)ERROR_PTR(
"invalid copyflag", procName, NULL);
3506 d = pixGetDepth(pixs);
3507 if (pixGetColormap(pixs)) {
3508 if (warnflag) L_WARNING(
"pix has colormap; removing\n", procName);
3510 }
else if (d == 8 || d == 32) {
3520 d = pixGetDepth(pixd);
3521 if (d != 8 && d != 32) {
3523 return (
PIX *)ERROR_PTR(
"depth not 8 or 32 bpp", procName, NULL);
3558 l_int32 w, h, d, i, j, wpls, wpld, rval, gval, bval;
3560 l_uint32 *datas, *datad, *lined;
3563 PROCNAME(
"pixConvert24to32");
3566 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3569 return (
PIX *)ERROR_PTR(
"pixs not 24 bpp", procName, NULL);
3574 wpls = pixGetWpl(pixs);
3575 wpld = pixGetWpl(pixd);
3576 for (i = 0; i < h; i++) {
3577 lines = (l_uint8 *)(datas + i * wpls);
3578 lined = datad + i * wpld;
3579 for (j = 0; j < w; j++) {
3587 pixCopyResolution(pixd, pixs);
3588 pixCopyInputFormat(pixd, pixs);
3608 l_int32 w, h, d, i, j, wpls, wpld, rval, gval, bval;
3609 l_uint32 *datas, *lines, *rgbdata;
3612 PROCNAME(
"pixConvert32to24");
3615 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3618 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
3621 wpls = pixGetWpl(pixs);
3624 wpld = pixGetWpl(pixd);
3625 for (i = 0; i < h; i++) {
3626 lines = datas + i * wpls;
3627 rgbdata8 = (l_uint8 *)(rgbdata + i * wpld);
3628 for (j = 0; j < w; j++) {
3635 pixCopyResolution(pixd, pixs);
3636 pixCopyInputFormat(pixd, pixs);
3662 l_int32 w, h, i, j, wpls, wpld;
3664 l_uint32 *datas, *lines, *datad, *lined;
3667 PROCNAME(
"pixConvert32to16");
3669 if (!pixs || pixGetDepth(pixs) != 32)
3670 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", procName, NULL);
3673 return (
PIX *)ERROR_PTR(
"invalid type", procName, NULL);
3676 if ((pixd =
pixCreate(w, h, 16)) == NULL)
3677 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
3678 pixCopyResolution(pixd, pixs);
3679 pixCopyInputFormat(pixd, pixs);
3680 wpls = pixGetWpl(pixs);
3682 wpld = pixGetWpl(pixd);
3685 for (i = 0; i < h; i++) {
3686 lines = datas + i * wpls;
3687 lined = datad + i * wpld;
3689 for (j = 0; j < wpls; j++) {
3690 sword = *(lines + j);
3691 dword = sword & 0xffff;
3695 for (j = 0; j < wpls; j++) {
3696 sword = *(lines + j);
3697 dword = sword >> 16;
3701 for (j = 0; j < wpls; j++) {
3702 sword = *(lines + j);
3703 dword = (sword >> 16) ? 0xffff : (sword & 0xffff);
3728 PROCNAME(
"pixConvert32to8");
3730 if (!pixs || pixGetDepth(pixs) != 32)
3731 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", procName, NULL);
3734 return (
PIX *)ERROR_PTR(
"invalid type16", procName, NULL);
3736 return (
PIX *)ERROR_PTR(
"invalid type8", procName, NULL);
3763 PROCNAME(
"pixRemoveAlpha");
3766 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3768 if (pixGetDepth(pixs) == 32 && pixGetSpp(pixs) == 4)
3803 PROCNAME(
"pixAddAlphaTo1bpp");
3805 if (!pixs || (pixGetDepth(pixs) != 1))
3806 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", procName, NULL);
3807 if (pixd && (pixd != pixs))
3808 return (
PIX *)ERROR_PTR(
"pixd defined but != pixs", procName, NULL);
3843 l_int32 w, h, ds, wpls, wpld, i, j, val;
3844 l_uint32 *datas, *datad, *lines, *lined;
3847 PROCNAME(
"pixConvertLossless");
3850 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3851 if (pixGetColormap(pixs))
3852 return (
PIX *)ERROR_PTR(
"pixs has colormap", procName, NULL);
3853 if (d != 2 && d != 4 && d != 8)
3854 return (
PIX *)ERROR_PTR(
"invalid dest depth", procName, NULL);
3858 return (
PIX *)ERROR_PTR(
"depth > d", procName, NULL);
3862 if ((pixd =
pixCreate(w, h, d)) == NULL)
3863 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
3864 pixCopyResolution(pixd, pixs);
3865 pixCopyInputFormat(pixd, pixs);
3869 wpls = pixGetWpl(pixs);
3871 wpld = pixGetWpl(pixd);
3872 for (i = 0; i < h; i++) {
3873 lines = datas + i * wpls;
3874 lined = datad + i * wpld;
3878 for (j = 0; j < w; j++) {
3889 for (j = 0; j < w; j++) {
3898 for (j = 0; j < w; j++) {
3937 PROCNAME(
"pixConvertForPSWrap");
3940 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
3942 cmap = pixGetColormap(pixs);
3943 d = pixGetDepth(pixs);
4019 PROCNAME(
"pixConvertToSubpixelRGB");
4022 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
4023 d = pixGetDepth(pixs);
4024 cmap = pixGetColormap(pixs);
4025 if (d != 8 && d != 32 && !cmap)
4026 return (
PIX *)ERROR_PTR(
"pix not 8 or 32 bpp and not cmapped",
4028 if (scalex <= 0.0 || scaley <= 0.0)
4029 return (
PIX *)ERROR_PTR(
"scale factors must be > 0", procName, NULL);
4032 return (
PIX *)ERROR_PTR(
"invalid subpixel order", procName, NULL);
4034 return (
PIX *)ERROR_PTR(
"pix1 not made", procName, NULL);
4036 d = pixGetDepth(pix1);
4043 L_ERROR(
"invalid depth %d\n", procName, d);
4085 l_int32 w, h, d, wd, hd, wplt, wpld, i, j, rval, gval, bval, direction;
4086 l_uint32 *datat, *datad, *linet, *lined;
4087 PIX *pix1, *pix2, *pixd;
4090 PROCNAME(
"pixConvertGrayToSubpixelRGB");
4093 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
4094 d = pixGetDepth(pixs);
4095 cmap = pixGetColormap(pixs);
4096 if (d != 8 && !cmap)
4097 return (
PIX *)ERROR_PTR(
"pix not 8 bpp & not cmapped", procName, NULL);
4098 if (scalex <= 0.0 || scaley <= 0.0)
4099 return (
PIX *)ERROR_PTR(
"scale factors must be > 0", procName, NULL);
4102 return (
PIX *)ERROR_PTR(
"invalid subpixel order", procName, NULL);
4108 if (direction == L_HORIZ)
4109 pix2 =
pixScale(pix1, 3.0 * scalex, scaley);
4111 pix2 =
pixScale(pix1, scalex, 3.0 * scaley);
4114 wd = (direction == L_HORIZ) ? w / 3 : w;
4115 hd = (direction == L_VERT) ? h / 3 : h;
4118 wpld = pixGetWpl(pixd);
4120 wplt = pixGetWpl(pix2);
4121 if (direction == L_HORIZ) {
4122 for (i = 0; i < hd; i++) {
4123 linet = datat + i * wplt;
4124 lined = datad + i * wpld;
4125 for (j = 0; j < wd; j++) {
4136 for (i = 0; i < hd; i++) {
4137 linet = datat + 3 * i * wplt;
4138 lined = datad + i * wpld;
4139 for (j = 0; j < wd; j++) {
4190 l_int32 w, h, d, wd, hd, wplt, wpld, i, j, rval, gval, bval, direction;
4191 l_uint32 *datat, *datad, *linet, *lined;
4192 PIX *pix1, *pix2, *pixd;
4195 PROCNAME(
"pixConvertColorToSubpixelRGB");
4198 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
4199 d = pixGetDepth(pixs);
4200 cmap = pixGetColormap(pixs);
4201 if (d != 32 && !cmap)
4202 return (
PIX *)ERROR_PTR(
"pix not 32 bpp & not cmapped", procName, NULL);
4203 if (scalex <= 0.0 || scaley <= 0.0)
4204 return (
PIX *)ERROR_PTR(
"scale factors must be > 0", procName, NULL);
4207 return (
PIX *)ERROR_PTR(
"invalid subpixel order", procName, NULL);
4213 if (direction == L_HORIZ)
4214 pix2 =
pixScale(pix1, 3.0 * scalex, scaley);
4216 pix2 =
pixScale(pix1, scalex, 3.0 * scaley);
4219 wd = (direction == L_HORIZ) ? w / 3 : w;
4220 hd = (direction == L_VERT) ? h / 3 : h;
4222 pixCopyInputFormat(pixd, pixs);
4224 wpld = pixGetWpl(pixd);
4226 wplt = pixGetWpl(pix2);
4227 if (direction == L_HORIZ) {
4228 for (i = 0; i < hd; i++) {
4229 linet = datat + i * wplt;
4230 lined = datad + i * wpld;
4231 for (j = 0; j < wd; j++) {
4245 for (i = 0; i < hd; i++) {
4246 linet = datat + 3 * i * wplt;
4247 lined = datad + i * wpld;
4248 for (j = 0; j < wd; j++) {
4263 if (pixGetSpp(pixs) == 4)
4290 PROCNAME(
"l_setNeutralBoostVal");
4293 L_ERROR(
"invalid reference value for neutral boost\n", procName);
4296 var_NEUTRAL_BOOST_VAL = val;
PIX * pixBackgroundNormSimple(PIX *pixs, PIX *pixim, PIX *pixg)
pixBackgroundNormSimple()
#define GET_DATA_QBIT(pdata, n)
#define GET_DATA_TWO_BYTES(pdata, n)
#define SET_DATA_BIT(pdata, n)
#define SET_DATA_DIBIT(pdata, n, val)
#define SET_DATA_TWO_BYTES(pdata, n, val)
#define GET_DATA_BYTE(pdata, n)
#define GET_DATA_DIBIT(pdata, n)
#define SET_DATA_BYTE(pdata, n, val)
#define GET_DATA_BIT(pdata, n)
#define SET_DATA_QBIT(pdata, n, val)
PIX * pixAlphaBlendUniform(PIX *pixs, l_uint32 color)
pixAlphaBlendUniform()
l_ok pixColorsForQuantization(PIX *pixs, l_int32 thresh, l_int32 *pncolors, l_int32 *piscolor, l_int32 debug)
pixColorsForQuantization()
l_ok pixNumColors(PIX *pixs, l_int32 factor, l_int32 *pncolors)
pixNumColors()
void pixcmapDestroy(PIXCMAP **pcmap)
pixcmapDestroy()
l_ok pixcmapHasColor(PIXCMAP *cmap, l_int32 *pcolor)
pixcmapHasColor()
l_int32 pixcmapGetCount(const PIXCMAP *cmap)
pixcmapGetCount()
l_ok pixcmapGetDistanceToColor(PIXCMAP *cmap, l_int32 index, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pdist)
pixcmapGetDistanceToColor()
PIXCMAP * pixcmapConvertTo8(PIXCMAP *cmaps)
pixcmapConvertTo8()
PIXCMAP * pixcmapCreate(l_int32 depth)
pixcmapCreate()
l_ok pixcmapAddRGBA(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 aval)
pixcmapAddRGBA()
PIXCMAP * pixcmapGrayToFalseColor(l_float32 gamma)
pixcmapGrayToFalseColor()
l_ok pixcmapGetColor(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
pixcmapGetColor()
l_ok pixcmapIsOpaque(PIXCMAP *cmap, l_int32 *popaque)
pixcmapIsOpaque()
PIXCMAP * pixcmapGrayToColor(l_uint32 color)
pixcmapGrayToColor()
l_ok pixcmapGetRangeValues(PIXCMAP *cmap, l_int32 select, l_int32 *pminval, l_int32 *pmaxval, l_int32 *pminindex, l_int32 *pmaxindex)
pixcmapGetRangeValues()
PIXCMAP * pixcmapCreateLinear(l_int32 d, l_int32 nlevels)
pixcmapCreateLinear()
l_ok pixcmapToArrays(const PIXCMAP *cmap, l_int32 **prmap, l_int32 **pgmap, l_int32 **pbmap, l_int32 **pamap)
pixcmapToArrays()
l_ok pixcmapIsBlackAndWhite(PIXCMAP *cmap, l_int32 *pblackwhite)
pixcmapIsBlackAndWhite()
l_ok pixcmapAddColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval)
pixcmapAddColor()
l_ok pixcmapToRGBTable(PIXCMAP *cmap, l_uint32 **ptab, l_int32 *pncolors)
pixcmapToRGBTable()
PIX * pixFewColorsOctcubeQuant1(PIX *pixs, l_int32 level)
pixFewColorsOctcubeQuant1()
NUMA * pixOctcubeHistogram(PIX *pixs, l_int32 level, l_int32 *pncolors)
pixOctcubeHistogram()
PIX * pixOctreeColorQuant(PIX *pixs, l_int32 colors, l_int32 ditherflag)
pixOctreeColorQuant()
PIX * pixFewColorsOctcubeQuant2(PIX *pixs, l_int32 level, NUMA *na, l_int32 ncolors, l_int32 *pnerrors)
pixFewColorsOctcubeQuant2()
PIX * pixConvertRGBToHue(PIX *pixs)
pixConvertRGBToHue()
PIX * pixConvertRGBToSaturation(PIX *pixs)
pixConvertRGBToSaturation()
PIX * pixThresholdTo2bpp(PIX *pixs, l_int32 nlevels, l_int32 cmapflag)
pixThresholdTo2bpp()
PIX * pixThresholdTo4bpp(PIX *pixs, l_int32 nlevels, l_int32 cmapflag)
pixThresholdTo4bpp()
PIX * pixThresholdOn8bpp(PIX *pixs, l_int32 nlevels, l_int32 cmapflag)
pixThresholdOn8bpp()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
void numaDestroy(NUMA **pna)
numaDestroy()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok numaGetCountRelativeToZero(NUMA *na, l_int32 type, l_int32 *pcount)
numaGetCountRelativeToZero()
NUMA * numaNormalizeHistogram(NUMA *nas, l_float32 tsum)
numaNormalizeHistogram()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
l_ok pixSetColormap(PIX *pix, PIXCMAP *colormap)
pixSetColormap()
l_ok pixDestroyColormap(PIX *pix)
pixDestroyColormap()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIX * pixCopy(PIX *pixd, const PIX *pixs)
pixCopy()
PIX * pixCreateTemplate(const PIX *pixs)
pixCreateTemplate()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIX * pixClone(PIX *pixs)
pixClone()
PIX * pixGetRGBComponent(PIX *pixs, l_int32 comp)
pixGetRGBComponent()
l_ok pixSetPadBits(PIX *pix, l_int32 val)
pixSetPadBits()
l_ok composeRGBAPixel(l_int32 rval, l_int32 gval, l_int32 bval, l_int32 aval, l_uint32 *ppixel)
composeRGBAPixel()
l_ok composeRGBPixel(l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 *ppixel)
composeRGBPixel()
void extractRGBValues(l_uint32 pixel, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
extractRGBValues()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
NUMA * pixGetGrayHistogram(PIX *pixs, l_int32 factor)
pixGetGrayHistogram()
NUMA * pixGetCmapHistogram(PIX *pixs, l_int32 factor)
pixGetCmapHistogram()
static const l_float32 L_BLUE_WEIGHT
static const l_float32 L_RED_WEIGHT
@ REMOVE_CMAP_TO_FULL_COLOR
@ REMOVE_CMAP_TO_GRAYSCALE
@ REMOVE_CMAP_BASED_ON_SRC
static const l_float32 L_GREEN_WEIGHT
PIX * pixConvertRGBToGrayGeneral(PIX *pixs, l_int32 type, l_float32 rwt, l_float32 gwt, l_float32 bwt)
pixConvertRGBToGrayGeneral()
PIX * pixUnpackBinary(PIX *pixs, l_int32 depth, l_int32 invert)
pixUnpackBinary()
PIX * pixConvert1To8Cmap(PIX *pixs)
pixConvert1To8Cmap()
PIX * pixConvertColorToSubpixelRGB(PIX *pixs, l_float32 scalex, l_float32 scaley, l_int32 order)
pixConvertColorToSubpixelRGB()
PIX * pixConvert1To32(PIX *pixd, PIX *pixs, l_uint32 val0, l_uint32 val1)
pixConvert1To32()
PIX * pixConvertTo1Adaptive(PIX *pixs)
pixConvertTo1Adaptive()
PIX * pixConvert1To16(PIX *pixd, PIX *pixs, l_uint16 val0, l_uint16 val1)
pixConvert1To16()
PIX * pixConvertRGBToGrayMinMax(PIX *pixs, l_int32 type)
pixConvertRGBToGrayMinMax()
l_ok pixQuantizeIfFewColors(PIX *pixs, l_int32 maxcolors, l_int32 mingraycolors, l_int32 octlevel, PIX **ppixd)
pixQuantizeIfFewColors()
PIX * pixConvertTo8Or32(PIX *pixs, l_int32 copyflag, l_int32 warnflag)
pixConvertTo8Or32()
PIX * pixRemoveAlpha(PIX *pixs)
pixRemoveAlpha()
PIX * pixConvertTo1BySampling(PIX *pixs, l_int32 factor, l_int32 threshold)
pixConvertTo1BySampling()
PIX * pixConvertTo2(PIX *pixs)
pixConvertTo2()
PIX * pixConvertCmapTo1(PIX *pixs)
pixConvertCmapTo1()
PIX * pixConvert4To8(PIX *pixs, l_int32 cmapflag)
pixConvert4To8()
PIX * pixConvertRGBToGray(PIX *pixs, l_float32 rwt, l_float32 gwt, l_float32 bwt)
pixConvertRGBToGray()
PIX * pixAddAlphaTo1bpp(PIX *pixd, PIX *pixs)
pixAddAlphaTo1bpp()
PIX * pixConvert2To8(PIX *pixs, l_uint8 val0, l_uint8 val1, l_uint8 val2, l_uint8 val3, l_int32 cmapflag)
pixConvert2To8()
PIX * pixConvert1To4(PIX *pixd, PIX *pixs, l_int32 val0, l_int32 val1)
pixConvert1To4()
PIX * pixConvert1To4Cmap(PIX *pixs)
pixConvert1To4Cmap()
PIX * pixConvert32To16(PIX *pixs, l_int32 type)
pixConvert32To16()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertRGBToColormap(PIX *pixs, l_int32 ditherflag)
pixConvertRGBToColormap()
l_ok pixAddGrayColormap8(PIX *pixs)
pixAddGrayColormap8()
PIX * pixColorizeGray(PIX *pixs, l_uint32 color, l_int32 cmapflag)
pixColorizeGray()
PIX * pixConvertGrayToColormap8(PIX *pixs, l_int32 mindepth)
pixConvertGrayToColormap8()
PIX * pixConvertTo8BySampling(PIX *pixs, l_int32 factor, l_int32 cmapflag)
pixConvertTo8BySampling()
PIX * pixConvertTo8Colormap(PIX *pixs, l_int32 dither)
pixConvertTo8Colormap()
PIX * pixConvertGrayToFalseColor(PIX *pixs, l_float32 gamma)
pixConvertGrayToFalseColor()
PIX * pixThreshold8(PIX *pixs, l_int32 d, l_int32 nlevels, l_int32 cmapflag)
pixThreshold8()
PIX * pixConvert8To16(PIX *pixs, l_int32 leftshift)
pixConvert8To16()
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
PIX * pixConvertForPSWrap(PIX *pixs)
pixConvertForPSWrap()
PIX * pixAddMinimalGrayColormap8(PIX *pixs)
pixAddMinimalGrayColormap8()
PIX * pixConvert1To2Cmap(PIX *pixs)
pixConvert1To2Cmap()
PIX * pixConvert1To8(PIX *pixd, PIX *pixs, l_uint8 val0, l_uint8 val1)
pixConvert1To8()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixConvertLossless(PIX *pixs, l_int32 d)
pixConvertLossless()
PIX * pixConvertTo32BySampling(PIX *pixs, l_int32 factor)
pixConvertTo32BySampling()
PIX * pixConvert1To2(PIX *pixd, PIX *pixs, l_int32 val0, l_int32 val1)
pixConvert1To2()
PIX * pixConvertTo4(PIX *pixs)
pixConvertTo4()
PIX * pixConvertTo16(PIX *pixs)
pixConvertTo16()
PIX * pixRemoveColormapGeneral(PIX *pixs, l_int32 type, l_int32 ifnocmap)
pixRemoveColormapGeneral()
PIX * pixConvertRGBToGrayArb(PIX *pixs, l_float32 rc, l_float32 gc, l_float32 bc)
pixConvertRGBToGrayArb()
PIX * pixConvert8To32(PIX *pixs)
pixConvert8To32()
PIX * pixConvertRGBToLuminance(PIX *pixs)
pixConvertRGBToLuminance()
PIX * pixConvertRGBToGraySatBoost(PIX *pixs, l_int32 refval)
pixConvertRGBToGraySatBoost()
PIX * pixConvert8To4(PIX *pix)
pixConvert8To4()
PIX * pixConvert8To2(PIX *pix)
pixConvert8To2()
PIX * pixConvertGrayToColormap(PIX *pixs)
pixConvertGrayToColormap()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
PIX * pixConvert32To8(PIX *pixs, l_int32 type16, l_int32 type8)
pixConvert32To8()
PIX * pixConvertRGBToGrayFast(PIX *pixs)
pixConvertRGBToGrayFast()
PIX * pixConvert16To8(PIX *pixs, l_int32 type)
pixConvert16To8()
PIX * pixConvert24To32(PIX *pixs)
pixConvert24To32()
void l_setNeutralBoostVal(l_int32 val)
l_setNeutralBoostVal()
PIX * pixConvertGrayToSubpixelRGB(PIX *pixs, l_float32 scalex, l_float32 scaley, l_int32 order)
pixConvertGrayToSubpixelRGB()
PIX * pixConvertRGBToBinaryArb(PIX *pixs, l_float32 rc, l_float32 gc, l_float32 bc, l_int32 thresh, l_int32 relation)
pixConvertRGBToBinaryArb()
PIX * pixConvert32To24(PIX *pixs)
pixConvert32To24()
PIX * pixConvertToSubpixelRGB(PIX *pixs, l_float32 scalex, l_float32 scaley, l_int32 order)
pixConvertToSubpixelRGB()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
PIX * pixScaleBySampling(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleBySampling()
l_ok pixScaleAndTransferAlpha(PIX *pixd, PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleAndTransferAlpha()
void lept_stderr(const char *fmt,...)
lept_stderr()