115 #include <config_auto.h>
119 #include "allheaders.h"
122 l_int32 wpld, l_uint32 *datas, l_int32 ws,
123 l_int32 hs, l_int32 wpls);
124 static void scaleGrayLILow(l_uint32 *datad, l_int32 wd, l_int32 hd,
125 l_int32 wpld, l_uint32 *datas, l_int32 ws,
126 l_int32 hs, l_int32 wpls);
128 l_int32 ws, l_int32 hs, l_int32 wpls);
130 l_uint32 *lines, l_int32 ws, l_int32 wpls,
131 l_int32 lastlineflag);
132 static void scaleGray2xLILow(l_uint32 *datad, l_int32 wpld, l_uint32 *datas,
133 l_int32 ws, l_int32 hs, l_int32 wpls);
135 l_uint32 *lines, l_int32 ws, l_int32 wpls,
136 l_int32 lastlineflag);
137 static void scaleGray4xLILow(l_uint32 *datad, l_int32 wpld, l_uint32 *datas,
138 l_int32 ws, l_int32 hs, l_int32 wpls);
140 l_uint32 *lines, l_int32 ws, l_int32 wpls,
141 l_int32 lastlineflag);
143 l_int32 wpld, l_uint32 *datas, l_int32 ws,
144 l_int32 hs, l_int32 d, l_int32 wpls);
145 static l_int32
scaleSmoothLow(l_uint32 *datad, l_int32 wd, l_int32 hd,
146 l_int32 wpld, l_uint32 *datas, l_int32 ws,
147 l_int32 hs, l_int32 d, l_int32 wpls,
150 l_int32 wpld, l_uint32 *datas, l_int32 wpls,
151 l_float32 rwt, l_float32 gwt, l_float32 bwt);
153 l_int32 wpld, l_uint32 *datas, l_int32 ws,
154 l_int32 hs, l_int32 wpls);
156 l_int32 wpld, l_uint32 *datas, l_int32 ws,
157 l_int32 hs, l_int32 wpls);
159 l_int32 wpld, l_uint32 *datas, l_int32 d,
161 static l_int32 scaleBinaryLow(l_uint32 *datad, l_int32 wd, l_int32 hd,
162 l_int32 wpld, l_uint32 *datas, l_int32 ws,
163 l_int32 hs, l_int32 wpls);
165 #ifndef NO_CONSOLE_IO
166 #define DEBUG_OVERFLOW 0
167 #define DEBUG_UNROLLING 0
255 l_float32 maxscale, sharpfract;
257 PROCNAME(
"pixScale");
260 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
263 maxscale = L_MAX(scalex, scaley);
264 sharpfract = (maxscale < 0.7) ? 0.2 : 0.4;
265 sharpwidth = (maxscale < 0.7) ? 1 : 2;
284 l_int32 w, h, wd, hd;
286 PROCNAME(
"pixScaleToSizeRel");
289 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
291 if (delw == 0 && delh == 0)
297 if (wd <= 0 || hd <= 0)
298 return (
PIX *)ERROR_PTR(
"pix dimension reduced to 0", procName, NULL);
328 l_float32 scalex, scaley;
330 PROCNAME(
"pixScaleToSize");
333 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
334 if (wd <= 0 && hd <= 0)
335 return (
PIX *)ERROR_PTR(
"neither wd nor hd > 0", procName, NULL);
339 scaley = (l_float32)hd / (l_float32)h;
341 }
else if (hd <= 0) {
342 scalex = (l_float32)wd / (l_float32)w;
345 scalex = (l_float32)wd / (l_float32)w;
346 scaley = (l_float32)hd / (l_float32)h;
349 return pixScale(pixs, scalex, scaley);
366 l_float32 *pscalefact)
371 PROCNAME(
"pixScaleToResolution");
373 if (pscalefact) *pscalefact = 1.0;
375 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
377 return (
PIX *)ERROR_PTR(
"target resolution <= 0", procName, NULL);
379 xres = pixGetXRes(pixs);
385 factor = target / (l_float32)xres;
386 if (pscalefact) *pscalefact = factor;
388 return pixScale(pixs, factor, factor);
426 l_float32 sharpfract,
430 l_float32 maxscale, minscale;
431 PIX *pix1, *pix2, *pixd;
433 PROCNAME(
"pixScaleGeneral");
436 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
437 d = pixGetDepth(pixs);
438 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 16 && d != 32)
439 return (
PIX *)ERROR_PTR(
"pixs not {1,2,4,8,16,32} bpp", procName, NULL);
440 if (scalex <= 0.0 || scaley <= 0.0)
441 return (
PIX *)ERROR_PTR(
"scale factor <= 0", procName, NULL);
442 if (scalex == 1.0 && scaley == 1.0)
450 return (
PIX *)ERROR_PTR(
"pix1 not made", procName, NULL);
453 d = pixGetDepth(pix1);
454 maxscale = L_MAX(scalex, scaley);
455 minscale = L_MIN(scalex, scaley);
456 if (maxscale < 0.7) {
457 if (minscale < 0.02) {
462 if (maxscale > 0.2 && sharpfract > 0.0 && sharpwidth > 0) {
473 if (maxscale < 1.4 && sharpfract > 0.0 && sharpwidth > 0) {
482 pixCopyText(pixd, pixs);
483 pixCopyInputFormat(pixd, pixs);
524 PROCNAME(
"pixScaleLI");
526 if (!pixs || (pixGetDepth(pixs) == 1))
527 return (
PIX *)ERROR_PTR(
"pixs not defined or 1 bpp", procName, NULL);
528 maxscale = L_MAX(scalex, scaley);
529 if (maxscale < 0.7) {
530 L_WARNING(
"scaling factors < 0.7; do regular scaling\n", procName);
533 d = pixGetDepth(pixs);
534 if (d != 2 && d != 4 && d != 8 && d != 16 && d != 32)
535 return (
PIX *)ERROR_PTR(
"pixs not {2,4,8,16,32} bpp", procName, NULL);
539 return (
PIX *)ERROR_PTR(
"pixt not made", procName, NULL);
541 d = pixGetDepth(pixt);
548 pixCopyInputFormat(pixd, pixs);
579 l_int32 ws, hs, wpls, wd, hd, wpld;
580 l_uint32 *datas, *datad;
584 PROCNAME(
"pixScaleColorLI");
586 if (!pixs || (pixGetDepth(pixs) != 32))
587 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", procName, NULL);
588 maxscale = L_MAX(scalex, scaley);
589 if (maxscale < 0.7) {
590 L_WARNING(
"scaling factors < 0.7; do regular scaling\n", procName);
595 if (scalex == 1.0 && scaley == 1.0)
597 if (scalex == 2.0 && scaley == 2.0)
599 if (scalex == 4.0 && scaley == 4.0)
605 wpls = pixGetWpl(pixs);
606 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
607 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
608 if ((pixd =
pixCreate(wd, hd, 32)) == NULL)
609 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
610 pixCopyResolution(pixd, pixs);
611 pixScaleResolution(pixd, scalex, scaley);
613 wpld = pixGetWpl(pixd);
615 if (pixGetSpp(pixs) == 4)
618 pixCopyInputFormat(pixd, pixs);
641 l_int32 ws, hs, wpls, wpld;
642 l_uint32 *datas, *datad;
645 PROCNAME(
"pixScaleColor2xLI");
647 if (!pixs || (pixGetDepth(pixs) != 32))
648 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", procName, NULL);
652 wpls = pixGetWpl(pixs);
653 if ((pixd =
pixCreate(2 * ws, 2 * hs, 32)) == NULL)
654 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
655 pixCopyResolution(pixd, pixs);
656 pixScaleResolution(pixd, 2.0, 2.0);
658 wpld = pixGetWpl(pixd);
660 if (pixGetSpp(pixs) == 4)
663 pixCopyInputFormat(pixd, pixs);
688 PIX *pixr, *pixg, *pixb;
689 PIX *pixrs, *pixgs, *pixbs;
692 PROCNAME(
"pixScaleColor4xLI");
694 if (!pixs || (pixGetDepth(pixs) != 32))
695 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", procName, NULL);
708 L_ERROR(
"pixd not made\n", procName);
710 if (pixGetSpp(pixs) == 4)
712 pixCopyInputFormat(pixd, pixs);
784 l_int32 ws, hs, wpls, wd, hd, wpld;
785 l_uint32 *datas, *datad;
789 PROCNAME(
"pixScaleGrayLI");
791 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
792 return (
PIX *)ERROR_PTR(
"pixs undefined, cmapped or not 8 bpp",
794 maxscale = L_MAX(scalex, scaley);
795 if (maxscale < 0.7) {
796 L_WARNING(
"scaling factors < 0.7; do regular scaling\n", procName);
801 if (scalex == 1.0 && scaley == 1.0)
803 if (scalex == 2.0 && scaley == 2.0)
805 if (scalex == 4.0 && scaley == 4.0)
811 wpls = pixGetWpl(pixs);
812 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
813 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
814 if ((pixd =
pixCreate(wd, hd, 8)) == NULL)
815 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
816 pixCopyText(pixd, pixs);
817 pixCopyResolution(pixd, pixs);
818 pixCopyInputFormat(pixd, pixs);
819 pixScaleResolution(pixd, scalex, scaley);
821 wpld = pixGetWpl(pixd);
843 l_int32 ws, hs, wpls, wpld;
844 l_uint32 *datas, *datad;
847 PROCNAME(
"pixScaleGray2xLI");
849 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
850 return (
PIX *)ERROR_PTR(
"pixs undefined, cmapped or not 8 bpp",
855 wpls = pixGetWpl(pixs);
856 if ((pixd =
pixCreate(2 * ws, 2 * hs, 8)) == NULL)
857 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
858 pixCopyResolution(pixd, pixs);
859 pixCopyInputFormat(pixd, pixs);
860 pixScaleResolution(pixd, 2.0, 2.0);
862 wpld = pixGetWpl(pixd);
884 l_int32 ws, hs, wpls, wpld;
885 l_uint32 *datas, *datad;
888 PROCNAME(
"pixScaleGray4xLI");
890 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
891 return (
PIX *)ERROR_PTR(
"pixs undefined, cmapped or not 8 bpp",
896 wpls = pixGetWpl(pixs);
897 if ((pixd =
pixCreate(4 * ws, 4 * hs, 8)) == NULL)
898 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
899 pixCopyResolution(pixd, pixs);
900 pixCopyInputFormat(pixd, pixs);
901 pixScaleResolution(pixd, 4.0, 4.0);
903 wpld = pixGetWpl(pixd);
930 l_int32 i, ws, hs, hsm, wd, hd, wpls, wplb, wpld;
931 l_uint32 *datas, *datad, *lines, *lined, *lineb;
934 PROCNAME(
"pixScaleGray2xLIThresh");
936 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
937 return (
PIX *)ERROR_PTR(
"pixs undefined, not 8 bpp, or cmapped",
939 if (thresh < 0 || thresh > 256)
940 return (
PIX *)ERROR_PTR(
"thresh must be in [0, ... 256]",
948 wpls = pixGetWpl(pixs);
952 if ((lineb = (l_uint32 *)LEPT_CALLOC(2 * wplb,
sizeof(l_uint32))) == NULL)
953 return (
PIX *)ERROR_PTR(
"lineb not made", procName, NULL);
956 if ((pixd =
pixCreate(wd, hd, 1)) == NULL) {
958 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
960 pixCopyInputFormat(pixd, pixs);
961 pixCopyResolution(pixd, pixs);
962 pixScaleResolution(pixd, 2.0, 2.0);
963 wpld = pixGetWpl(pixd);
967 for (i = 0; i < hsm; i++) {
968 lines = datas + i * wpls;
969 lined = datad + 2 * i * wpld;
971 thresholdToBinaryLineLow(lined, wd, lineb, 8, thresh);
972 thresholdToBinaryLineLow(lined + wpld, wd, lineb + wplb, 8, thresh);
976 lines = datas + hsm * wpls;
977 lined = datad + 2 * hsm * wpld;
979 thresholdToBinaryLineLow(lined, wd, lineb, 8, thresh);
980 thresholdToBinaryLineLow(lined + wpld, wd, lineb + wplb, 8, thresh);
1008 l_int32 i, ws, hs, hsm, wd, hd, wpls, wplb, wpld;
1009 l_uint32 *datas, *datad;
1011 l_uint32 *lineb = NULL;
1012 l_uint32 *linebp = NULL;
1013 l_uint32 *bufs = NULL;
1016 PROCNAME(
"pixScaleGray2xLIDither");
1018 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
1019 return (
PIX *)ERROR_PTR(
"pixs undefined, not 8 bpp, or cmapped",
1027 wpls = pixGetWpl(pixs);
1030 if ((bufs = (l_uint32 *)LEPT_CALLOC(2 * wpls,
sizeof(l_uint32))) == NULL)
1031 return (
PIX *)ERROR_PTR(
"bufs not made", procName, NULL);
1034 wplb = (wd + 3) / 4;
1035 if ((lineb = (l_uint32 *)LEPT_CALLOC(2 * wplb,
sizeof(l_uint32))) == NULL) {
1036 L_ERROR(
"lineb not made\n", procName);
1041 if ((linebp = (l_uint32 *)LEPT_CALLOC(wplb,
sizeof(l_uint32))) == NULL) {
1042 L_ERROR(
"linebp not made\n", procName);
1047 if ((pixd =
pixCreate(wd, hd, 1)) == NULL) {
1048 L_ERROR(
"pixd not made\n", procName);
1051 pixCopyInputFormat(pixd, pixs);
1052 pixCopyResolution(pixd, pixs);
1053 pixScaleResolution(pixd, 2.0, 2.0);
1054 wpld = pixGetWpl(pixd);
1058 memcpy(bufs, datas, 4 * wpls);
1059 memcpy(bufs + wpls, datas + wpls, 4 * wpls);
1067 for (i = 1; i < hsm; i++) {
1068 memcpy(bufs, datas + i * wpls, 4 * wpls);
1069 memcpy(bufs + wpls, datas + (i + 1) * wpls, 4 * wpls);
1070 memcpy(linebp, lineb + wplb, 4 * wplb);
1072 lined = datad + 2 * i * wpld;
1082 memcpy(bufs, datas + hsm * wpls, 4 * wpls);
1083 memcpy(linebp, lineb + wplb, 4 * wplb);
1128 l_int32 i, j, ws, hs, hsm, wd, hd, wpls, wplb, wpld;
1129 l_uint32 *datas, *datad, *lines, *lined, *lineb;
1132 PROCNAME(
"pixScaleGray4xLIThresh");
1134 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
1135 return (
PIX *)ERROR_PTR(
"pixs undefined, not 8 bpp, or cmapped",
1137 if (thresh < 0 || thresh > 256)
1138 return (
PIX *)ERROR_PTR(
"thresh must be in [0, ... 256]",
1146 wpls = pixGetWpl(pixs);
1149 wplb = (wd + 3) / 4;
1150 if ((lineb = (l_uint32 *)LEPT_CALLOC(4 * wplb,
sizeof(l_uint32))) == NULL)
1151 return (
PIX *)ERROR_PTR(
"lineb not made", procName, NULL);
1154 if ((pixd =
pixCreate(wd, hd, 1)) == NULL) {
1156 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1158 pixCopyInputFormat(pixd, pixs);
1159 pixCopyResolution(pixd, pixs);
1160 pixScaleResolution(pixd, 4.0, 4.0);
1161 wpld = pixGetWpl(pixd);
1165 for (i = 0; i < hsm; i++) {
1166 lines = datas + i * wpls;
1167 lined = datad + 4 * i * wpld;
1169 for (j = 0; j < 4; j++) {
1170 thresholdToBinaryLineLow(lined + j * wpld, wd,
1171 lineb + j * wplb, 8, thresh);
1176 lines = datas + hsm * wpls;
1177 lined = datad + 4 * hsm * wpld;
1179 for (j = 0; j < 4; j++) {
1180 thresholdToBinaryLineLow(lined + j * wpld, wd,
1181 lineb + j * wplb, 8, thresh);
1215 l_int32 i, j, ws, hs, hsm, wd, hd, wpls, wplb, wpld;
1216 l_uint32 *datas, *datad;
1218 l_uint32 *lineb = NULL;
1219 l_uint32 *linebp = NULL;
1220 l_uint32 *bufs = NULL;
1223 PROCNAME(
"pixScaleGray4xLIDither");
1225 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
1226 return (
PIX *)ERROR_PTR(
"pixs undefined, not 8 bpp, or cmapped",
1234 wpls = pixGetWpl(pixs);
1237 if ((bufs = (l_uint32 *)LEPT_CALLOC(2 * wpls,
sizeof(l_uint32))) == NULL)
1238 return (
PIX *)ERROR_PTR(
"bufs not made", procName, NULL);
1241 wplb = (wd + 3) / 4;
1242 if ((lineb = (l_uint32 *)LEPT_CALLOC(4 * wplb,
sizeof(l_uint32))) == NULL) {
1243 L_ERROR(
"lineb not made\n", procName);
1248 if ((linebp = (l_uint32 *)LEPT_CALLOC(wplb,
sizeof(l_uint32))) == NULL) {
1249 L_ERROR(
"linebp not made\n", procName);
1254 if ((pixd =
pixCreate(wd, hd, 1)) == NULL) {
1255 L_ERROR(
"pixd not made\n", procName);
1258 pixCopyInputFormat(pixd, pixs);
1259 pixCopyResolution(pixd, pixs);
1260 pixScaleResolution(pixd, 4.0, 4.0);
1261 wpld = pixGetWpl(pixd);
1265 memcpy(bufs, datas, 4 * wpls);
1266 memcpy(bufs + wpls, datas + wpls, 4 * wpls);
1269 for (j = 0; j < 3; j++) {
1271 lineb + (j + 1) * wplb,
1276 for (i = 1; i < hsm; i++) {
1277 memcpy(bufs, datas + i * wpls, 4 * wpls);
1278 memcpy(bufs + wpls, datas + (i + 1) * wpls, 4 * wpls);
1279 memcpy(linebp, lineb + 3 * wplb, 4 * wplb);
1281 lined = datad + 4 * i * wpld;
1285 for (j = 0; j < 3; j++) {
1287 lineb + (j + 1) * wplb,
1293 memcpy(bufs, datas + hsm * wpls, 4 * wpls);
1294 memcpy(linebp, lineb + 3 * wplb, 4 * wplb);
1296 lined = datad + 4 * hsm * wpld;
1300 for (j = 0; j < 3; j++) {
1302 lineb + (j + 1) * wplb,
1342 l_int32 ws, hs, d, wpls, wd, hd, wpld;
1343 l_uint32 *datas, *datad;
1346 PROCNAME(
"pixScaleBySampling");
1349 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1350 if (scalex <= 0.0 || scaley <= 0.0)
1351 return (
PIX *)ERROR_PTR(
"scale factor <= 0", procName, NULL);
1352 if (scalex == 1.0 && scaley == 1.0)
1354 if ((d = pixGetDepth(pixs)) == 1)
1359 wpls = pixGetWpl(pixs);
1360 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
1361 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
1362 if ((pixd =
pixCreate(wd, hd, d)) == NULL)
1363 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1364 pixCopyResolution(pixd, pixs);
1365 pixScaleResolution(pixd, scalex, scaley);
1367 pixCopyText(pixd, pixs);
1368 pixCopyInputFormat(pixd, pixs);
1371 wpld = pixGetWpl(pixd);
1373 if (d == 32 && pixGetSpp(pixs) == 4)
1405 l_float32 scalex, scaley;
1407 PROCNAME(
"pixScaleBySamplingToSize");
1410 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1411 if (wd <= 0 && hd <= 0)
1412 return (
PIX *)ERROR_PTR(
"neither wd nor hd > 0", procName, NULL);
1416 scaley = (l_float32)hd / (l_float32)h;
1418 }
else if (hd <= 0) {
1419 scalex = (l_float32)wd / (l_float32)w;
1422 scalex = (l_float32)wd / (l_float32)w;
1423 scaley = (l_float32)hd / (l_float32)h;
1449 PROCNAME(
"pixScaleByIntSampling");
1452 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1455 L_ERROR(
"factor must be >= 1; returning a copy\n", procName);
1459 scale = 1. / (l_float32)factor;
1490 l_int32 byteval, shift;
1491 l_int32 i, j, ws, hs, wd, hd, wpls, wpld;
1492 l_uint32 *datas, *words, *datad, *lined;
1496 PROCNAME(
"pixScaleRGBToGrayFast");
1499 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1500 if (pixGetDepth(pixs) != 32)
1501 return (
PIX *)ERROR_PTR(
"depth not 32 bpp", procName, NULL);
1503 return (
PIX *)ERROR_PTR(
"factor must be >= 1", procName, NULL);
1506 shift = L_RED_SHIFT;
1508 shift = L_GREEN_SHIFT;
1510 shift = L_BLUE_SHIFT;
1512 return (
PIX *)ERROR_PTR(
"invalid color", procName, NULL);
1516 wpls = pixGetWpl(pixs);
1520 if ((pixd =
pixCreate(wd, hd, 8)) == NULL)
1521 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1522 pixCopyResolution(pixd, pixs);
1523 pixCopyInputFormat(pixd, pixs);
1524 scale = 1. / (l_float32) factor;
1525 pixScaleResolution(pixd, scale, scale);
1527 wpld = pixGetWpl(pixd);
1529 for (i = 0; i < hd; i++) {
1530 words = datas + i * factor * wpls;
1531 lined = datad + i * wpld;
1532 for (j = 0; j < wd; j++, words += factor) {
1533 byteval = ((*words) >> shift) & 0xff;
1566 l_int32 i, j, ws, hs, wd, hd, wpls, wpld;
1567 l_uint32 *datas, *words, *datad, *lined;
1571 PROCNAME(
"pixScaleRGBToBinaryFast");
1574 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1576 return (
PIX *)ERROR_PTR(
"factor must be >= 1", procName, NULL);
1577 if (pixGetDepth(pixs) != 32)
1578 return (
PIX *)ERROR_PTR(
"depth not 32 bpp", procName, NULL);
1582 wpls = pixGetWpl(pixs);
1586 if ((pixd =
pixCreate(wd, hd, 1)) == NULL)
1587 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1588 pixCopyResolution(pixd, pixs);
1589 pixCopyInputFormat(pixd, pixs);
1590 scale = 1. / (l_float32) factor;
1591 pixScaleResolution(pixd, scale, scale);
1593 wpld = pixGetWpl(pixd);
1595 for (i = 0; i < hd; i++) {
1596 words = datas + i * factor * wpls;
1597 lined = datad + i * wpld;
1598 for (j = 0; j < wd; j++, words += factor) {
1599 byteval = ((*words) >> L_GREEN_SHIFT) & 0xff;
1600 if (byteval < thresh)
1632 l_int32 i, j, ws, hs, wd, hd, wpls, wpld, sj;
1633 l_uint32 *datas, *datad, *lines, *lined;
1637 PROCNAME(
"pixScaleGrayToBinaryFast");
1640 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1642 return (
PIX *)ERROR_PTR(
"factor must be >= 1", procName, NULL);
1643 if (pixGetDepth(pixs) != 8)
1644 return (
PIX *)ERROR_PTR(
"depth not 8 bpp", procName, NULL);
1648 wpls = pixGetWpl(pixs);
1652 if ((pixd =
pixCreate(wd, hd, 1)) == NULL)
1653 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1654 pixCopyResolution(pixd, pixs);
1655 pixCopyInputFormat(pixd, pixs);
1656 scale = 1. / (l_float32) factor;
1657 pixScaleResolution(pixd, scale, scale);
1659 wpld = pixGetWpl(pixd);
1661 for (i = 0; i < hd; i++) {
1662 lines = datas + i * factor * wpls;
1663 lined = datad + i * wpld;
1664 for (j = 0, sj = 0; j < wd; j++, sj += factor) {
1666 if (byteval < thresh)
1713 l_int32 ws, hs, d, wd, hd, wpls, wpld, isize;
1715 l_uint32 *datas, *datad;
1716 l_float32 minscale, size;
1719 PROCNAME(
"pixScaleSmooth");
1722 return (
PIX *)ERROR_PTR(
"pix not defined", procName, NULL);
1723 if (scalex >= 0.7 || scaley >= 0.7) {
1724 L_WARNING(
"scaling factor not < 0.7; do regular scaling\n", procName);
1727 d = pixGetDepth(pix);
1728 if (d != 2 && d != 4 && d !=8 && d != 32)
1729 return (
PIX *)ERROR_PTR(
"pix not 2, 4, 8 or 32 bpp", procName, NULL);
1733 return (
PIX *)ERROR_PTR(
"pixs not made", procName, NULL);
1734 d = pixGetDepth(pixs);
1739 minscale = L_MIN(scalex, scaley);
1740 size = 1.0 / minscale;
1741 isize = L_MIN(10000, L_MAX(2, (l_int32)(size + 0.5)));
1744 if ((ws < isize) || (hs < isize)) {
1748 L_WARNING(
"ridiculously small scaling factor %f\n", procName, minscale);
1754 wpls = pixGetWpl(pixs);
1755 wd = L_MAX(1, (l_int32)(scalex * (l_float32)ws + 0.5));
1756 hd = L_MAX(1, (l_int32)(scaley * (l_float32)hs + 0.5));
1757 if ((pixd =
pixCreate(wd, hd, d)) == NULL) {
1759 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1761 pixCopyResolution(pixd, pixs);
1762 pixCopyInputFormat(pixd, pixs);
1763 pixScaleResolution(pixd, scalex, scaley);
1765 wpld = pixGetWpl(pixd);
1766 scaleSmoothLow(datad, wd, hd, wpld, datas, ws, hs, d, wpls, isize);
1767 if (d == 32 && pixGetSpp(pixs) == 4)
1800 l_float32 scalex, scaley;
1802 PROCNAME(
"pixScaleSmoothToSize");
1805 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1806 if (wd <= 0 && hd <= 0)
1807 return (
PIX *)ERROR_PTR(
"neither wd nor hd > 0", procName, NULL);
1811 scaley = (l_float32)hd / (l_float32)h;
1813 }
else if (hd <= 0) {
1814 scalex = (l_float32)wd / (l_float32)w;
1817 scalex = (l_float32)wd / (l_float32)w;
1818 scaley = (l_float32)hd / (l_float32)h;
1838 l_int32 wd, hd, wpls, wpld;
1839 l_uint32 *datas, *datad;
1842 PROCNAME(
"pixScaleRGBToGray2");
1845 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1846 if (pixGetDepth(pixs) != 32)
1847 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", procName, NULL);
1848 if (rwt + gwt + bwt < 0.98 || rwt + gwt + bwt > 1.02)
1849 return (
PIX *)ERROR_PTR(
"sum of wts should be 1.0", procName, NULL);
1851 wd = pixGetWidth(pixs) / 2;
1852 hd = pixGetHeight(pixs) / 2;
1853 wpls = pixGetWpl(pixs);
1855 if ((pixd =
pixCreate(wd, hd, 8)) == NULL)
1856 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1857 pixCopyResolution(pixd, pixs);
1858 pixCopyInputFormat(pixd, pixs);
1859 pixScaleResolution(pixd, 0.5, 0.5);
1860 wpld = pixGetWpl(pixd);
1918 l_int32 ws, hs, d, wd, hd, wpls, wpld;
1919 l_uint32 *datas, *datad;
1920 l_float32 maxscale, minscale;
1921 PIX *pixs, *pixd, *pix1, *pix2, *pix3;
1923 PROCNAME(
"pixScaleAreaMap");
1926 return (
PIX *)ERROR_PTR(
"pix not defined", procName, NULL);
1927 d = pixGetDepth(pix);
1928 if (d != 2 && d != 4 && d != 8 && d != 32)
1929 return (
PIX *)ERROR_PTR(
"pix not 2, 4, 8 or 32 bpp", procName, NULL);
1931 minscale = L_MIN(scalex, scaley);
1932 if (minscale < 0.02) {
1933 L_WARNING(
"tiny scaling factor; using pixScaleSmooth()\n", procName);
1937 maxscale = L_MAX(scalex, scaley);
1938 if (maxscale >= 0.7) {
1939 L_WARNING(
"scaling factor >= 0.7; do regular scaling\n", procName);
1944 if (scalex == 0.5 && scaley == 0.5)
1946 if (scalex == 0.25 && scaley == 0.25) {
1952 if (scalex == 0.125 && scaley == 0.125) {
1960 if (scalex == 0.0625 && scaley == 0.0625) {
1975 if (scalex > 0.35 && scalex < 0.5) {
1985 if ((d == 2 || d == 4 || d == 8) && pixGetColormap(pix)) {
1986 L_WARNING(
"pix has colormap; removing\n", procName);
1988 d = pixGetDepth(pixs);
1989 }
else if (d == 2 || d == 4) {
1998 wpls = pixGetWpl(pixs);
1999 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
2000 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
2001 if (wd < 1 || hd < 1) {
2003 return (
PIX *)ERROR_PTR(
"pixd too small", procName, NULL);
2005 if ((pixd =
pixCreate(wd, hd, d)) == NULL) {
2007 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2009 pixCopyInputFormat(pixd, pixs);
2010 pixCopyResolution(pixd, pixs);
2011 pixScaleResolution(pixd, scalex, scaley);
2013 wpld = pixGetWpl(pixd);
2018 if (pixGetSpp(pixs) == 4)
2049 l_int32 wd, hd, d, wpls, wpld;
2050 l_uint32 *datas, *datad;
2053 PROCNAME(
"pixScaleAreaMap2");
2056 return (
PIX *)ERROR_PTR(
"pix not defined", procName, NULL);
2057 d = pixGetDepth(pix);
2058 if (d != 2 && d != 4 && d != 8 && d != 32)
2059 return (
PIX *)ERROR_PTR(
"pix not 2, 4, 8 or 32 bpp", procName, NULL);
2063 if ((d == 2 || d == 4 || d == 8) && pixGetColormap(pix)) {
2064 L_WARNING(
"pix has colormap; removing\n", procName);
2066 d = pixGetDepth(pixs);
2067 }
else if (d == 2 || d == 4) {
2074 wd = pixGetWidth(pixs) / 2;
2075 hd = pixGetHeight(pixs) / 2;
2077 wpls = pixGetWpl(pixs);
2080 wpld = pixGetWpl(pixd);
2081 pixCopyInputFormat(pixd, pixs);
2082 pixCopyResolution(pixd, pixs);
2083 pixScaleResolution(pixd, 0.5, 0.5);
2085 if (pixGetSpp(pixs) == 4)
2117 l_float32 scalex, scaley;
2119 PROCNAME(
"pixScaleAreaMapToSize");
2122 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2123 if (wd <= 0 && hd <= 0)
2124 return (
PIX *)ERROR_PTR(
"neither wd nor hd > 0", procName, NULL);
2128 scaley = (l_float32)hd / (l_float32)h;
2130 }
else if (hd <= 0) {
2131 scalex = (l_float32)wd / (l_float32)w;
2134 scalex = (l_float32)wd / (l_float32)w;
2135 scaley = (l_float32)hd / (l_float32)h;
2165 l_int32 ws, hs, wpls, wd, hd, wpld;
2166 l_uint32 *datas, *datad;
2169 PROCNAME(
"pixScaleBinary");
2172 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
2173 if (pixGetDepth(pixs) != 1)
2174 return (
PIX *)ERROR_PTR(
"pixs must be 1 bpp", procName, NULL);
2175 if (scalex <= 0.0 || scaley <= 0.0)
2176 return (
PIX *)ERROR_PTR(
"scale factor <= 0", procName, NULL);
2177 if (scalex == 1.0 && scaley == 1.0)
2182 wpls = pixGetWpl(pixs);
2183 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
2184 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
2185 if ((pixd =
pixCreate(wd, hd, 1)) == NULL)
2186 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
2188 pixCopyText(pixd, pixs);
2189 pixCopyInputFormat(pixd, pixs);
2190 pixCopyResolution(pixd, pixs);
2191 pixScaleResolution(pixd, scalex, scaley);
2193 wpld = pixGetWpl(pixd);
2194 scaleBinaryLow(datad, wd, hd, wpld, datas, ws, hs, wpls);
2228 l_int32 i, j, wm2, hm2;
2230 l_int32 xp, yp, xf, yf;
2231 l_uint32 v00r, v01r, v10r, v11r, v00g, v01g, v10g, v11g;
2232 l_uint32 v00b, v01b, v10b, v11b, area00, area01, area10, area11;
2233 l_uint32 pixels1, pixels2, pixels3, pixels4, pixel;
2234 l_uint32 *lines, *lined;
2241 scx = 16. * (l_float32)ws / (l_float32)wd;
2242 scy = 16. * (l_float32)hs / (l_float32)hd;
2247 for (i = 0; i < hd; i++) {
2248 ypm = (l_int32)(scy * (l_float32)i);
2251 lined = datad + i * wpld;
2252 lines = datas + yp * wpls;
2253 for (j = 0; j < wd; j++) {
2254 xpm = (l_int32)(scx * (l_float32)j);
2263 pixels1 = *(lines + xp);
2265 if (xp > wm2 || yp > hm2) {
2266 if (yp > hm2 && xp <= wm2) {
2267 pixels2 = *(lines + xp + 1);
2270 }
else if (xp > wm2 && yp <= hm2) {
2272 pixels3 = *(lines + wpls + xp);
2275 pixels4 = pixels3 = pixels2 = pixels1;
2278 pixels2 = *(lines + xp + 1);
2279 pixels3 = *(lines + wpls + xp);
2280 pixels4 = *(lines + wpls + xp + 1);
2283 area00 = (16 - xf) * (16 - yf);
2284 area10 = xf * (16 - yf);
2285 area01 = (16 - xf) * yf;
2287 v00r = area00 * ((pixels1 >> L_RED_SHIFT) & 0xff);
2288 v00g = area00 * ((pixels1 >> L_GREEN_SHIFT) & 0xff);
2289 v00b = area00 * ((pixels1 >> L_BLUE_SHIFT) & 0xff);
2290 v10r = area10 * ((pixels2 >> L_RED_SHIFT) & 0xff);
2291 v10g = area10 * ((pixels2 >> L_GREEN_SHIFT) & 0xff);
2292 v10b = area10 * ((pixels2 >> L_BLUE_SHIFT) & 0xff);
2293 v01r = area01 * ((pixels3 >> L_RED_SHIFT) & 0xff);
2294 v01g = area01 * ((pixels3 >> L_GREEN_SHIFT) & 0xff);
2295 v01b = area01 * ((pixels3 >> L_BLUE_SHIFT) & 0xff);
2296 v11r = area11 * ((pixels4 >> L_RED_SHIFT) & 0xff);
2297 v11g = area11 * ((pixels4 >> L_GREEN_SHIFT) & 0xff);
2298 v11b = area11 * ((pixels4 >> L_BLUE_SHIFT) & 0xff);
2299 pixel = (((v00r + v10r + v01r + v11r + 128) << 16) & 0xff000000) |
2300 (((v00g + v10g + v01g + v11g + 128) << 8) & 0x00ff0000) |
2301 ((v00b + v10b + v01b + v11b + 128) & 0x0000ff00);
2302 *(lined + j) = pixel;
2333 l_int32 i, j, wm2, hm2;
2335 l_int32 xp, yp, xf, yf;
2336 l_int32 v00, v01, v10, v11, v00_val, v01_val, v10_val, v11_val;
2338 l_uint32 *lines, *lined;
2345 scx = 16. * (l_float32)ws / (l_float32)wd;
2346 scy = 16. * (l_float32)hs / (l_float32)hd;
2351 for (i = 0; i < hd; i++) {
2352 ypm = (l_int32)(scy * (l_float32)i);
2355 lined = datad + i * wpld;
2356 lines = datas + yp * wpls;
2357 for (j = 0; j < wd; j++) {
2358 xpm = (l_int32)(scx * (l_float32)j);
2367 if (xp > wm2 || yp > hm2) {
2368 if (yp > hm2 && xp <= wm2) {
2372 }
else if (xp > wm2 && yp <= hm2) {
2377 v10_val = v01_val = v11_val = v00_val;
2385 v00 = (16 - xf) * (16 - yf) * v00_val;
2386 v10 = xf * (16 - yf) * v10_val;
2387 v01 = (16 - xf) * yf * v01_val;
2388 v11 = xf * yf * v11_val;
2390 val = (l_uint8)((v00 + v01 + v10 + v11 + 128) / 256);
2449 l_uint32 *lines, *lined;
2464 for (i = 0; i < hsm; i++) {
2465 lines = datas + i * wpls;
2466 lined = datad + 2 * i * wpld;
2471 lines = datas + hsm * wpls;
2472 lined = datad + 2 * hsm * wpld;
2494 l_int32 lastlineflag)
2497 l_uint32 rval1, rval2, rval3, rval4, gval1, gval2, gval3, gval4;
2498 l_uint32 bval1, bval2, bval3, bval4;
2499 l_uint32 pixels1, pixels2, pixels3, pixels4, pixel;
2500 l_uint32 *linesp, *linedp;
2504 if (lastlineflag == 0) {
2505 linesp = lines + wpls;
2506 linedp = lined + wpld;
2511 rval2 = pixels1 >> 24;
2512 gval2 = (pixels1 >> 16) & 0xff;
2513 bval2 = (pixels1 >> 8) & 0xff;
2514 rval4 = pixels3 >> 24;
2515 gval4 = (pixels3 >> 16) & 0xff;
2516 bval4 = (pixels3 >> 8) & 0xff;
2518 for (j = 0, jd = 0; j < wsm; j++, jd += 2) {
2527 pixels2 = *(lines + j + 1);
2528 pixels4 = *(linesp + j + 1);
2529 rval2 = pixels2 >> 24;
2530 gval2 = (pixels2 >> 16) & 0xff;
2531 bval2 = (pixels2 >> 8) & 0xff;
2532 rval4 = pixels4 >> 24;
2533 gval4 = (pixels4 >> 16) & 0xff;
2534 bval4 = (pixels4 >> 8) & 0xff;
2536 pixel = (rval1 << 24 | gval1 << 16 | bval1 << 8);
2537 *(lined + jd) = pixel;
2538 pixel = ((((rval1 + rval2) << 23) & 0xff000000) |
2539 (((gval1 + gval2) << 15) & 0x00ff0000) |
2540 (((bval1 + bval2) << 7) & 0x0000ff00));
2541 *(lined + jd + 1) = pixel;
2542 pixel = ((((rval1 + rval3) << 23) & 0xff000000) |
2543 (((gval1 + gval3) << 15) & 0x00ff0000) |
2544 (((bval1 + bval3) << 7) & 0x0000ff00));
2545 *(linedp + jd) = pixel;
2546 pixel = ((((rval1 + rval2 + rval3 + rval4) << 22) & 0xff000000) |
2547 (((gval1 + gval2 + gval3 + gval4) << 14) & 0x00ff0000) |
2548 (((bval1 + bval2 + bval3 + bval4) << 6) & 0x0000ff00));
2549 *(linedp + jd + 1) = pixel;
2558 pixel = (rval1 << 24 | gval1 << 16 | bval1 << 8);
2559 *(lined + 2 * wsm) = pixel;
2560 *(lined + 2 * wsm + 1) = pixel;
2561 pixel = ((((rval1 + rval3) << 23) & 0xff000000) |
2562 (((gval1 + gval3) << 15) & 0x00ff0000) |
2563 (((bval1 + bval3) << 7) & 0x0000ff00));
2564 *(linedp + 2 * wsm) = pixel;
2565 *(linedp + 2 * wsm + 1) = pixel;
2567 linedp = lined + wpld;
2569 rval2 = pixels2 >> 24;
2570 gval2 = (pixels2 >> 16) & 0xff;
2571 bval2 = (pixels2 >> 8) & 0xff;
2572 for (j = 0, jd = 0; j < wsm; j++, jd += 2) {
2576 pixels2 = *(lines + j + 1);
2577 rval2 = pixels2 >> 24;
2578 gval2 = (pixels2 >> 16) & 0xff;
2579 bval2 = (pixels2 >> 8) & 0xff;
2580 pixel = (rval1 << 24 | gval1 << 16 | bval1 << 8);
2581 *(lined + jd) = pixel;
2582 *(linedp + jd) = pixel;
2583 pixel = ((((rval1 + rval2) << 23) & 0xff000000) |
2584 (((gval1 + gval2) << 15) & 0x00ff0000) |
2585 (((bval1 + bval2) << 7) & 0x0000ff00));
2586 *(lined + jd + 1) = pixel;
2587 *(linedp + jd + 1) = pixel;
2592 pixel = (rval1 << 24 | gval1 << 16 | bval1 << 8);
2593 *(lined + 2 * wsm) = pixel;
2594 *(lined + 2 * wsm + 1) = pixel;
2595 *(linedp + 2 * wsm) = pixel;
2596 *(linedp + 2 * wsm + 1) = pixel;
2651 l_uint32 *lines, *lined;
2666 for (i = 0; i < hsm; i++) {
2667 lines = datas + i * wpls;
2668 lined = datad + 2 * i * wpld;
2673 lines = datas + hsm * wpls;
2674 lined = datad + 2 * hsm * wpld;
2696 l_int32 lastlineflag)
2698 l_int32 j, jd, wsm, w;
2699 l_uint32 sval1, sval2, sval3, sval4;
2700 l_uint32 *linesp, *linedp;
2701 l_uint32 words, wordsp, wordd, worddp;
2705 if (lastlineflag == 0) {
2706 linesp = lines + wpls;
2707 linedp = lined + wpld;
2712 sval2 = (words >> 24) & 0xff;
2713 sval4 = (wordsp >> 24) & 0xff;
2714 for (j = 0, jd = 0, w = 0; j + 3 < wsm; j += 4, jd += 8, w++) {
2720 sval2 = (words >> 16) & 0xff;
2722 sval4 = (wordsp >> 16) & 0xff;
2723 wordd = (sval1 << 24) | (((sval1 + sval2) >> 1) << 16);
2724 worddp = (((sval1 + sval3) >> 1) << 24) |
2725 (((sval1 + sval2 + sval3 + sval4) >> 2) << 16);
2728 sval2 = (words >> 8) & 0xff;
2730 sval4 = (wordsp >> 8) & 0xff;
2731 wordd |= (sval1 << 8) | ((sval1 + sval2) >> 1);
2732 worddp |= (((sval1 + sval3) >> 1) << 8) |
2733 ((sval1 + sval2 + sval3 + sval4) >> 2);
2734 lined[w * 2] = wordd;
2735 linedp[w * 2] = worddp;
2738 sval2 = words & 0xff;
2740 sval4 = wordsp & 0xff;
2741 wordd = (sval1 << 24) |
2742 (((sval1 + sval2) >> 1) << 16);
2743 worddp = (((sval1 + sval3) >> 1) << 24) |
2744 (((sval1 + sval2 + sval3 + sval4) >> 2) << 16);
2747 words = lines[w + 1];
2748 wordsp = linesp[w + 1];
2750 sval2 = (words >> 24) & 0xff;
2752 sval4 = (wordsp >> 24) & 0xff;
2753 wordd |= (sval1 << 8) |
2754 ((sval1 + sval2) >> 1);
2755 worddp |= (((sval1 + sval3) >> 1) << 8) |
2756 ((sval1 + sval2 + sval3 + sval4) >> 2);
2757 lined[w * 2 + 1] = wordd;
2758 linedp[w * 2 + 1] = worddp;
2762 for (; j < wsm; j++, jd += 2) {
2771 (sval1 + sval2 + sval3 + sval4) / 4);
2781 #define CHECK_BYTE(a, b, c) if (GET_DATA_BYTE(a, b) != c) {\
2782 lept_stderr("Error: mismatch at %d, %d vs %d\n", \
2783 j, GET_DATA_BYTE(a, b), c); }
2787 for (j = 0, jd = 0; j < wsm; j++, jd += 2) {
2792 CHECK_BYTE(lined, jd, sval1);
2793 CHECK_BYTE(lined, jd + 1, (sval1 + sval2) / 2);
2794 CHECK_BYTE(linedp, jd, (sval1 + sval3) / 2);
2795 CHECK_BYTE(linedp, jd + 1,
2796 (sval1 + sval2 + sval3 + sval4) / 4);
2800 CHECK_BYTE(lined, 2 * wsm, sval1);
2801 CHECK_BYTE(lined, 2 * wsm + 1, sval1);
2802 CHECK_BYTE(linedp, 2 * wsm, (sval1 + sval3) / 2);
2803 CHECK_BYTE(linedp, 2 * wsm + 1, (sval1 + sval3) / 2);
2807 linedp = lined + wpld;
2809 for (j = 0, jd = 0; j < wsm; j++, jd += 2) {
2892 l_uint32 *lines, *lined;
2905 for (i = 0; i < hsm; i++) {
2906 lines = datas + i * wpls;
2907 lined = datad + 4 * i * wpld;
2912 lines = datas + hsm * wpls;
2913 lined = datad + 4 * hsm * wpld;
2935 l_int32 lastlineflag)
2937 l_int32 j, jd, wsm, wsm4;
2938 l_int32 s1, s2, s3, s4, s1t, s2t, s3t, s4t;
2939 l_uint32 *linesp, *linedp1, *linedp2, *linedp3;
2944 if (lastlineflag == 0) {
2945 linesp = lines + wpls;
2946 linedp1 = lined + wpld;
2947 linedp2 = lined + 2 * wpld;
2948 linedp3 = lined + 3 * wpld;
2951 for (j = 0, jd = 0; j < wsm; j++, jd += 4) {
2965 SET_DATA_BYTE(linedp1, jd + 1, (9*s1 + s2t + s3t + s4) / 16);
2967 SET_DATA_BYTE(linedp1, jd + 3, (s1t + 9*s2 + s3 + s4t) / 16);
2973 SET_DATA_BYTE(linedp3, jd + 1, (s1t + s2 + 9*s3 + s4t) / 16);
2975 SET_DATA_BYTE(linedp3, jd + 3, (s1 + s2t + s3t + 9*s4) / 16);
2998 linedp1 = lined + wpld;
2999 linedp2 = lined + 2 * wpld;
3000 linedp3 = lined + 3 * wpld;
3002 for (j = 0, jd = 0; j < wsm; j++, jd += 4) {
3075 l_int32 xs, prevxs, sval;
3076 l_int32 *srow, *scol;
3078 l_uint32 *lines, *prevlines, *lined, *prevlined;
3079 l_float32 wratio, hratio;
3081 PROCNAME(
"scaleBySamplingLow");
3083 if (d != 2 && d != 4 && d !=8 && d != 16 && d != 32)
3084 return ERROR_INT(
"pixel depth not supported", procName, 1);
3087 memset(datad, 0, 4LL * hd * wpld);
3091 if ((srow = (l_int32 *)LEPT_CALLOC(hd,
sizeof(l_int32))) == NULL)
3092 return ERROR_INT(
"srow not made", procName, 1);
3093 if ((scol = (l_int32 *)LEPT_CALLOC(wd,
sizeof(l_int32))) == NULL) {
3095 return ERROR_INT(
"scol not made", procName, 1);
3098 wratio = (l_float32)ws / (l_float32)wd;
3099 hratio = (l_float32)hs / (l_float32)hd;
3100 for (i = 0; i < hd; i++)
3101 srow[i] = L_MIN((l_int32)(hratio * i + 0.5), hs - 1);
3102 for (j = 0; j < wd; j++)
3103 scol[j] = L_MIN((l_int32)(wratio * j + 0.5), ws - 1);
3106 for (i = 0; i < hd; i++) {
3107 lines = datas + srow[i] * wpls;
3108 lined = datad + i * wpld;
3109 if (lines != prevlines) {
3114 for (j = 0; j < wd; j++) {
3124 }
else if (d == 4) {
3125 for (j = 0; j < wd; j++) {
3135 }
else if (d == 8) {
3136 for (j = 0; j < wd; j++) {
3146 }
else if (d == 16) {
3147 for (j = 0; j < wd; j++) {
3158 for (j = 0; j < wd; j++) {
3170 prevlined = lined - wpld;
3171 memcpy(lined, prevlined, 4 * wpld);
3208 l_int32 i, j, m, n, xstart;
3209 l_int32 val, rval, gval, bval;
3210 l_int32 *srow, *scol;
3211 l_uint32 *lines, *lined, *line, *ppixel;
3213 l_float32 wratio, hratio, norm;
3215 PROCNAME(
"scaleSmoothLow");
3218 memset(datad, 0, 4LL * wpld * hd);
3225 if ((srow = (l_int32 *)LEPT_CALLOC(hd,
sizeof(l_int32))) == NULL)
3226 return ERROR_INT(
"srow not made", procName, 1);
3227 if ((scol = (l_int32 *)LEPT_CALLOC(wd,
sizeof(l_int32))) == NULL) {
3229 return ERROR_INT(
"scol not made", procName, 1);
3232 norm = 1. / (l_float32)(size * size);
3233 wratio = (l_float32)ws / (l_float32)wd;
3234 hratio = (l_float32)hs / (l_float32)hd;
3235 for (i = 0; i < hd; i++)
3236 srow[i] = L_MIN((l_int32)(hratio * i), hs - size);
3237 for (j = 0; j < wd; j++)
3238 scol[j] = L_MIN((l_int32)(wratio * j), ws - size);
3242 for (i = 0; i < hd; i++) {
3243 lines = datas + srow[i] * wpls;
3244 lined = datad + i * wpld;
3245 for (j = 0; j < wd; j++) {
3248 for (m = 0; m < size; m++) {
3249 line = lines + m * wpls;
3250 for (n = 0; n < size; n++) {
3254 val = (l_int32)((l_float32)val * norm);
3259 for (i = 0; i < hd; i++) {
3260 lines = datas + srow[i] * wpls;
3261 lined = datad + i * wpld;
3262 for (j = 0; j < wd; j++) {
3264 rval = gval = bval = 0;
3265 for (m = 0; m < size; m++) {
3266 ppixel = lines + m * wpls + xstart;
3267 for (n = 0; n < size; n++) {
3268 pixel = *(ppixel + n);
3269 rval += (pixel >> L_RED_SHIFT) & 0xff;
3270 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3271 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3274 rval = (l_int32)((l_float32)rval * norm);
3275 gval = (l_int32)((l_float32)gval * norm);
3276 bval = (l_int32)((l_float32)bval * norm);
3308 l_int32 i, j, val, rval, gval, bval;
3309 l_uint32 *lines, *lined;
3315 for (i = 0; i < hd; i++) {
3316 lines = datas + 2 * i * wpls;
3317 lined = datad + i * wpld;
3318 for (j = 0; j < wd; j++) {
3320 pixel = *(lines + 2 * j);
3321 rval = (pixel >> L_RED_SHIFT) & 0xff;
3322 gval = (pixel >> L_GREEN_SHIFT) & 0xff;
3323 bval = (pixel >> L_BLUE_SHIFT) & 0xff;
3324 pixel = *(lines + 2 * j + 1);
3325 rval += (pixel >> L_RED_SHIFT) & 0xff;
3326 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3327 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3328 pixel = *(lines + wpls + 2 * j);
3329 rval += (pixel >> L_RED_SHIFT) & 0xff;
3330 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3331 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3332 pixel = *(lines + wpls + 2 * j + 1);
3333 rval += (pixel >> L_RED_SHIFT) & 0xff;
3334 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3335 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3337 val = (l_int32)(rwt * rval + gwt * gval + bwt * bval);
3372 l_int32 i, j, k, m, wm2, hm2;
3373 l_int32 area00, area10, area01, area11, areal, arear, areat, areab;
3376 l_int32 xup, yup, xuf, yuf;
3377 l_int32 xlp, ylp, xlf, ylf;
3378 l_int32 delx, dely, area;
3379 l_int32 v00r, v00g, v00b;
3380 l_int32 v01r, v01g, v01b;
3381 l_int32 v10r, v10g, v10b;
3382 l_int32 v11r, v11g, v11b;
3383 l_int32 vinr, ving, vinb;
3384 l_int32 vmidr, vmidg, vmidb;
3385 l_int32 rval, gval, bval;
3386 l_uint32 pixel00, pixel10, pixel01, pixel11, pixel;
3387 l_uint32 *lines, *lined;
3394 scx = 16. * (l_float32)ws / (l_float32)wd;
3395 scy = 16. * (l_float32)hs / (l_float32)hd;
3400 for (i = 0; i < hd; i++) {
3401 yu = (l_int32)(scy * i);
3402 yl = (l_int32)(scy * (i + 1.0));
3408 lined = datad + i * wpld;
3409 lines = datas + yup * wpls;
3410 for (j = 0; j < wd; j++) {
3411 xu = (l_int32)(scx * j);
3412 xl = (l_int32)(scx * (j + 1.0));
3420 if (xlp > wm2 || ylp > hm2) {
3421 *(lined + j) = *(lines + xup);
3428 area = ((16 - xuf) + 16 * (delx - 1) + xlf) *
3429 ((16 - yuf) + 16 * (dely - 1) + ylf);
3432 pixel00 = *(lines + xup);
3433 pixel10 = *(lines + xlp);
3434 pixel01 = *(lines + dely * wpls + xup);
3435 pixel11 = *(lines + dely * wpls + xlp);
3436 area00 = (16 - xuf) * (16 - yuf);
3437 area10 = xlf * (16 - yuf);
3438 area01 = (16 - xuf) * ylf;
3440 v00r = area00 * ((pixel00 >> L_RED_SHIFT) & 0xff);
3441 v00g = area00 * ((pixel00 >> L_GREEN_SHIFT) & 0xff);
3442 v00b = area00 * ((pixel00 >> L_BLUE_SHIFT) & 0xff);
3443 v10r = area10 * ((pixel10 >> L_RED_SHIFT) & 0xff);
3444 v10g = area10 * ((pixel10 >> L_GREEN_SHIFT) & 0xff);
3445 v10b = area10 * ((pixel10 >> L_BLUE_SHIFT) & 0xff);
3446 v01r = area01 * ((pixel01 >> L_RED_SHIFT) & 0xff);
3447 v01g = area01 * ((pixel01 >> L_GREEN_SHIFT) & 0xff);
3448 v01b = area01 * ((pixel01 >> L_BLUE_SHIFT) & 0xff);
3449 v11r = area11 * ((pixel11 >> L_RED_SHIFT) & 0xff);
3450 v11g = area11 * ((pixel11 >> L_GREEN_SHIFT) & 0xff);
3451 v11b = area11 * ((pixel11 >> L_BLUE_SHIFT) & 0xff);
3452 vinr = ving = vinb = 0;
3453 for (k = 1; k < dely; k++) {
3454 for (m = 1; m < delx; m++) {
3455 pixel = *(lines + k * wpls + xup + m);
3456 vinr += 256 * ((pixel >> L_RED_SHIFT) & 0xff);
3457 ving += 256 * ((pixel >> L_GREEN_SHIFT) & 0xff);
3458 vinb += 256 * ((pixel >> L_BLUE_SHIFT) & 0xff);
3461 vmidr = vmidg = vmidb = 0;
3462 areal = (16 - xuf) * 16;
3464 areat = 16 * (16 - yuf);
3466 for (k = 1; k < dely; k++) {
3467 pixel = *(lines + k * wpls + xup);
3468 vmidr += areal * ((pixel >> L_RED_SHIFT) & 0xff);
3469 vmidg += areal * ((pixel >> L_GREEN_SHIFT) & 0xff);
3470 vmidb += areal * ((pixel >> L_BLUE_SHIFT) & 0xff);
3472 for (k = 1; k < dely; k++) {
3473 pixel = *(lines + k * wpls + xlp);
3474 vmidr += arear * ((pixel >> L_RED_SHIFT) & 0xff);
3475 vmidg += arear * ((pixel >> L_GREEN_SHIFT) & 0xff);
3476 vmidb += arear * ((pixel >> L_BLUE_SHIFT) & 0xff);
3478 for (m = 1; m < delx; m++) {
3479 pixel = *(lines + xup + m);
3480 vmidr += areat * ((pixel >> L_RED_SHIFT) & 0xff);
3481 vmidg += areat * ((pixel >> L_GREEN_SHIFT) & 0xff);
3482 vmidb += areat * ((pixel >> L_BLUE_SHIFT) & 0xff);
3484 for (m = 1; m < delx; m++) {
3485 pixel = *(lines + dely * wpls + xup + m);
3486 vmidr += areab * ((pixel >> L_RED_SHIFT) & 0xff);
3487 vmidg += areab * ((pixel >> L_GREEN_SHIFT) & 0xff);
3488 vmidb += areab * ((pixel >> L_BLUE_SHIFT) & 0xff);
3492 rval = (v00r + v01r + v10r + v11r + vinr + vmidr + 128) / area;
3493 gval = (v00g + v01g + v10g + v11g + ving + vmidg + 128) / area;
3494 bval = (v00b + v01b + v10b + v11b + vinb + vmidb + 128) / area;
3496 if (rval > 255)
lept_stderr(
"rval ovfl: %d\n", rval);
3497 if (gval > 255)
lept_stderr(
"gval ovfl: %d\n", gval);
3498 if (bval > 255)
lept_stderr(
"bval ovfl: %d\n", bval);
3530 l_int32 i, j, k, m, wm2, hm2;
3533 l_int32 xup, yup, xuf, yuf;
3534 l_int32 xlp, ylp, xlf, ylf;
3535 l_int32 delx, dely, area;
3543 l_uint32 *lines, *lined;
3550 scx = 16. * (l_float32)ws / (l_float32)wd;
3551 scy = 16. * (l_float32)hs / (l_float32)hd;
3556 for (i = 0; i < hd; i++) {
3557 yu = (l_int32)(scy * i);
3558 yl = (l_int32)(scy * (i + 1.0));
3564 lined = datad + i * wpld;
3565 lines = datas + yup * wpls;
3566 for (j = 0; j < wd; j++) {
3567 xu = (l_int32)(scx * j);
3568 xl = (l_int32)(scx * (j + 1.0));
3576 if (xlp > wm2 || ylp > hm2) {
3584 area = ((16 - xuf) + 16 * (delx - 1) + xlf) *
3585 ((16 - yuf) + 16 * (dely - 1) + ylf);
3590 v01 = (16 - xuf) * ylf *
GET_DATA_BYTE(lines + dely * wpls, xup);
3592 for (vin = 0, k = 1; k < dely; k++) {
3593 for (m = 1; m < delx; m++) {
3597 for (vmid = 0, k = 1; k < dely; k++)
3598 vmid += (16 - xuf) * 16 *
GET_DATA_BYTE(lines + k * wpls, xup);
3599 for (k = 1; k < dely; k++)
3601 for (m = 1; m < delx; m++)
3603 for (m = 1; m < delx; m++)
3604 vmid += 16 * ylf *
GET_DATA_BYTE(lines + dely * wpls, xup + m);
3605 val = (v00 + v01 + v10 + v11 + vin + vmid + 128) / area;
3607 if (val > 255)
lept_stderr(
"val overflow: %d\n", val);
3636 l_int32 i, j, val, rval, gval, bval;
3637 l_uint32 *lines, *lined;
3641 for (i = 0; i < hd; i++) {
3642 lines = datas + 2 * i * wpls;
3643 lined = datad + i * wpld;
3644 for (j = 0; j < wd; j++) {
3655 for (i = 0; i < hd; i++) {
3656 lines = datas + 2 * i * wpls;
3657 lined = datad + i * wpld;
3658 for (j = 0; j < wd; j++) {
3660 pixel = *(lines + 2 * j);
3661 rval = (pixel >> L_RED_SHIFT) & 0xff;
3662 gval = (pixel >> L_GREEN_SHIFT) & 0xff;
3663 bval = (pixel >> L_BLUE_SHIFT) & 0xff;
3664 pixel = *(lines + 2 * j + 1);
3665 rval += (pixel >> L_RED_SHIFT) & 0xff;
3666 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3667 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3668 pixel = *(lines + wpls + 2 * j);
3669 rval += (pixel >> L_RED_SHIFT) & 0xff;
3670 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3671 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3672 pixel = *(lines + wpls + 2 * j + 1);
3673 rval += (pixel >> L_RED_SHIFT) & 0xff;
3674 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3675 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3677 *(lined + j) = pixel;
3700 scaleBinaryLow(l_uint32 *datad,
3710 l_int32 xs, prevxs, sval;
3711 l_int32 *srow, *scol;
3712 l_uint32 *lines, *prevlines, *lined, *prevlined;
3713 l_float32 wratio, hratio;
3715 PROCNAME(
"scaleBinaryLow");
3718 memset(datad, 0, 4LL * hd * wpld);
3722 if ((srow = (l_int32 *)LEPT_CALLOC(hd,
sizeof(l_int32))) == NULL)
3723 return ERROR_INT(
"srow not made", procName, 1);
3724 if ((scol = (l_int32 *)LEPT_CALLOC(wd,
sizeof(l_int32))) == NULL) {
3726 return ERROR_INT(
"scol not made", procName, 1);
3729 wratio = (l_float32)ws / (l_float32)wd;
3730 hratio = (l_float32)hs / (l_float32)hd;
3731 for (i = 0; i < hd; i++)
3732 srow[i] = L_MIN((l_int32)(hratio * i + 0.5), hs - 1);
3733 for (j = 0; j < wd; j++)
3734 scol[j] = L_MIN((l_int32)(wratio * j + 0.5), ws - 1);
3739 for (i = 0; i < hd; i++) {
3740 lines = datas + srow[i] * wpls;
3741 lined = datad + i * wpld;
3742 if (lines != prevlines) {
3743 for (j = 0; j < wd; j++) {
3755 prevlined = lined - wpld;
3756 memcpy(lined, prevlined, 4 * wpld);
#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 * pixUnsharpMasking(PIX *pixs, l_int32 halfwidth, l_float32 fract)
pixUnsharpMasking()
void ditherToBinaryLineLow(l_uint32 *lined, l_int32 w, l_uint32 *bufs1, l_uint32 *bufs2, l_int32 lowerclip, l_int32 upperclip, l_int32 lastlineflag)
ditherToBinaryLineLow()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
l_ok pixCopySpp(PIX *pixd, const PIX *pixs)
pixCopySpp()
PIX * pixCopy(PIX *pixd, const PIX *pixs)
pixCopy()
l_ok pixCopyColormap(PIX *pixd, const PIX *pixs)
pixCopyColormap()
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 pixSetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 val)
pixSetPixel()
l_ok pixGetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval)
pixGetPixel()
PIX * pixCreateRGBImage(PIX *pixr, PIX *pixg, PIX *pixb)
pixCreateRGBImage()
l_ok composeRGBPixel(l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 *ppixel)
composeRGBPixel()
@ REMOVE_CMAP_BASED_ON_SRC
PIX * pixConvertTo8Or32(PIX *pixs, l_int32 copyflag, l_int32 warnflag)
pixConvertTo8Or32()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
static l_int32 scaleBySamplingLow(l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 d, l_int32 wpls)
scaleBySamplingLow()
PIX * pixScaleToResolution(PIX *pixs, l_float32 target, l_float32 assumed, l_float32 *pscalefact)
pixScaleToResolution()
PIX * pixScaleRGBToGrayFast(PIX *pixs, l_int32 factor, l_int32 color)
pixScaleRGBToGrayFast()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
static void scaleAreaMapLow2(l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 d, l_int32 wpls)
scaleAreaMapLow2()
PIX * pixScaleGray4xLIThresh(PIX *pixs, l_int32 thresh)
pixScaleGray4xLIThresh()
static void scaleGray4xLILineLow(l_uint32 *lined, l_int32 wpld, l_uint32 *lines, l_int32 ws, l_int32 wpls, l_int32 lastlineflag)
scaleGray4xLILineLow()
static void scaleGray2xLILineLow(l_uint32 *lined, l_int32 wpld, l_uint32 *lines, l_int32 ws, l_int32 wpls, l_int32 lastlineflag)
scaleGray2xLILineLow()
PIX * pixScaleGrayLI(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleGrayLI()
PIX * pixScaleGeneral(PIX *pixs, l_float32 scalex, l_float32 scaley, l_float32 sharpfract, l_int32 sharpwidth)
pixScaleGeneral()
PIX * pixScaleColor2xLI(PIX *pixs)
pixScaleColor2xLI()
PIX * pixScaleRGBToGray2(PIX *pixs, l_float32 rwt, l_float32 gwt, l_float32 bwt)
pixScaleRGBToGray2()
PIX * pixScaleColor4xLI(PIX *pixs)
pixScaleColor4xLI()
static void scaleColorAreaMapLow(l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleColorAreaMapLow()
static void scaleGrayLILow(l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleGrayLILow()
PIX * pixScaleAreaMap(PIX *pix, l_float32 scalex, l_float32 scaley)
pixScaleAreaMap()
PIX * pixScaleRGBToBinaryFast(PIX *pixs, l_int32 factor, l_int32 thresh)
pixScaleRGBToBinaryFast()
PIX * pixScaleToSizeRel(PIX *pixs, l_int32 delw, l_int32 delh)
pixScaleToSizeRel()
PIX * pixScaleToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleToSize()
PIX * pixScaleLI(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleLI()
static void scaleColorLILow(l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleColorLILow()
PIX * pixScaleGray2xLI(PIX *pixs)
pixScaleGray2xLI()
PIX * pixScaleBinary(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleBinary()
static l_int32 scaleSmoothLow(l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 d, l_int32 wpls, l_int32 size)
scaleSmoothLow()
PIX * pixScaleGrayToBinaryFast(PIX *pixs, l_int32 factor, l_int32 thresh)
pixScaleGrayToBinaryFast()
PIX * pixScaleSmooth(PIX *pix, l_float32 scalex, l_float32 scaley)
pixScaleSmooth()
PIX * pixScaleGray2xLIThresh(PIX *pixs, l_int32 thresh)
pixScaleGray2xLIThresh()
PIX * pixScaleAreaMap2(PIX *pix)
pixScaleAreaMap2()
static void scaleColor2xLILow(l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleColor2xLILow()
static void scaleGray4xLILow(l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleGray4xLILow()
PIX * pixScaleBySamplingToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleBySamplingToSize()
PIX * pixScaleAreaMapToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleAreaMapToSize()
PIX * pixScaleGray4xLI(PIX *pixs)
pixScaleGray4xLI()
PIX * pixScaleByIntSampling(PIX *pixs, l_int32 factor)
pixScaleByIntSampling()
static void scaleRGBToGray2Low(l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_float32 rwt, l_float32 gwt, l_float32 bwt)
scaleRGBToGray2Low()
static void scaleGray2xLILow(l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleGray2xLILow()
static void scaleGrayAreaMapLow(l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleGrayAreaMapLow()
PIX * pixScaleColorLI(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleColorLI()
PIX * pixScaleSmoothToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleSmoothToSize()
static void scaleColor2xLILineLow(l_uint32 *lined, l_int32 wpld, l_uint32 *lines, l_int32 ws, l_int32 wpls, l_int32 lastlineflag)
scaleColor2xLILineLow()
PIX * pixScaleGray4xLIDither(PIX *pixs)
pixScaleGray4xLIDither()
PIX * pixScaleBySampling(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleBySampling()
PIX * pixScaleGray2xLIDither(PIX *pixs)
pixScaleGray2xLIDither()
l_ok pixScaleAndTransferAlpha(PIX *pixd, PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleAndTransferAlpha()
void lept_stderr(const char *fmt,...)
lept_stderr()