117#include <config_auto.h>
121#include "allheaders.h"
124 l_int32 wpld, l_uint32 *datas, l_int32 ws,
125 l_int32 hs, l_int32 wpls);
126static void scaleGrayLILow(l_uint32 *datad, l_int32 wd, l_int32 hd,
127 l_int32 wpld, l_uint32 *datas, l_int32 ws,
128 l_int32 hs, l_int32 wpls);
130 l_int32 ws, l_int32 hs, l_int32 wpls);
132 l_uint32 *lines, l_int32 ws, l_int32 wpls,
133 l_int32 lastlineflag);
135 l_int32 ws, l_int32 hs, l_int32 wpls);
137 l_uint32 *lines, l_int32 ws, l_int32 wpls,
138 l_int32 lastlineflag);
140 l_int32 ws, l_int32 hs, l_int32 wpls);
142 l_uint32 *lines, l_int32 ws, l_int32 wpls,
143 l_int32 lastlineflag);
145 l_int32 wpld, l_uint32 *datas, l_int32 ws,
146 l_int32 hs, l_int32 d, l_int32 wpls,
147 l_float32 shiftx, l_float32 shifty);
148static l_int32
scaleSmoothLow(l_uint32 *datad, l_int32 wd, l_int32 hd,
149 l_int32 wpld, l_uint32 *datas, l_int32 ws,
150 l_int32 hs, l_int32 d, l_int32 wpls,
153 l_int32 wpld, l_uint32 *datas, l_int32 wpls,
154 l_float32 rwt, l_float32 gwt, l_float32 bwt);
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 ws,
160 l_int32 hs, l_int32 wpls);
162 l_int32 wpld, l_uint32 *datas, l_int32 d,
164static l_int32 scaleBinaryLow(l_uint32 *datad, l_int32 wd, l_int32 hd,
165 l_int32 wpld, l_uint32 *datas, l_int32 ws,
166 l_int32 hs, l_int32 wpls,
167 l_float32 shiftx, l_float32 shifty);
170#define DEBUG_OVERFLOW 0
171#define DEBUG_UNROLLING 0
259l_float32 maxscale, sharpfract;
262 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
265 maxscale = L_MAX(scalex, scaley);
266 sharpfract = (maxscale < 0.7) ? 0.2f : 0.4f;
267 sharpwidth = (maxscale < 0.7) ? 1 : 2;
289 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
291 if (delw == 0 && delh == 0)
292 return pixCopy(NULL, pixs);
294 pixGetDimensions(pixs, &w, &h, NULL);
297 if (wd <= 0 || hd <= 0)
298 return (
PIX *)ERROR_PTR(
"pix dimension reduced to 0", __func__, NULL);
328l_float32 scalex, scaley;
331 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
332 if (wd <= 0 && hd <= 0)
333 return (
PIX *)ERROR_PTR(
"neither wd nor hd > 0", __func__, NULL);
335 pixGetDimensions(pixs, &w, &h, NULL);
337 scaley = (l_float32)hd / (l_float32)h;
339 }
else if (hd <= 0) {
340 scalex = (l_float32)wd / (l_float32)w;
343 scalex = (l_float32)wd / (l_float32)w;
344 scaley = (l_float32)hd / (l_float32)h;
347 return pixScale(pixs, scalex, scaley);
364 l_float32 *pscalefact)
369 if (pscalefact) *pscalefact = 1.0;
371 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
373 return (
PIX *)ERROR_PTR(
"target resolution <= 0", __func__, NULL);
375 xres = pixGetXRes(pixs);
378 return pixCopy(NULL, pixs);
381 factor = target / (l_float32)xres;
382 if (pscalefact) *pscalefact = factor;
384 return pixScale(pixs, factor, factor);
422 l_float32 sharpfract,
426l_float32 maxscale, minscale;
427PIX *pix1, *pix2, *pixd;
430 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
431 d = pixGetDepth(pixs);
432 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 16 && d != 32)
433 return (
PIX *)ERROR_PTR(
"pixs not {1,2,4,8,16,32} bpp", __func__, NULL);
434 if (scalex <= 0.0 || scaley <= 0.0)
435 return (
PIX *)ERROR_PTR(
"scale factor <= 0", __func__, NULL);
436 if (scalex == 1.0 && scaley == 1.0)
437 return pixCopy(NULL, pixs);
443 if ((pix1 = pixConvertTo8Or32(pixs,
L_CLONE, 0)) == NULL)
444 return (
PIX *)ERROR_PTR(
"pix1 not made", __func__, NULL);
447 d = pixGetDepth(pix1);
448 maxscale = L_MAX(scalex, scaley);
449 minscale = L_MIN(scalex, scaley);
450 if (maxscale < 0.7) {
451 if (minscale < 0.02) {
456 if (maxscale > 0.2 && sharpfract > 0.0 && sharpwidth > 0) {
457 pixd = pixUnsharpMasking(pix2, sharpwidth, sharpfract);
459 pixd = pixClone(pix2);
467 if (maxscale < 1.4 && sharpfract > 0.0 && sharpwidth > 0) {
468 pixd = pixUnsharpMasking(pix2, sharpwidth, sharpfract);
470 pixd = pixClone(pix2);
476 pixCopyText(pixd, pixs);
477 pixCopyInputFormat(pixd, pixs);
518 if (!pixs || (pixGetDepth(pixs) == 1))
519 return (
PIX *)ERROR_PTR(
"pixs not defined or 1 bpp", __func__, NULL);
520 maxscale = L_MAX(scalex, scaley);
521 if (maxscale < 0.7) {
522 L_WARNING(
"scaling factors < 0.7; do regular scaling\n", __func__);
525 d = pixGetDepth(pixs);
526 if (d != 2 && d != 4 && d != 8 && d != 16 && d != 32)
527 return (
PIX *)ERROR_PTR(
"pixs not {2,4,8,16,32} bpp", __func__, NULL);
530 if ((pixt = pixConvertTo8Or32(pixs,
L_CLONE, 0)) == NULL)
531 return (
PIX *)ERROR_PTR(
"pixt not made", __func__, NULL);
533 d = pixGetDepth(pixt);
540 pixCopyInputFormat(pixd, pixs);
571l_int32 ws, hs, wpls, wd, hd, wpld;
572l_uint32 *datas, *datad;
576 if (!pixs || (pixGetDepth(pixs) != 32))
577 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", __func__, NULL);
578 maxscale = L_MAX(scalex, scaley);
579 if (maxscale < 0.7) {
580 L_WARNING(
"scaling factors < 0.7; do regular scaling\n", __func__);
585 if (scalex == 1.0 && scaley == 1.0)
586 return pixCopy(NULL, pixs);
587 if (scalex == 2.0 && scaley == 2.0)
589 if (scalex == 4.0 && scaley == 4.0)
593 pixGetDimensions(pixs, &ws, &hs, NULL);
594 datas = pixGetData(pixs);
595 wpls = pixGetWpl(pixs);
596 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
597 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
598 if ((pixd = pixCreate(wd, hd, 32)) == NULL)
599 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
600 pixCopyResolution(pixd, pixs);
601 pixScaleResolution(pixd, scalex, scaley);
602 datad = pixGetData(pixd);
603 wpld = pixGetWpl(pixd);
605 if (pixGetSpp(pixs) == 4)
606 pixScaleAndTransferAlpha(pixd, pixs, scalex, scaley);
608 pixCopyInputFormat(pixd, pixs);
631l_int32 ws, hs, wpls, wpld;
632l_uint32 *datas, *datad;
635 if (!pixs || (pixGetDepth(pixs) != 32))
636 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", __func__, NULL);
638 pixGetDimensions(pixs, &ws, &hs, NULL);
639 datas = pixGetData(pixs);
640 wpls = pixGetWpl(pixs);
641 if ((pixd = pixCreate(2 * ws, 2 * hs, 32)) == NULL)
642 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
643 pixCopyResolution(pixd, pixs);
644 pixScaleResolution(pixd, 2.0, 2.0);
645 datad = pixGetData(pixd);
646 wpld = pixGetWpl(pixd);
648 if (pixGetSpp(pixs) == 4)
649 pixScaleAndTransferAlpha(pixd, pixs, 2.0, 2.0);
651 pixCopyInputFormat(pixd, pixs);
676PIX *pixr, *pixg, *pixb;
677PIX *pixrs, *pixgs, *pixbs;
680 if (!pixs || (pixGetDepth(pixs) != 32))
681 return (
PIX *)ERROR_PTR(
"pixs undefined or not 32 bpp", __func__, NULL);
683 pixr = pixGetRGBComponent(pixs,
COLOR_RED);
693 if ((pixd = pixCreateRGBImage(pixrs, pixgs, pixbs)) == NULL) {
694 L_ERROR(
"pixd not made\n", __func__);
696 if (pixGetSpp(pixs) == 4)
697 pixScaleAndTransferAlpha(pixd, pixs, 4.0, 4.0);
698 pixCopyInputFormat(pixd, pixs);
770l_int32 ws, hs, wpls, wd, hd, wpld;
771l_uint32 *datas, *datad;
775 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
776 return (
PIX *)ERROR_PTR(
"pixs undefined, cmapped or not 8 bpp",
778 maxscale = L_MAX(scalex, scaley);
779 if (maxscale < 0.7) {
780 L_WARNING(
"scaling factors < 0.7; do regular scaling\n", __func__);
785 if (scalex == 1.0 && scaley == 1.0)
786 return pixCopy(NULL, pixs);
787 if (scalex == 2.0 && scaley == 2.0)
789 if (scalex == 4.0 && scaley == 4.0)
793 pixGetDimensions(pixs, &ws, &hs, NULL);
794 datas = pixGetData(pixs);
795 wpls = pixGetWpl(pixs);
796 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
797 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
798 if ((pixd = pixCreate(wd, hd, 8)) == NULL)
799 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
800 pixCopyText(pixd, pixs);
801 pixCopyResolution(pixd, pixs);
802 pixCopyInputFormat(pixd, pixs);
803 pixScaleResolution(pixd, scalex, scaley);
804 datad = pixGetData(pixd);
805 wpld = pixGetWpl(pixd);
827l_int32 ws, hs, wpls, wpld;
828l_uint32 *datas, *datad;
831 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
832 return (
PIX *)ERROR_PTR(
"pixs undefined, cmapped or not 8 bpp",
835 pixGetDimensions(pixs, &ws, &hs, NULL);
836 datas = pixGetData(pixs);
837 wpls = pixGetWpl(pixs);
838 if ((pixd = pixCreate(2 * ws, 2 * hs, 8)) == NULL)
839 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
840 pixCopyResolution(pixd, pixs);
841 pixCopyInputFormat(pixd, pixs);
842 pixScaleResolution(pixd, 2.0, 2.0);
843 datad = pixGetData(pixd);
844 wpld = pixGetWpl(pixd);
866l_int32 ws, hs, wpls, wpld;
867l_uint32 *datas, *datad;
870 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
871 return (
PIX *)ERROR_PTR(
"pixs undefined, cmapped or not 8 bpp",
874 pixGetDimensions(pixs, &ws, &hs, NULL);
875 datas = pixGetData(pixs);
876 wpls = pixGetWpl(pixs);
877 if ((pixd = pixCreate(4 * ws, 4 * hs, 8)) == NULL)
878 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
879 pixCopyResolution(pixd, pixs);
880 pixCopyInputFormat(pixd, pixs);
881 pixScaleResolution(pixd, 4.0, 4.0);
882 datad = pixGetData(pixd);
883 wpld = pixGetWpl(pixd);
910l_int32 i, ws, hs, hsm, wd, hd, wpls, wplb, wpld;
911l_uint32 *datas, *datad, *lines, *lined, *lineb;
914 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
915 return (
PIX *)ERROR_PTR(
"pixs undefined, not 8 bpp, or cmapped",
917 if (thresh < 0 || thresh > 256)
918 return (
PIX *)ERROR_PTR(
"thresh must be in [0, ... 256]",
921 pixGetDimensions(pixs, &ws, &hs, NULL);
925 datas = pixGetData(pixs);
926 wpls = pixGetWpl(pixs);
930 if ((lineb = (l_uint32 *)LEPT_CALLOC(2 * wplb,
sizeof(l_uint32))) == NULL)
931 return (
PIX *)ERROR_PTR(
"lineb not made", __func__, NULL);
934 if ((pixd = pixCreate(wd, hd, 1)) == NULL) {
936 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
938 pixCopyInputFormat(pixd, pixs);
939 pixCopyResolution(pixd, pixs);
940 pixScaleResolution(pixd, 2.0, 2.0);
941 wpld = pixGetWpl(pixd);
942 datad = pixGetData(pixd);
945 for (i = 0; i < hsm; i++) {
946 lines = datas + i * wpls;
947 lined = datad + 2 * i * wpld;
949 thresholdToBinaryLineLow(lined, wd, lineb, 8, thresh);
950 thresholdToBinaryLineLow(lined + wpld, wd, lineb + wplb, 8, thresh);
954 lines = datas + hsm * wpls;
955 lined = datad + 2 * hsm * wpld;
957 thresholdToBinaryLineLow(lined, wd, lineb, 8, thresh);
958 thresholdToBinaryLineLow(lined + wpld, wd, lineb + wplb, 8, thresh);
986l_int32 i, ws, hs, hsm, wd, hd, wpls, wplb, wpld;
987l_uint32 *datas, *datad;
989l_uint32 *lineb = NULL;
990l_uint32 *linebp = NULL;
991l_uint32 *bufs = NULL;
994 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
995 return (
PIX *)ERROR_PTR(
"pixs undefined, not 8 bpp, or cmapped",
998 pixGetDimensions(pixs, &ws, &hs, NULL);
1002 datas = pixGetData(pixs);
1003 wpls = pixGetWpl(pixs);
1006 if ((bufs = (l_uint32 *)LEPT_CALLOC(2 * wpls,
sizeof(l_uint32))) == NULL)
1007 return (
PIX *)ERROR_PTR(
"bufs not made", __func__, NULL);
1010 wplb = (wd + 3) / 4;
1011 if ((lineb = (l_uint32 *)LEPT_CALLOC(2 * wplb,
sizeof(l_uint32))) == NULL) {
1012 L_ERROR(
"lineb not made\n", __func__);
1017 if ((linebp = (l_uint32 *)LEPT_CALLOC(wplb,
sizeof(l_uint32))) == NULL) {
1018 L_ERROR(
"linebp not made\n", __func__);
1023 if ((pixd = pixCreate(wd, hd, 1)) == NULL) {
1024 L_ERROR(
"pixd not made\n", __func__);
1027 pixCopyInputFormat(pixd, pixs);
1028 pixCopyResolution(pixd, pixs);
1029 pixScaleResolution(pixd, 2.0, 2.0);
1030 wpld = pixGetWpl(pixd);
1031 datad = pixGetData(pixd);
1034 memcpy(bufs, datas, 4 * wpls);
1035 memcpy(bufs + wpls, datas + wpls, 4 * wpls);
1038 ditherToBinaryLineLow(lined, wd, lineb, lineb + wplb,
1043 for (i = 1; i < hsm; i++) {
1044 memcpy(bufs, datas + i * wpls, 4 * wpls);
1045 memcpy(bufs + wpls, datas + (i + 1) * wpls, 4 * wpls);
1046 memcpy(linebp, lineb + wplb, 4 * wplb);
1048 lined = datad + 2 * i * wpld;
1049 ditherToBinaryLineLow(lined - wpld, wd, linebp, lineb,
1052 ditherToBinaryLineLow(lined, wd, lineb, lineb + wplb,
1058 memcpy(bufs, datas + hsm * wpls, 4 * wpls);
1059 memcpy(linebp, lineb + wplb, 4 * wplb);
1061 ditherToBinaryLineLow(lined + wpld, wd, linebp, lineb,
1064 ditherToBinaryLineLow(lined + 2 * wpld, wd, lineb, lineb + wplb,
1067 ditherToBinaryLineLow(lined + 3 * wpld, wd, lineb + wplb, NULL,
1104l_int32 i, j, ws, hs, hsm, wd, hd, wpls, wplb, wpld;
1105l_uint32 *datas, *datad, *lines, *lined, *lineb;
1108 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
1109 return (
PIX *)ERROR_PTR(
"pixs undefined, not 8 bpp, or cmapped",
1111 if (thresh < 0 || thresh > 256)
1112 return (
PIX *)ERROR_PTR(
"thresh must be in [0, ... 256]",
1115 pixGetDimensions(pixs, &ws, &hs, NULL);
1119 datas = pixGetData(pixs);
1120 wpls = pixGetWpl(pixs);
1123 wplb = (wd + 3) / 4;
1124 if ((lineb = (l_uint32 *)LEPT_CALLOC(4 * wplb,
sizeof(l_uint32))) == NULL)
1125 return (
PIX *)ERROR_PTR(
"lineb not made", __func__, NULL);
1128 if ((pixd = pixCreate(wd, hd, 1)) == NULL) {
1130 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1132 pixCopyInputFormat(pixd, pixs);
1133 pixCopyResolution(pixd, pixs);
1134 pixScaleResolution(pixd, 4.0, 4.0);
1135 wpld = pixGetWpl(pixd);
1136 datad = pixGetData(pixd);
1139 for (i = 0; i < hsm; i++) {
1140 lines = datas + i * wpls;
1141 lined = datad + 4 * i * wpld;
1143 for (j = 0; j < 4; j++) {
1144 thresholdToBinaryLineLow(lined + j * wpld, wd,
1145 lineb + j * wplb, 8, thresh);
1150 lines = datas + hsm * wpls;
1151 lined = datad + 4 * hsm * wpld;
1153 for (j = 0; j < 4; j++) {
1154 thresholdToBinaryLineLow(lined + j * wpld, wd,
1155 lineb + j * wplb, 8, thresh);
1189l_int32 i, j, ws, hs, hsm, wd, hd, wpls, wplb, wpld;
1190l_uint32 *datas, *datad;
1192l_uint32 *lineb = NULL;
1193l_uint32 *linebp = NULL;
1194l_uint32 *bufs = NULL;
1197 if (!pixs || pixGetDepth(pixs) != 8 || pixGetColormap(pixs))
1198 return (
PIX *)ERROR_PTR(
"pixs undefined, not 8 bpp, or cmapped",
1201 pixGetDimensions(pixs, &ws, &hs, NULL);
1205 datas = pixGetData(pixs);
1206 wpls = pixGetWpl(pixs);
1209 if ((bufs = (l_uint32 *)LEPT_CALLOC(2 * wpls,
sizeof(l_uint32))) == NULL)
1210 return (
PIX *)ERROR_PTR(
"bufs not made", __func__, NULL);
1213 wplb = (wd + 3) / 4;
1214 if ((lineb = (l_uint32 *)LEPT_CALLOC(4 * wplb,
sizeof(l_uint32))) == NULL) {
1215 L_ERROR(
"lineb not made\n", __func__);
1220 if ((linebp = (l_uint32 *)LEPT_CALLOC(wplb,
sizeof(l_uint32))) == NULL) {
1221 L_ERROR(
"linebp not made\n", __func__);
1226 if ((pixd = pixCreate(wd, hd, 1)) == NULL) {
1227 L_ERROR(
"pixd not made\n", __func__);
1230 pixCopyInputFormat(pixd, pixs);
1231 pixCopyResolution(pixd, pixs);
1232 pixScaleResolution(pixd, 4.0, 4.0);
1233 wpld = pixGetWpl(pixd);
1234 datad = pixGetData(pixd);
1237 memcpy(bufs, datas, 4 * wpls);
1238 memcpy(bufs + wpls, datas + wpls, 4 * wpls);
1241 for (j = 0; j < 3; j++) {
1242 ditherToBinaryLineLow(lined + j * wpld, wd, lineb + j * wplb,
1243 lineb + (j + 1) * wplb,
1248 for (i = 1; i < hsm; i++) {
1249 memcpy(bufs, datas + i * wpls, 4 * wpls);
1250 memcpy(bufs + wpls, datas + (i + 1) * wpls, 4 * wpls);
1251 memcpy(linebp, lineb + 3 * wplb, 4 * wplb);
1253 lined = datad + 4 * i * wpld;
1254 ditherToBinaryLineLow(lined - wpld, wd, linebp, lineb,
1257 for (j = 0; j < 3; j++) {
1258 ditherToBinaryLineLow(lined + j * wpld, wd, lineb + j * wplb,
1259 lineb + (j + 1) * wplb,
1265 memcpy(bufs, datas + hsm * wpls, 4 * wpls);
1266 memcpy(linebp, lineb + 3 * wplb, 4 * wplb);
1268 lined = datad + 4 * hsm * wpld;
1269 ditherToBinaryLineLow(lined - wpld, wd, linebp, lineb,
1272 for (j = 0; j < 3; j++) {
1273 ditherToBinaryLineLow(lined + j * wpld, wd, lineb + j * wplb,
1274 lineb + (j + 1) * wplb,
1278 ditherToBinaryLineLow(lined + 3 * wpld, wd, lineb + 3 * wplb, NULL,
1322 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1351l_int32 ws, hs, d, wpls, wd, hd, wpld;
1352l_uint32 *datas, *datad;
1356 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1357 if (scalex <= 0.0 || scaley <= 0.0)
1358 return (
PIX *)ERROR_PTR(
"scale factor <= 0", __func__, NULL);
1359 if (scalex == 1.0 && scaley == 1.0)
1360 return pixCopy(NULL, pixs);
1361 if (shiftx != 0.0 && shiftx != 0.5)
1362 return (
PIX *)ERROR_PTR(
"shiftx != 0.0 or 0.5", __func__, NULL);
1363 if (shifty != 0.0 && shifty != 0.5)
1364 return (
PIX *)ERROR_PTR(
"shifty != 0.0 or 0.5", __func__, NULL);
1365 if ((d = pixGetDepth(pixs)) == 1)
1368 pixGetDimensions(pixs, &ws, &hs, NULL);
1369 datas = pixGetData(pixs);
1370 wpls = pixGetWpl(pixs);
1371 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
1372 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
1373 if ((pixd = pixCreate(wd, hd, d)) == NULL)
1374 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1375 pixCopyResolution(pixd, pixs);
1376 pixScaleResolution(pixd, scalex, scaley);
1377 pixCopyColormap(pixd, pixs);
1378 pixCopyText(pixd, pixs);
1379 pixCopyInputFormat(pixd, pixs);
1380 pixCopySpp(pixd, pixs);
1381 datad = pixGetData(pixd);
1382 wpld = pixGetWpl(pixd);
1385 if (d == 32 && pixGetSpp(pixs) == 4)
1386 pixScaleAndTransferAlpha(pixd, pixs, scalex, scaley);
1417l_float32 scalex, scaley;
1420 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1421 if (wd <= 0 && hd <= 0)
1422 return (
PIX *)ERROR_PTR(
"neither wd nor hd > 0", __func__, NULL);
1424 pixGetDimensions(pixs, &w, &h, NULL);
1426 scaley = (l_float32)hd / (l_float32)h;
1428 }
else if (hd <= 0) {
1429 scalex = (l_float32)wd / (l_float32)w;
1432 scalex = (l_float32)wd / (l_float32)w;
1433 scaley = (l_float32)hd / (l_float32)h;
1460 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1463 L_ERROR(
"factor must be >= 1; returning a copy\n", __func__);
1464 return pixCopy(NULL, pixs);
1467 scale = 1.f / (l_float32)factor;
1498l_int32 byteval, shift;
1499l_int32 i, j, ws, hs, wd, hd, wpls, wpld;
1500l_uint32 *datas, *words, *datad, *lined;
1505 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1506 if (pixGetDepth(pixs) != 32)
1507 return (
PIX *)ERROR_PTR(
"depth not 32 bpp", __func__, NULL);
1509 return (
PIX *)ERROR_PTR(
"factor must be >= 1", __func__, NULL);
1512 shift = L_RED_SHIFT;
1514 shift = L_GREEN_SHIFT;
1516 shift = L_BLUE_SHIFT;
1518 return (
PIX *)ERROR_PTR(
"invalid color", __func__, NULL);
1520 pixGetDimensions(pixs, &ws, &hs, NULL);
1521 datas = pixGetData(pixs);
1522 wpls = pixGetWpl(pixs);
1526 if ((pixd = pixCreate(wd, hd, 8)) == NULL)
1527 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1528 pixCopyResolution(pixd, pixs);
1529 pixCopyInputFormat(pixd, pixs);
1530 scale = 1.f / (l_float32) factor;
1531 pixScaleResolution(pixd, scale, scale);
1532 datad = pixGetData(pixd);
1533 wpld = pixGetWpl(pixd);
1535 for (i = 0; i < hd; i++) {
1536 words = datas + i * factor * wpls;
1537 lined = datad + i * wpld;
1538 for (j = 0; j < wd; j++, words += factor) {
1539 byteval = ((*words) >> shift) & 0xff;
1572l_int32 i, j, ws, hs, wd, hd, wpls, wpld;
1573l_uint32 *datas, *words, *datad, *lined;
1578 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1580 return (
PIX *)ERROR_PTR(
"factor must be >= 1", __func__, NULL);
1581 if (pixGetDepth(pixs) != 32)
1582 return (
PIX *)ERROR_PTR(
"depth not 32 bpp", __func__, NULL);
1584 pixGetDimensions(pixs, &ws, &hs, NULL);
1585 datas = pixGetData(pixs);
1586 wpls = pixGetWpl(pixs);
1590 if ((pixd = pixCreate(wd, hd, 1)) == NULL)
1591 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1592 pixCopyResolution(pixd, pixs);
1593 pixCopyInputFormat(pixd, pixs);
1594 scale = 1. / (l_float32) factor;
1595 pixScaleResolution(pixd, scale, scale);
1596 datad = pixGetData(pixd);
1597 wpld = pixGetWpl(pixd);
1599 for (i = 0; i < hd; i++) {
1600 words = datas + i * factor * wpls;
1601 lined = datad + i * wpld;
1602 for (j = 0; j < wd; j++, words += factor) {
1603 byteval = ((*words) >> L_GREEN_SHIFT) & 0xff;
1604 if (byteval < thresh)
1636l_int32 i, j, ws, hs, wd, hd, wpls, wpld, sj;
1637l_uint32 *datas, *datad, *lines, *lined;
1642 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1644 return (
PIX *)ERROR_PTR(
"factor must be >= 1", __func__, NULL);
1645 if (pixGetDepth(pixs) != 8)
1646 return (
PIX *)ERROR_PTR(
"depth not 8 bpp", __func__, NULL);
1648 pixGetDimensions(pixs, &ws, &hs, NULL);
1649 datas = pixGetData(pixs);
1650 wpls = pixGetWpl(pixs);
1654 if ((pixd = pixCreate(wd, hd, 1)) == NULL)
1655 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1656 pixCopyResolution(pixd, pixs);
1657 pixCopyInputFormat(pixd, pixs);
1658 scale = 1.f / (l_float32) factor;
1659 pixScaleResolution(pixd, scale, scale);
1660 datad = pixGetData(pixd);
1661 wpld = pixGetWpl(pixd);
1663 for (i = 0; i < hd; i++) {
1664 lines = datas + i * factor * wpls;
1665 lined = datad + i * wpld;
1666 for (j = 0, sj = 0; j < wd; j++, sj += factor) {
1668 if (byteval < thresh)
1715l_int32 ws, hs, d, wd, hd, wpls, wpld, isize;
1717l_uint32 *datas, *datad;
1718l_float32 minscale, size;
1722 return (
PIX *)ERROR_PTR(
"pix not defined", __func__, NULL);
1723 if (scalex >= 0.7 || scaley >= 0.7) {
1724 L_WARNING(
"scaling factor not < 0.7; do regular scaling\n", __func__);
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", __func__, NULL);
1732 if ((pixs = pixConvertTo8Or32(pix,
L_CLONE, 0)) == NULL)
1733 return (
PIX *)ERROR_PTR(
"pixs not made", __func__, NULL);
1734 d = pixGetDepth(pixs);
1739 minscale = L_MIN(scalex, scaley);
1740 size = 1.0f / minscale;
1741 isize = L_MIN(10000, L_MAX(2, (l_int32)(size + 0.5)));
1743 pixGetDimensions(pixs, &ws, &hs, NULL);
1744 if ((ws < isize) || (hs < isize)) {
1745 pixd = pixCreate(1, 1, d);
1746 pixGetPixel(pixs, ws / 2, hs / 2, &val);
1747 pixSetPixel(pixd, 0, 0, val);
1748 L_WARNING(
"ridiculously small scaling factor %f\n", __func__, minscale);
1753 datas = pixGetData(pixs);
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", __func__, NULL);
1761 pixCopyResolution(pixd, pixs);
1762 pixCopyInputFormat(pixd, pixs);
1763 pixScaleResolution(pixd, scalex, scaley);
1764 datad = pixGetData(pixd);
1765 wpld = pixGetWpl(pixd);
1766 scaleSmoothLow(datad, wd, hd, wpld, datas, ws, hs, d, wpls, isize);
1767 if (d == 32 && pixGetSpp(pixs) == 4)
1768 pixScaleAndTransferAlpha(pixd, pixs, scalex, scaley);
1800l_float32 scalex, scaley;
1803 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1804 if (wd <= 0 && hd <= 0)
1805 return (
PIX *)ERROR_PTR(
"neither wd nor hd > 0", __func__, NULL);
1807 pixGetDimensions(pixs, &w, &h, NULL);
1809 scaley = (l_float32)hd / (l_float32)h;
1811 }
else if (hd <= 0) {
1812 scalex = (l_float32)wd / (l_float32)w;
1815 scalex = (l_float32)wd / (l_float32)w;
1816 scaley = (l_float32)hd / (l_float32)h;
1836l_int32 wd, hd, wpls, wpld;
1837l_uint32 *datas, *datad;
1841 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1842 if (pixGetDepth(pixs) != 32)
1843 return (
PIX *)ERROR_PTR(
"pixs not 32 bpp", __func__, NULL);
1844 if (rwt + gwt + bwt < 0.98 || rwt + gwt + bwt > 1.02)
1845 return (
PIX *)ERROR_PTR(
"sum of wts should be 1.0", __func__, NULL);
1847 wd = pixGetWidth(pixs) / 2;
1848 hd = pixGetHeight(pixs) / 2;
1849 wpls = pixGetWpl(pixs);
1850 datas = pixGetData(pixs);
1851 if ((pixd = pixCreate(wd, hd, 8)) == NULL)
1852 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1853 pixCopyResolution(pixd, pixs);
1854 pixCopyInputFormat(pixd, pixs);
1855 pixScaleResolution(pixd, 0.5, 0.5);
1856 wpld = pixGetWpl(pixd);
1857 datad = pixGetData(pixd);
1914l_int32 ws, hs, d, wd, hd, wpls, wpld;
1915l_uint32 *datas, *datad;
1916l_float32 maxscale, minscale;
1917PIX *pixs, *pixd, *pix1, *pix2, *pix3;
1920 return (
PIX *)ERROR_PTR(
"pix not defined", __func__, NULL);
1921 d = pixGetDepth(pix);
1922 if (d != 2 && d != 4 && d != 8 && d != 32)
1923 return (
PIX *)ERROR_PTR(
"pix not 2, 4, 8 or 32 bpp", __func__, NULL);
1925 minscale = L_MIN(scalex, scaley);
1926 if (minscale < 0.02) {
1927 L_WARNING(
"tiny scaling factor; using pixScaleSmooth()\n", __func__);
1931 maxscale = L_MAX(scalex, scaley);
1932 if (maxscale >= 0.7) {
1933 L_WARNING(
"scaling factor >= 0.7; do regular scaling\n", __func__);
1938 if (scalex == 0.5 && scaley == 0.5)
1940 if (scalex == 0.25 && scaley == 0.25) {
1946 if (scalex == 0.125 && scaley == 0.125) {
1954 if (scalex == 0.0625 && scaley == 0.0625) {
1969 if (scalex > 0.35 && scalex < 0.5) {
1979 if ((d == 2 || d == 4 || d == 8) && pixGetColormap(pix)) {
1980 L_WARNING(
"pix has colormap; removing\n", __func__);
1982 d = pixGetDepth(pixs);
1983 }
else if (d == 2 || d == 4) {
1984 pixs = pixConvertTo8(pix, FALSE);
1987 pixs = pixClone(pix);
1990 pixGetDimensions(pixs, &ws, &hs, NULL);
1991 datas = pixGetData(pixs);
1992 wpls = pixGetWpl(pixs);
1993 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
1994 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
1995 if (wd < 1 || hd < 1) {
1997 return (
PIX *)ERROR_PTR(
"pixd too small", __func__, NULL);
1999 if ((pixd = pixCreate(wd, hd, d)) == NULL) {
2001 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
2003 pixCopyInputFormat(pixd, pixs);
2004 pixCopyResolution(pixd, pixs);
2005 pixScaleResolution(pixd, scalex, scaley);
2006 datad = pixGetData(pixd);
2007 wpld = pixGetWpl(pixd);
2012 if (pixGetSpp(pixs) == 4)
2013 pixScaleAndTransferAlpha(pixd, pixs, scalex, scaley);
2043l_int32 wd, hd, d, wpls, wpld;
2044l_uint32 *datas, *datad;
2048 return (
PIX *)ERROR_PTR(
"pix not defined", __func__, NULL);
2049 d = pixGetDepth(pix);
2050 if (d != 2 && d != 4 && d != 8 && d != 32)
2051 return (
PIX *)ERROR_PTR(
"pix not 2, 4, 8 or 32 bpp", __func__, NULL);
2055 if ((d == 2 || d == 4 || d == 8) && pixGetColormap(pix)) {
2056 L_WARNING(
"pix has colormap; removing\n", __func__);
2058 d = pixGetDepth(pixs);
2059 }
else if (d == 2 || d == 4) {
2060 pixs = pixConvertTo8(pix, FALSE);
2063 pixs = pixClone(pix);
2066 wd = pixGetWidth(pixs) / 2;
2067 hd = pixGetHeight(pixs) / 2;
2068 datas = pixGetData(pixs);
2069 wpls = pixGetWpl(pixs);
2070 pixd = pixCreate(wd, hd, d);
2071 datad = pixGetData(pixd);
2072 wpld = pixGetWpl(pixd);
2073 pixCopyInputFormat(pixd, pixs);
2074 pixCopyResolution(pixd, pixs);
2075 pixScaleResolution(pixd, 0.5, 0.5);
2077 if (pixGetSpp(pixs) == 4)
2078 pixScaleAndTransferAlpha(pixd, pixs, 0.5, 0.5);
2109l_float32 scalex, scaley;
2112 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2113 if (wd <= 0 && hd <= 0)
2114 return (
PIX *)ERROR_PTR(
"neither wd nor hd > 0", __func__, NULL);
2116 pixGetDimensions(pixs, &w, &h, NULL);
2118 scaley = (l_float32)hd / (l_float32)h;
2120 }
else if (hd <= 0) {
2121 scalex = (l_float32)wd / (l_float32)w;
2124 scalex = (l_float32)wd / (l_float32)w;
2125 scaley = (l_float32)hd / (l_float32)h;
2163 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2164 if (pixGetDepth(pixs) != 1)
2165 return (
PIX *)ERROR_PTR(
"pixs must be 1 bpp", __func__, NULL);
2194l_int32 ws, hs, wpls, wd, hd, wpld;
2195l_uint32 *datas, *datad;
2199 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2200 if (pixGetDepth(pixs) != 1)
2201 return (
PIX *)ERROR_PTR(
"pixs must be 1 bpp", __func__, NULL);
2202 if (scalex <= 0.0 || scaley <= 0.0)
2203 return (
PIX *)ERROR_PTR(
"scale factor <= 0", __func__, NULL);
2204 if (scalex == 1.0 && scaley == 1.0)
2205 return pixCopy(NULL, pixs);
2206 if (shiftx != 0.0 && shiftx != 0.5)
2207 return (
PIX *)ERROR_PTR(
"shiftx != 0.0 or 0.5", __func__, NULL);
2208 if (shifty != 0.0 && shifty != 0.5)
2209 return (
PIX *)ERROR_PTR(
"shifty != 0.0 or 0.5", __func__, NULL);
2211 pixGetDimensions(pixs, &ws, &hs, NULL);
2212 datas = pixGetData(pixs);
2213 wpls = pixGetWpl(pixs);
2214 wd = (l_int32)(scalex * (l_float32)ws + 0.5);
2215 hd = (l_int32)(scaley * (l_float32)hs + 0.5);
2216 if ((pixd = pixCreate(wd, hd, 1)) == NULL)
2217 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
2218 pixCopyColormap(pixd, pixs);
2219 pixCopyText(pixd, pixs);
2220 pixCopyInputFormat(pixd, pixs);
2221 pixCopyResolution(pixd, pixs);
2222 pixScaleResolution(pixd, scalex, scaley);
2223 datad = pixGetData(pixd);
2224 wpld = pixGetWpl(pixd);
2225 scaleBinaryLow(datad, wd, hd, wpld, datas, ws, hs, wpls, shiftx, shifty);
2259l_int32 i, j, wm2, hm2;
2261l_int32 xp, yp, xf, yf;
2262l_uint32 v00r, v01r, v10r, v11r, v00g, v01g, v10g, v11g;
2263l_uint32 v00b, v01b, v10b, v11b, area00, area01, area10, area11;
2264l_uint32 pixels1, pixels2, pixels3, pixels4, pixel;
2265l_uint32 *lines, *lined;
2272 scx = 16.f * (l_float32)ws / (l_float32)wd;
2273 scy = 16.f * (l_float32)hs / (l_float32)hd;
2278 for (i = 0; i < hd; i++) {
2279 ypm = (l_int32)(scy * (l_float32)i);
2282 lined = datad + i * wpld;
2283 lines = datas + yp * wpls;
2284 for (j = 0; j < wd; j++) {
2285 xpm = (l_int32)(scx * (l_float32)j);
2294 pixels1 = *(lines + xp);
2296 if (xp > wm2 || yp > hm2) {
2297 if (yp > hm2 && xp <= wm2) {
2298 pixels2 = *(lines + xp + 1);
2301 }
else if (xp > wm2 && yp <= hm2) {
2303 pixels3 = *(lines + wpls + xp);
2306 pixels4 = pixels3 = pixels2 = pixels1;
2309 pixels2 = *(lines + xp + 1);
2310 pixels3 = *(lines + wpls + xp);
2311 pixels4 = *(lines + wpls + xp + 1);
2314 area00 = (16 - xf) * (16 - yf);
2315 area10 = xf * (16 - yf);
2316 area01 = (16 - xf) * yf;
2318 v00r = area00 * ((pixels1 >> L_RED_SHIFT) & 0xff);
2319 v00g = area00 * ((pixels1 >> L_GREEN_SHIFT) & 0xff);
2320 v00b = area00 * ((pixels1 >> L_BLUE_SHIFT) & 0xff);
2321 v10r = area10 * ((pixels2 >> L_RED_SHIFT) & 0xff);
2322 v10g = area10 * ((pixels2 >> L_GREEN_SHIFT) & 0xff);
2323 v10b = area10 * ((pixels2 >> L_BLUE_SHIFT) & 0xff);
2324 v01r = area01 * ((pixels3 >> L_RED_SHIFT) & 0xff);
2325 v01g = area01 * ((pixels3 >> L_GREEN_SHIFT) & 0xff);
2326 v01b = area01 * ((pixels3 >> L_BLUE_SHIFT) & 0xff);
2327 v11r = area11 * ((pixels4 >> L_RED_SHIFT) & 0xff);
2328 v11g = area11 * ((pixels4 >> L_GREEN_SHIFT) & 0xff);
2329 v11b = area11 * ((pixels4 >> L_BLUE_SHIFT) & 0xff);
2330 pixel = (((v00r + v10r + v01r + v11r + 128) << 16) & 0xff000000) |
2331 (((v00g + v10g + v01g + v11g + 128) << 8) & 0x00ff0000) |
2332 ((v00b + v10b + v01b + v11b + 128) & 0x0000ff00);
2333 *(lined + j) = pixel;
2364l_int32 i, j, wm2, hm2;
2366l_int32 xp, yp, xf, yf;
2367l_int32 v00, v01, v10, v11, v00_val, v01_val, v10_val, v11_val;
2369l_uint32 *lines, *lined;
2376 scx = 16.f * (l_float32)ws / (l_float32)wd;
2377 scy = 16.f * (l_float32)hs / (l_float32)hd;
2382 for (i = 0; i < hd; i++) {
2383 ypm = (l_int32)(scy * (l_float32)i);
2386 lined = datad + i * wpld;
2387 lines = datas + yp * wpls;
2388 for (j = 0; j < wd; j++) {
2389 xpm = (l_int32)(scx * (l_float32)j);
2398 if (xp > wm2 || yp > hm2) {
2399 if (yp > hm2 && xp <= wm2) {
2403 }
else if (xp > wm2 && yp <= hm2) {
2408 v10_val = v01_val = v11_val = v00_val;
2416 v00 = (16 - xf) * (16 - yf) * v00_val;
2417 v10 = xf * (16 - yf) * v10_val;
2418 v01 = (16 - xf) * yf * v01_val;
2419 v11 = xf * yf * v11_val;
2421 val = (l_uint8)((v00 + v01 + v10 + v11 + 128) / 256);
2480l_uint32 *lines, *lined;
2495 for (i = 0; i < hsm; i++) {
2496 lines = datas + i * wpls;
2497 lined = datad + 2 * i * wpld;
2502 lines = datas + hsm * wpls;
2503 lined = datad + 2 * hsm * wpld;
2525 l_int32 lastlineflag)
2528l_uint32 rval1, rval2, rval3, rval4, gval1, gval2, gval3, gval4;
2529l_uint32 bval1, bval2, bval3, bval4;
2530l_uint32 pixels1, pixels2, pixels3, pixels4, pixel;
2531l_uint32 *linesp, *linedp;
2535 if (lastlineflag == 0) {
2536 linesp = lines + wpls;
2537 linedp = lined + wpld;
2542 rval2 = pixels1 >> 24;
2543 gval2 = (pixels1 >> 16) & 0xff;
2544 bval2 = (pixels1 >> 8) & 0xff;
2545 rval4 = pixels3 >> 24;
2546 gval4 = (pixels3 >> 16) & 0xff;
2547 bval4 = (pixels3 >> 8) & 0xff;
2549 for (j = 0, jd = 0; j < wsm; j++, jd += 2) {
2558 pixels2 = *(lines + j + 1);
2559 pixels4 = *(linesp + j + 1);
2560 rval2 = pixels2 >> 24;
2561 gval2 = (pixels2 >> 16) & 0xff;
2562 bval2 = (pixels2 >> 8) & 0xff;
2563 rval4 = pixels4 >> 24;
2564 gval4 = (pixels4 >> 16) & 0xff;
2565 bval4 = (pixels4 >> 8) & 0xff;
2567 pixel = (rval1 << 24 | gval1 << 16 | bval1 << 8);
2568 *(lined + jd) = pixel;
2569 pixel = ((((rval1 + rval2) << 23) & 0xff000000) |
2570 (((gval1 + gval2) << 15) & 0x00ff0000) |
2571 (((bval1 + bval2) << 7) & 0x0000ff00));
2572 *(lined + jd + 1) = pixel;
2573 pixel = ((((rval1 + rval3) << 23) & 0xff000000) |
2574 (((gval1 + gval3) << 15) & 0x00ff0000) |
2575 (((bval1 + bval3) << 7) & 0x0000ff00));
2576 *(linedp + jd) = pixel;
2577 pixel = ((((rval1 + rval2 + rval3 + rval4) << 22) & 0xff000000) |
2578 (((gval1 + gval2 + gval3 + gval4) << 14) & 0x00ff0000) |
2579 (((bval1 + bval2 + bval3 + bval4) << 6) & 0x0000ff00));
2580 *(linedp + jd + 1) = pixel;
2589 pixel = (rval1 << 24 | gval1 << 16 | bval1 << 8);
2590 *(lined + 2 * wsm) = pixel;
2591 *(lined + 2 * wsm + 1) = pixel;
2592 pixel = ((((rval1 + rval3) << 23) & 0xff000000) |
2593 (((gval1 + gval3) << 15) & 0x00ff0000) |
2594 (((bval1 + bval3) << 7) & 0x0000ff00));
2595 *(linedp + 2 * wsm) = pixel;
2596 *(linedp + 2 * wsm + 1) = pixel;
2598 linedp = lined + wpld;
2600 rval2 = pixels2 >> 24;
2601 gval2 = (pixels2 >> 16) & 0xff;
2602 bval2 = (pixels2 >> 8) & 0xff;
2603 for (j = 0, jd = 0; j < wsm; j++, jd += 2) {
2607 pixels2 = *(lines + j + 1);
2608 rval2 = pixels2 >> 24;
2609 gval2 = (pixels2 >> 16) & 0xff;
2610 bval2 = (pixels2 >> 8) & 0xff;
2611 pixel = (rval1 << 24 | gval1 << 16 | bval1 << 8);
2612 *(lined + jd) = pixel;
2613 *(linedp + jd) = pixel;
2614 pixel = ((((rval1 + rval2) << 23) & 0xff000000) |
2615 (((gval1 + gval2) << 15) & 0x00ff0000) |
2616 (((bval1 + bval2) << 7) & 0x0000ff00));
2617 *(lined + jd + 1) = pixel;
2618 *(linedp + jd + 1) = pixel;
2623 pixel = (rval1 << 24 | gval1 << 16 | bval1 << 8);
2624 *(lined + 2 * wsm) = pixel;
2625 *(lined + 2 * wsm + 1) = pixel;
2626 *(linedp + 2 * wsm) = pixel;
2627 *(linedp + 2 * wsm + 1) = pixel;
2682l_uint32 *lines, *lined;
2697 for (i = 0; i < hsm; i++) {
2698 lines = datas + i * wpls;
2699 lined = datad + 2 * i * wpld;
2704 lines = datas + hsm * wpls;
2705 lined = datad + 2 * hsm * wpld;
2727 l_int32 lastlineflag)
2729l_int32 j, jd, wsm, w;
2730l_uint32 sval1, sval2, sval3, sval4;
2731l_uint32 *linesp, *linedp;
2732l_uint32 words, wordsp, wordd, worddp;
2736 if (lastlineflag == 0) {
2737 linesp = lines + wpls;
2738 linedp = lined + wpld;
2743 sval2 = (words >> 24) & 0xff;
2744 sval4 = (wordsp >> 24) & 0xff;
2745 for (j = 0, jd = 0, w = 0; j + 3 < wsm; j += 4, jd += 8, w++) {
2751 sval2 = (words >> 16) & 0xff;
2753 sval4 = (wordsp >> 16) & 0xff;
2754 wordd = (sval1 << 24) | (((sval1 + sval2) >> 1) << 16);
2755 worddp = (((sval1 + sval3) >> 1) << 24) |
2756 (((sval1 + sval2 + sval3 + sval4) >> 2) << 16);
2759 sval2 = (words >> 8) & 0xff;
2761 sval4 = (wordsp >> 8) & 0xff;
2762 wordd |= (sval1 << 8) | ((sval1 + sval2) >> 1);
2763 worddp |= (((sval1 + sval3) >> 1) << 8) |
2764 ((sval1 + sval2 + sval3 + sval4) >> 2);
2765 lined[w * 2] = wordd;
2766 linedp[w * 2] = worddp;
2769 sval2 = words & 0xff;
2771 sval4 = wordsp & 0xff;
2772 wordd = (sval1 << 24) |
2773 (((sval1 + sval2) >> 1) << 16);
2774 worddp = (((sval1 + sval3) >> 1) << 24) |
2775 (((sval1 + sval2 + sval3 + sval4) >> 2) << 16);
2778 words = lines[w + 1];
2779 wordsp = linesp[w + 1];
2781 sval2 = (words >> 24) & 0xff;
2783 sval4 = (wordsp >> 24) & 0xff;
2784 wordd |= (sval1 << 8) |
2785 ((sval1 + sval2) >> 1);
2786 worddp |= (((sval1 + sval3) >> 1) << 8) |
2787 ((sval1 + sval2 + sval3 + sval4) >> 2);
2788 lined[w * 2 + 1] = wordd;
2789 linedp[w * 2 + 1] = worddp;
2793 for (; j < wsm; j++, jd += 2) {
2802 (sval1 + sval2 + sval3 + sval4) / 4);
2812#define CHECK_BYTE(a, b, c) if (GET_DATA_BYTE(a, b) != c) {\
2813 lept_stderr("Error: mismatch at %d, %d vs %d\n", \
2814 j, GET_DATA_BYTE(a, b), c); }
2818 for (j = 0, jd = 0; j < wsm; j++, jd += 2) {
2823 CHECK_BYTE(lined, jd, sval1);
2824 CHECK_BYTE(lined, jd + 1, (sval1 + sval2) / 2);
2825 CHECK_BYTE(linedp, jd, (sval1 + sval3) / 2);
2826 CHECK_BYTE(linedp, jd + 1,
2827 (sval1 + sval2 + sval3 + sval4) / 4);
2831 CHECK_BYTE(lined, 2 * wsm, sval1);
2832 CHECK_BYTE(lined, 2 * wsm + 1, sval1);
2833 CHECK_BYTE(linedp, 2 * wsm, (sval1 + sval3) / 2);
2834 CHECK_BYTE(linedp, 2 * wsm + 1, (sval1 + sval3) / 2);
2838 linedp = lined + wpld;
2840 for (j = 0, jd = 0; j < wsm; j++, jd += 2) {
2923l_uint32 *lines, *lined;
2936 for (i = 0; i < hsm; i++) {
2937 lines = datas + i * wpls;
2938 lined = datad + 4 * i * wpld;
2943 lines = datas + hsm * wpls;
2944 lined = datad + 4 * hsm * wpld;
2966 l_int32 lastlineflag)
2968l_int32 j, jd, wsm, wsm4;
2969l_int32 s1, s2, s3, s4, s1t, s2t, s3t, s4t;
2970l_uint32 *linesp, *linedp1, *linedp2, *linedp3;
2975 if (lastlineflag == 0) {
2976 linesp = lines + wpls;
2977 linedp1 = lined + wpld;
2978 linedp2 = lined + 2 * wpld;
2979 linedp3 = lined + 3 * wpld;
2982 for (j = 0, jd = 0; j < wsm; j++, jd += 4) {
2996 SET_DATA_BYTE(linedp1, jd + 1, (9*s1 + s2t + s3t + s4) / 16);
2998 SET_DATA_BYTE(linedp1, jd + 3, (s1t + 9*s2 + s3 + s4t) / 16);
3004 SET_DATA_BYTE(linedp3, jd + 1, (s1t + s2 + 9*s3 + s4t) / 16);
3006 SET_DATA_BYTE(linedp3, jd + 3, (s1 + s2t + s3t + 9*s4) / 16);
3029 linedp1 = lined + wpld;
3030 linedp2 = lined + 2 * wpld;
3031 linedp3 = lined + 3 * wpld;
3033 for (j = 0, jd = 0; j < wsm; j++, jd += 4) {
3108l_int32 xs, prevxs, sval;
3109l_int32 *srow, *scol;
3111l_uint32 *lines, *prevlines, *lined, *prevlined;
3112l_float32 wratio, hratio;
3114 if (d != 2 && d != 4 && d !=8 && d != 16 && d != 32)
3115 return ERROR_INT(
"pixel depth not supported", __func__, 1);
3118 memset(datad, 0, 4LL * hd * wpld);
3122 if ((srow = (l_int32 *)LEPT_CALLOC(hd,
sizeof(l_int32))) == NULL)
3123 return ERROR_INT(
"srow not made", __func__, 1);
3124 if ((scol = (l_int32 *)LEPT_CALLOC(wd,
sizeof(l_int32))) == NULL) {
3126 return ERROR_INT(
"scol not made", __func__, 1);
3129 wratio = (l_float32)ws / (l_float32)wd;
3130 hratio = (l_float32)hs / (l_float32)hd;
3131 for (i = 0; i < hd; i++)
3132 srow[i] = L_MIN((l_int32)(hratio * i + shifty), hs - 1);
3133 for (j = 0; j < wd; j++)
3134 scol[j] = L_MIN((l_int32)(wratio * j + shiftx), ws - 1);
3137 for (i = 0; i < hd; i++) {
3138 lines = datas + srow[i] * wpls;
3139 lined = datad + i * wpld;
3140 if (lines != prevlines) {
3145 for (j = 0; j < wd; j++) {
3155 }
else if (d == 4) {
3156 for (j = 0; j < wd; j++) {
3166 }
else if (d == 8) {
3167 for (j = 0; j < wd; j++) {
3177 }
else if (d == 16) {
3178 for (j = 0; j < wd; j++) {
3189 for (j = 0; j < wd; j++) {
3201 prevlined = lined - wpld;
3202 memcpy(lined, prevlined, 4 * wpld);
3239l_int32 i, j, m, n, xstart;
3240l_int32 val, rval, gval, bval;
3241l_int32 *srow, *scol;
3242l_uint32 *lines, *lined, *line, *ppixel;
3244l_float32 wratio, hratio, norm;
3247 memset(datad, 0, 4LL * wpld * hd);
3254 if ((srow = (l_int32 *)LEPT_CALLOC(hd,
sizeof(l_int32))) == NULL)
3255 return ERROR_INT(
"srow not made", __func__, 1);
3256 if ((scol = (l_int32 *)LEPT_CALLOC(wd,
sizeof(l_int32))) == NULL) {
3258 return ERROR_INT(
"scol not made", __func__, 1);
3261 norm = 1.f / (l_float32)(size * size);
3262 wratio = (l_float32)ws / (l_float32)wd;
3263 hratio = (l_float32)hs / (l_float32)hd;
3264 for (i = 0; i < hd; i++)
3265 srow[i] = L_MIN((l_int32)(hratio * i), hs - size);
3266 for (j = 0; j < wd; j++)
3267 scol[j] = L_MIN((l_int32)(wratio * j), ws - size);
3271 for (i = 0; i < hd; i++) {
3272 lines = datas + srow[i] * wpls;
3273 lined = datad + i * wpld;
3274 for (j = 0; j < wd; j++) {
3277 for (m = 0; m < size; m++) {
3278 line = lines + m * wpls;
3279 for (n = 0; n < size; n++) {
3283 val = (l_int32)((l_float32)val * norm);
3288 for (i = 0; i < hd; i++) {
3289 lines = datas + srow[i] * wpls;
3290 lined = datad + i * wpld;
3291 for (j = 0; j < wd; j++) {
3293 rval = gval = bval = 0;
3294 for (m = 0; m < size; m++) {
3295 ppixel = lines + m * wpls + xstart;
3296 for (n = 0; n < size; n++) {
3297 pixel = *(ppixel + n);
3298 rval += (pixel >> L_RED_SHIFT) & 0xff;
3299 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3300 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3303 rval = (l_int32)((l_float32)rval * norm);
3304 gval = (l_int32)((l_float32)gval * norm);
3305 bval = (l_int32)((l_float32)bval * norm);
3306 composeRGBPixel(rval, gval, bval, lined + j);
3337l_int32 i, j, val, rval, gval, bval;
3338l_uint32 *lines, *lined;
3344 for (i = 0; i < hd; i++) {
3345 lines = datas + 2 * i * wpls;
3346 lined = datad + i * wpld;
3347 for (j = 0; j < wd; j++) {
3349 pixel = *(lines + 2 * j);
3350 rval = (pixel >> L_RED_SHIFT) & 0xff;
3351 gval = (pixel >> L_GREEN_SHIFT) & 0xff;
3352 bval = (pixel >> L_BLUE_SHIFT) & 0xff;
3353 pixel = *(lines + 2 * j + 1);
3354 rval += (pixel >> L_RED_SHIFT) & 0xff;
3355 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3356 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3357 pixel = *(lines + wpls + 2 * j);
3358 rval += (pixel >> L_RED_SHIFT) & 0xff;
3359 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3360 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3361 pixel = *(lines + wpls + 2 * j + 1);
3362 rval += (pixel >> L_RED_SHIFT) & 0xff;
3363 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3364 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3366 val = (l_int32)(rwt * rval + gwt * gval + bwt * bval);
3401l_int32 i, j, k, m, wm2, hm2;
3402l_int32 area00, area10, area01, area11, areal, arear, areat, areab;
3405l_int32 xup, yup, xuf, yuf;
3406l_int32 xlp, ylp, xlf, ylf;
3407l_int32 delx, dely, area;
3408l_int32 v00r, v00g, v00b;
3409l_int32 v01r, v01g, v01b;
3410l_int32 v10r, v10g, v10b;
3411l_int32 v11r, v11g, v11b;
3412l_int32 vinr, ving, vinb;
3413l_int32 vmidr, vmidg, vmidb;
3414l_int32 rval, gval, bval;
3415l_uint32 pixel00, pixel10, pixel01, pixel11, pixel;
3416l_uint32 *lines, *lined;
3423 scx = 16.f * (l_float32)ws / (l_float32)wd;
3424 scy = 16.f * (l_float32)hs / (l_float32)hd;
3429 for (i = 0; i < hd; i++) {
3430 yu = (l_int32)(scy * i);
3431 yl = (l_int32)(scy * (i + 1.0));
3437 lined = datad + i * wpld;
3438 lines = datas + yup * wpls;
3439 for (j = 0; j < wd; j++) {
3440 xu = (l_int32)(scx * j);
3441 xl = (l_int32)(scx * (j + 1.0));
3449 if (xlp > wm2 || ylp > hm2) {
3450 *(lined + j) = *(lines + xup);
3457 area = ((16 - xuf) + 16 * (delx - 1) + xlf) *
3458 ((16 - yuf) + 16 * (dely - 1) + ylf);
3461 pixel00 = *(lines + xup);
3462 pixel10 = *(lines + xlp);
3463 pixel01 = *(lines + dely * wpls + xup);
3464 pixel11 = *(lines + dely * wpls + xlp);
3465 area00 = (16 - xuf) * (16 - yuf);
3466 area10 = xlf * (16 - yuf);
3467 area01 = (16 - xuf) * ylf;
3469 v00r = area00 * ((pixel00 >> L_RED_SHIFT) & 0xff);
3470 v00g = area00 * ((pixel00 >> L_GREEN_SHIFT) & 0xff);
3471 v00b = area00 * ((pixel00 >> L_BLUE_SHIFT) & 0xff);
3472 v10r = area10 * ((pixel10 >> L_RED_SHIFT) & 0xff);
3473 v10g = area10 * ((pixel10 >> L_GREEN_SHIFT) & 0xff);
3474 v10b = area10 * ((pixel10 >> L_BLUE_SHIFT) & 0xff);
3475 v01r = area01 * ((pixel01 >> L_RED_SHIFT) & 0xff);
3476 v01g = area01 * ((pixel01 >> L_GREEN_SHIFT) & 0xff);
3477 v01b = area01 * ((pixel01 >> L_BLUE_SHIFT) & 0xff);
3478 v11r = area11 * ((pixel11 >> L_RED_SHIFT) & 0xff);
3479 v11g = area11 * ((pixel11 >> L_GREEN_SHIFT) & 0xff);
3480 v11b = area11 * ((pixel11 >> L_BLUE_SHIFT) & 0xff);
3481 vinr = ving = vinb = 0;
3482 for (k = 1; k < dely; k++) {
3483 for (m = 1; m < delx; m++) {
3484 pixel = *(lines + k * wpls + xup + m);
3485 vinr += 256 * ((pixel >> L_RED_SHIFT) & 0xff);
3486 ving += 256 * ((pixel >> L_GREEN_SHIFT) & 0xff);
3487 vinb += 256 * ((pixel >> L_BLUE_SHIFT) & 0xff);
3490 vmidr = vmidg = vmidb = 0;
3491 areal = (16 - xuf) * 16;
3493 areat = 16 * (16 - yuf);
3495 for (k = 1; k < dely; k++) {
3496 pixel = *(lines + k * wpls + xup);
3497 vmidr += areal * ((pixel >> L_RED_SHIFT) & 0xff);
3498 vmidg += areal * ((pixel >> L_GREEN_SHIFT) & 0xff);
3499 vmidb += areal * ((pixel >> L_BLUE_SHIFT) & 0xff);
3501 for (k = 1; k < dely; k++) {
3502 pixel = *(lines + k * wpls + xlp);
3503 vmidr += arear * ((pixel >> L_RED_SHIFT) & 0xff);
3504 vmidg += arear * ((pixel >> L_GREEN_SHIFT) & 0xff);
3505 vmidb += arear * ((pixel >> L_BLUE_SHIFT) & 0xff);
3507 for (m = 1; m < delx; m++) {
3508 pixel = *(lines + xup + m);
3509 vmidr += areat * ((pixel >> L_RED_SHIFT) & 0xff);
3510 vmidg += areat * ((pixel >> L_GREEN_SHIFT) & 0xff);
3511 vmidb += areat * ((pixel >> L_BLUE_SHIFT) & 0xff);
3513 for (m = 1; m < delx; m++) {
3514 pixel = *(lines + dely * wpls + xup + m);
3515 vmidr += areab * ((pixel >> L_RED_SHIFT) & 0xff);
3516 vmidg += areab * ((pixel >> L_GREEN_SHIFT) & 0xff);
3517 vmidb += areab * ((pixel >> L_BLUE_SHIFT) & 0xff);
3521 rval = (v00r + v01r + v10r + v11r + vinr + vmidr + 128) / area;
3522 gval = (v00g + v01g + v10g + v11g + ving + vmidg + 128) / area;
3523 bval = (v00b + v01b + v10b + v11b + vinb + vmidb + 128) / area;
3525 if (rval > 255) lept_stderr(
"rval ovfl: %d\n", rval);
3526 if (gval > 255) lept_stderr(
"gval ovfl: %d\n", gval);
3527 if (bval > 255) lept_stderr(
"bval ovfl: %d\n", bval);
3529 composeRGBPixel(rval, gval, bval, lined + j);
3559l_int32 i, j, k, m, wm2, hm2;
3562l_int32 xup, yup, xuf, yuf;
3563l_int32 xlp, ylp, xlf, ylf;
3564l_int32 delx, dely, area;
3572l_uint32 *lines, *lined;
3579 scx = 16.f * (l_float32)ws / (l_float32)wd;
3580 scy = 16.f * (l_float32)hs / (l_float32)hd;
3585 for (i = 0; i < hd; i++) {
3586 yu = (l_int32)(scy * i);
3587 yl = (l_int32)(scy * (i + 1.0));
3593 lined = datad + i * wpld;
3594 lines = datas + yup * wpls;
3595 for (j = 0; j < wd; j++) {
3596 xu = (l_int32)(scx * j);
3597 xl = (l_int32)(scx * (j + 1.0));
3605 if (xlp > wm2 || ylp > hm2) {
3613 area = ((16 - xuf) + 16 * (delx - 1) + xlf) *
3614 ((16 - yuf) + 16 * (dely - 1) + ylf);
3619 v01 = (16 - xuf) * ylf *
GET_DATA_BYTE(lines + dely * wpls, xup);
3621 for (vin = 0, k = 1; k < dely; k++) {
3622 for (m = 1; m < delx; m++) {
3626 for (vmid = 0, k = 1; k < dely; k++)
3627 vmid += (16 - xuf) * 16 *
GET_DATA_BYTE(lines + k * wpls, xup);
3628 for (k = 1; k < dely; k++)
3630 for (m = 1; m < delx; m++)
3632 for (m = 1; m < delx; m++)
3633 vmid += 16 * ylf *
GET_DATA_BYTE(lines + dely * wpls, xup + m);
3634 val = (v00 + v01 + v10 + v11 + vin + vmid + 128) / area;
3636 if (val > 255) lept_stderr(
"val overflow: %d\n", val);
3665l_int32 i, j, val, rval, gval, bval;
3666l_uint32 *lines, *lined;
3670 for (i = 0; i < hd; i++) {
3671 lines = datas + 2 * i * wpls;
3672 lined = datad + i * wpld;
3673 for (j = 0; j < wd; j++) {
3684 for (i = 0; i < hd; i++) {
3685 lines = datas + 2 * i * wpls;
3686 lined = datad + i * wpld;
3687 for (j = 0; j < wd; j++) {
3689 pixel = *(lines + 2 * j);
3690 rval = (pixel >> L_RED_SHIFT) & 0xff;
3691 gval = (pixel >> L_GREEN_SHIFT) & 0xff;
3692 bval = (pixel >> L_BLUE_SHIFT) & 0xff;
3693 pixel = *(lines + 2 * j + 1);
3694 rval += (pixel >> L_RED_SHIFT) & 0xff;
3695 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3696 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3697 pixel = *(lines + wpls + 2 * j);
3698 rval += (pixel >> L_RED_SHIFT) & 0xff;
3699 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3700 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3701 pixel = *(lines + wpls + 2 * j + 1);
3702 rval += (pixel >> L_RED_SHIFT) & 0xff;
3703 gval += (pixel >> L_GREEN_SHIFT) & 0xff;
3704 bval += (pixel >> L_BLUE_SHIFT) & 0xff;
3705 composeRGBPixel(rval >> 2, gval >> 2, bval >> 2, &pixel);
3706 *(lined + j) = pixel;
3729scaleBinaryLow(l_uint32 *datad,
3741l_int32 xs, prevxs, sval;
3742l_int32 *srow, *scol;
3743l_uint32 *lines, *prevlines, *lined, *prevlined;
3744l_float32 wratio, hratio;
3747 memset(datad, 0, 4LL * hd * wpld);
3751 if ((srow = (l_int32 *)LEPT_CALLOC(hd,
sizeof(l_int32))) == NULL)
3752 return ERROR_INT(
"srow not made", __func__, 1);
3753 if ((scol = (l_int32 *)LEPT_CALLOC(wd,
sizeof(l_int32))) == NULL) {
3755 return ERROR_INT(
"scol not made", __func__, 1);
3758 wratio = (l_float32)ws / (l_float32)wd;
3759 hratio = (l_float32)hs / (l_float32)hd;
3760 for (i = 0; i < hd; i++)
3761 srow[i] = L_MIN((l_int32)(hratio * i + shifty), hs - 1);
3762 for (j = 0; j < wd; j++)
3763 scol[j] = L_MIN((l_int32)(wratio * j + shiftx), ws - 1);
3768 for (i = 0; i < hd; i++) {
3769 lines = datas + srow[i] * wpls;
3770 lined = datad + i * wpld;
3771 if (lines != prevlines) {
3772 for (j = 0; j < wd; j++) {
3784 prevlined = lined - wpld;
3785 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)
@ REMOVE_CMAP_BASED_ON_SRC
PIX * pixScaleGray4xLIDither(PIX *pixs)
pixScaleGray4xLIDither()
PIX * pixScaleLI(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleLI()
PIX * pixScaleBinaryWithShift(PIX *pixs, l_float32 scalex, l_float32 scaley, l_float32 shiftx, l_float32 shifty)
pixScaleBinaryWithShift()
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 * pixScaleAreaMap2(PIX *pix)
pixScaleAreaMap2()
PIX * pixScaleGrayToBinaryFast(PIX *pixs, l_int32 factor, l_int32 thresh)
pixScaleGrayToBinaryFast()
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 * pixScaleBySamplingWithShift(PIX *pixs, l_float32 scalex, l_float32 scaley, l_float32 shiftx, l_float32 shifty)
pixScaleBySamplingWithShift()
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 * pixScaleBinary(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleBinary()
PIX * pixScaleGray2xLIThresh(PIX *pixs, l_int32 thresh)
pixScaleGray2xLIThresh()
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, l_float32 shiftx, l_float32 shifty)
scaleBySamplingLow()
PIX * pixScaleByIntSampling(PIX *pixs, l_int32 factor)
pixScaleByIntSampling()
PIX * pixScaleGray2xLI(PIX *pixs)
pixScaleGray2xLI()
PIX * pixScaleSmooth(PIX *pix, l_float32 scalex, l_float32 scaley)
pixScaleSmooth()
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 * pixScaleColor2xLI(PIX *pixs)
pixScaleColor2xLI()
PIX * pixScaleGray2xLIDither(PIX *pixs)
pixScaleGray2xLIDither()
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 * pixScaleGray4xLIThresh(PIX *pixs, l_int32 thresh)
pixScaleGray4xLIThresh()
PIX * pixScaleGray4xLI(PIX *pixs)
pixScaleGray4xLI()
PIX * pixScaleBySamplingToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleBySamplingToSize()
PIX * pixScaleBySampling(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleBySampling()
PIX * pixScaleColorLI(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleColorLI()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
static void scaleColor2xLILow(l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleColor2xLILow()
PIX * pixScaleToSizeRel(PIX *pixs, l_int32 delw, l_int32 delh)
pixScaleToSizeRel()
static void scaleGray4xLILow(l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls)
scaleGray4xLILow()
PIX * pixScaleRGBToGray2(PIX *pixs, l_float32 rwt, l_float32 gwt, l_float32 bwt)
pixScaleRGBToGray2()
PIX * pixScaleSmoothToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleSmoothToSize()
PIX * pixScaleRGBToBinaryFast(PIX *pixs, l_int32 factor, l_int32 thresh)
pixScaleRGBToBinaryFast()
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()
PIX * pixScaleRGBToGrayFast(PIX *pixs, l_int32 factor, l_int32 color)
pixScaleRGBToGrayFast()
PIX * pixScaleToResolution(PIX *pixs, l_float32 target, l_float32 assumed, l_float32 *pscalefact)
pixScaleToResolution()
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 * pixScaleToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleToSize()
PIX * pixScaleAreaMapToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleAreaMapToSize()
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()
static void scaleColor2xLILineLow(l_uint32 *lined, l_int32 wpld, l_uint32 *lines, l_int32 ws, l_int32 wpls, l_int32 lastlineflag)
scaleColor2xLILineLow()
PIX * pixScaleAreaMap(PIX *pix, l_float32 scalex, l_float32 scaley)
pixScaleAreaMap()