本文整理汇总了C++中pixSaveTiled函数的典型用法代码示例。如果您正苦于以下问题:C++ pixSaveTiled函数的具体用法?C++ pixSaveTiled怎么用?C++ pixSaveTiled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pixSaveTiled函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
main(int argc,
char **argv)
{
l_int32 i;
PIX *pix;
PIXA *pixa;
for (i = 0; i < NTests; i++)
GenerateSplitPlot(i);
/* Read the results back in ... */
pixa = pixaCreate(0);
for (i = 0; i < NTests; i++) {
sprintf(buf, "/tmp/junkplot.%d.png", i);
pix = pixRead(buf);
pixSaveTiled(pix, pixa, 1, 1, 25, 32);
pixDestroy(&pix);
sprintf(buf, "/tmp/junkplots.%d.png", i);
pix = pixRead(buf);
pixSaveTiled(pix, pixa, 1, 0, 25, 32);
pixDestroy(&pix);
}
/* ... and save into a tiled pix */
pix = pixaDisplay(pixa, 0, 0);
pixWrite("/tmp/junkotsuplot.png", pix, IFF_PNG);
pixDisplay(pix, 100, 100);
pixaDestroy(&pixa);
pixDestroy(&pix);
return 0;
}
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:31,代码来源:otsutest1.c
示例2: AddScaledImages
static void
AddScaledImages(PIXA *pixa,
const char *fname,
l_int32 width)
{
l_int32 i, w;
l_float32 scalefactor;
PIX *pixs, *pixt1, *pixt2, *pix32;
pixs = pixRead(fname);
w = pixGetWidth(pixs);
for (i = 0; i < 5; i++) {
scalefactor = (l_float32)width / (FACTOR[i] * (l_float32)w);
pixt1 = pixScale(pixs, FACTOR[i], FACTOR[i]);
pixt2 = pixScale(pixt1, scalefactor, scalefactor);
pix32 = pixConvertTo32(pixt2);
if (i == 0)
pixSaveTiled(pix32, pixa, 1.0, 1, SPACE, 32);
else
pixSaveTiled(pix32, pixa, 1.0, 0, SPACE, 32);
pixDestroy(&pixt1);
pixDestroy(&pixt2);
pixDestroy(&pix32);
}
pixDestroy(&pixs);
return;
}
开发者ID:ZhangXinNan,项目名称:leptonica-1,代码行数:27,代码来源:scale_reg.c
示例3: PixSavePlots1
static PIXA *
PixSavePlots1(void)
{
PIX *pixt;
PIXA *pixa;
pixa = pixaCreate(8);
pixt = pixRead("/tmp/rtnan.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnar.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnai.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnarbin.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnabb.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnared.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnagreen.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnablue.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
return pixa;
}
开发者ID:AngusHardie,项目名称:TesseractOCR-For-Mac,代码行数:33,代码来源:rankhisto_reg.c
示例4: main
int main(int argc,
char **argv)
{
PIX *pixs, *pixd;
PIXA *pixa;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
pixs = pixRead("stampede2.jpg");
pixa = pixaCreate(0);
pixSaveTiled(pixs, pixa, 1.0, 1, 20, 8);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 18, 40, 40, 0.7, -25, 280, 128);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 18, 40, 40, 0.7, -25, 280, 128);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 10, 40, 40, 0.7, -15, 305, 128);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 10, 40, 40, 0.7, -15, 305, 128);
AddTestSet(pixa, pixs, L_SOBEL_EDGE, 15, 40, 40, 0.6, -45, 285, 158);
AddTestSet(pixa, pixs, L_TWO_SIDED_EDGE, 15, 40, 40, 0.6, -45, 285, 158);
pixDestroy(&pixs);
pixd = pixaDisplay(pixa, 0, 0);
regTestWritePixAndCheck(rp, pixd, IFF_JFIF_JPEG); /* 0 */
pixDisplayWithTitle(pixd, 100, 100, NULL, rp->display);
pixDestroy(&pixd);
pixaDestroy(&pixa);
return regTestCleanup(rp);
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:30,代码来源:threshnorm_reg.c
示例5: PixSave32
static void
PixSave32(PIXA *pixa, PIX *pixc)
{
PIX *pix32;
pix32 = pixConvertTo32(pixc);
pixSaveTiled(pix32, pixa, 1.0, 0, SPACE, 32);
pixDestroy(&pixc);
pixDestroy(&pix32);
return;
}
开发者ID:ZhangXinNan,项目名称:leptonica-1,代码行数:10,代码来源:scale_reg.c
示例6: PixSave32
static void
PixSave32(PIXA *pixa, PIX *pixc, L_REGPARAMS *rp)
{
PIX *pix32;
pix32 = pixConvertTo32(pixc);
pixSaveTiled(pix32, pixa, 1.0, 0, SPACE, 0);
regTestWritePixAndCheck(rp, pix32, IFF_JFIF_JPEG);
pixDestroy(&pixc);
pixDestroy(&pix32);
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:11,代码来源:colorquant_reg.c
示例7: PixTest1
PIX *
PixTest1(PIX *pixs,
l_int32 size,
l_float32 factor,
L_REGPARAMS *rp)
{
l_int32 w, h;
PIX *pixm, *pixsd, *pixth, *pixd, *pixt;
PIXA *pixa;
pixm = pixsd = pixth = pixd = NULL;
pixGetDimensions(pixs, &w, &h, NULL);
/* Get speed */
startTimer();
pixSauvolaBinarize(pixs, size, factor, 1, NULL, NULL, NULL, &pixd);
fprintf(stderr, "\nSpeed: 1 tile, %7.3f Mpix/sec\n",
(w * h / 1000000.) / stopTimer());
pixDestroy(&pixd);
/* Get results */
pixSauvolaBinarize(pixs, size, factor, 1, &pixm, &pixsd, &pixth, &pixd);
pixa = pixaCreate(0);
pixSaveTiled(pixm, pixa, 1, 1, 30, 8);
pixSaveTiled(pixsd, pixa, 1, 0, 30, 8);
pixSaveTiled(pixth, pixa, 1, 1, 30, 8);
pixSaveTiled(pixd, pixa, 1, 0, 30, 8);
pixt = pixaDisplay(pixa, 0, 0);
regTestWritePixAndCheck(rp, pixt, IFF_JFIF_JPEG);
if (rp->index < 5)
pixDisplayWithTitle(pixt, 100, 100, NULL, rp->display);
regTestWritePixAndCheck(rp, pixd, IFF_PNG);
pixaDestroy(&pixa);
pixDestroy(&pixm);
pixDestroy(&pixsd);
pixDestroy(&pixth);
pixDestroy(&pixt);
return pixd;
}
开发者ID:0xkasun,项目名称:Dummy_Tes,代码行数:40,代码来源:binarize_reg.c
示例8: main
int main(int argc,
char **argv)
{
char namebuf[256];
l_int32 i, j, k, maxdist, maxcolors, selsize, finalcolors;
PIX *pixs, *pixt, *pixd;
PIXA *pixa;
static char mainName[] = "colorseg_reg";
if (argc != 1)
return ERROR_INT("Syntax: colorseg_reg", mainName, 1);
pixs = pixRead("tetons.jpg");
for (k = 0; k < 3; k++) {
maxcolors = MaxColors[k];
finalcolors = FinalColors[k];
pixa = pixaCreate(0);
pixSaveTiled(pixs, pixa, 1.0, 1, 15, 32);
for (i = 1; i <= 9; i++) {
maxdist = 20 * i;
for (j = 0; j <= 6; j++) {
selsize = j;
pixt = pixColorSegment(pixs, maxdist, maxcolors, selsize,
finalcolors);
pixSaveTiled(pixt, pixa, 1.0, j == 0 ? 1 : 0, 15, 32);
pixDestroy(&pixt);
}
}
pixd = pixaDisplay(pixa, 0, 0);
pixDisplay(pixd, 100, 100);
sprintf(namebuf, "/tmp/junkcolorseg%d.jpg", k);
pixWrite(namebuf, pixd, IFF_JFIF_JPEG);
pixDestroy(&pixd);
pixaDestroy(&pixa);
}
pixDestroy(&pixs);
return 0;
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:40,代码来源:colorseg_reg.c
示例9: AddTestSet
void
AddTestSet(PIXA *pixa,
PIX *pixs,
l_int32 filtertype,
l_int32 edgethresh,
l_int32 smoothx,
l_int32 smoothy,
l_float32 gamma,
l_int32 minval,
l_int32 maxval,
l_int32 targetthresh)
{
PIX *pixb, *pixd, *pixth;
pixThresholdSpreadNorm(pixs, filtertype, edgethresh,
smoothx, smoothy, gamma, minval,
maxval, targetthresh, &pixth, NULL, &pixd);
pixSaveTiled(pixth, pixa, 1.0, 1, 20, 0);
pixSaveTiled(pixd, pixa, 1.0, 0, 20, 0);
pixb = pixThresholdToBinary(pixd, targetthresh - 20);
pixSaveTiled(pixb, pixa, 1.0, 0, 20, 0);
pixDestroy(&pixb);
pixb = pixThresholdToBinary(pixd, targetthresh);
pixSaveTiled(pixb, pixa, 1.0, 0, 20, 0);
pixDestroy(&pixb);
pixb = pixThresholdToBinary(pixd, targetthresh + 20);
pixSaveTiled(pixb, pixa, 1.0, 0, 20, 0);
pixDestroy(&pixb);
pixb = pixThresholdToBinary(pixd, targetthresh + 40);
pixSaveTiled(pixb, pixa, 1.0, 0, 20, 0);
pixDestroy(&pixb);
pixDestroy(&pixth);
pixDestroy(&pixd);
return;
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:35,代码来源:threshnorm_reg.c
示例10: DisplayResult
static void
DisplayResult(PIXA *pixac,
PIXA **ppixa,
l_int32 w,
l_int32 h,
l_int32 newline)
{
PIX *pixd;
pixd = pixaDisplay(*ppixa, w, h);
pixSaveTiled(pixd, pixac, 1, newline, 30, 8);
pixDestroy(&pixd);
pixaDestroy(ppixa);
return;
}
开发者ID:dreamplayerzhang,项目名称:leptonica,代码行数:15,代码来源:ptra1_reg.c
示例11: main
main(int argc,
char **argv)
{
char buf[256];
l_int32 i, j, k, index, conn, depth, bc;
BOX *box;
PIX *pix, *pixs, *pixd;
PIXA *pixa;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
pix = pixRead("feyn.tif");
box = boxCreate(383, 338, 1480, 1050);
pixs = pixClipRectangle(pix, box, NULL);
regTestWritePixAndCheck(rp, pixs, IFF_PNG); /* 0 */
for (i = 0; i < 2; i++) {
conn = 4 + 4 * i;
for (j = 0; j < 2; j++) {
depth = 8 + 8 * j;
for (k = 0; k < 2; k++) {
bc = k + 1;
index = 4 * i + 2 * j + k;
fprintf(stderr, "Set %d\n", index);
if (DEBUG) {
fprintf(stderr, "%d: conn = %d, depth = %d, bc = %d\n",
rp->index + 1, conn, depth, bc);
}
pixa = pixaCreate(0);
pixSaveTiled(pixs, pixa, 1, 1, 20, 8);
TestDistance(pixa, pixs, conn, depth, bc, rp);
pixd = pixaDisplay(pixa, 0, 0);
pixDisplayWithTitle(pixd, 0, 0, NULL, rp->display);
pixaDestroy(&pixa);
pixDestroy(&pixd);
}
}
}
boxDestroy(&box);
pixDestroy(&pix);
pixDestroy(&pixs);
regTestCleanup(rp);
return 0;
}
开发者ID:slohman,项目名称:October2012Workspace,代码行数:47,代码来源:distance_reg.c
示例12: PixSavePlots2
static PIXA *
PixSavePlots2(void)
{
PIX *pixt;
PIXA *pixa;
pixa = pixaCreate(9);
pixt = pixRead("/tmp/rtnan1.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnai1.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnarbin1.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnan2.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnai2.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnarbin2.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnan3.png");
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnai3.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = pixRead("/tmp/rtnarbin3.png");
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
return pixa;
}
开发者ID:AngusHardie,项目名称:TesseractOCR-For-Mac,代码行数:36,代码来源:rankhisto_reg.c
示例13: pixSaveTiledWithText
/*!
* pixSaveTiledWithText()
*
* Input: pixs (1, 2, 4, 8, 32 bpp)
* pixa (the pix are accumulated here; as 32 bpp)
* outwidth (in pixels; use 0 to disable entirely)
* newrow (1 to start a new row; 0 to go on same row as previous)
* space (horizontal and vertical spacing, in pixels)
* linewidth (width of added outline for image; 0 for no outline)
* bmf (<optional> font struct)
* textstr (<optional> text string to be added)
* val (color to set the text)
* location (L_ADD_ABOVE, L_ADD_AT_TOP, L_ADD_AT_BOT, L_ADD_BELOW)
* Return: 0 if OK, 1 on error.
*
* Notes:
* (1) Before calling this function for the first time, use
* pixaCreate() to make the @pixa that will accumulate the pix.
* This is passed in each time pixSaveTiled() is called.
* (2) @outwidth is the scaled width. After scaling, the image is
* saved in the input pixa, along with a box that specifies
* the location to place it when tiled later. Disable saving
* the pix by setting @outwidth == 0.
* (3) @newrow and @space specify the location of the new pix
* with respect to the last one(s) that were entered.
* (4) All pix are saved as 32 bpp RGB.
* (5) If both @bmf and @textstr are defined, this generates a pix
* with the additional text; otherwise, no text is written.
* (6) The text is written before scaling, so it is properly
* antialiased in the scaled pix. However, if the pix on
* different calls have different widths, the size of the
* text will vary.
* (7) See pixSaveTiledOutline() for other implementation details.
*/
l_int32
pixSaveTiledWithText(PIX *pixs,
PIXA *pixa,
l_int32 outwidth,
l_int32 newrow,
l_int32 space,
l_int32 linewidth,
L_BMF *bmf,
const char *textstr,
l_uint32 val,
l_int32 location)
{
PIX *pix1, *pix2, *pix3, *pix4;
PROCNAME("pixSaveTiledWithText");
if (outwidth == 0) return 0;
if (!pixs)
return ERROR_INT("pixs not defined", procName, 1);
if (!pixa)
return ERROR_INT("pixa not defined", procName, 1);
pix1 = pixConvertTo32(pixs);
if (linewidth > 0)
pix2 = pixAddBorder(pix1, linewidth, 0);
else
pix2 = pixClone(pix1);
if (bmf && textstr)
pix3 = pixAddSingleTextblock(pix2, bmf, textstr, val, location, NULL);
else
pix3 = pixClone(pix2);
pix4 = pixScaleToSize(pix3, outwidth, 0);
pixSaveTiled(pix4, pixa, 1.0, newrow, space, 32);
pixDestroy(&pix1);
pixDestroy(&pix2);
pixDestroy(&pix3);
pixDestroy(&pix4);
return 0;
}
开发者ID:KevinSantos,项目名称:openalpr-windows,代码行数:74,代码来源:writefile.c
示例14: RotateTest
static void
RotateTest(PIX *pixs,
l_float32 scale,
L_REGPARAMS *rp)
{
l_int32 w, h, d, i, outformat;
PIX *pixt, *pixd;
PIXA *pixa;
pixa = pixaCreate(0);
pixGetDimensions(pixs, &w, &h, &d);
outformat = (d == 8 || d == 32) ? IFF_JFIF_JPEG : IFF_PNG;
pixd = pixRotate(pixs, ANGLE1, L_ROTATE_SHEAR, L_BRING_IN_WHITE, w, h);
for (i = 1; i < NTIMES; i++) {
if ((i % MODSIZE) == 0) {
if (i == MODSIZE) {
pixSaveTiled(pixd, pixa, scale, 1, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
} else {
pixSaveTiled(pixd, pixa, scale, 0, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
}
}
pixt = pixRotate(pixd, ANGLE1, L_ROTATE_SHEAR,
L_BRING_IN_WHITE, w, h);
pixDestroy(&pixd);
pixd = pixt;
}
pixDestroy(&pixd);
pixd = pixRotate(pixs, ANGLE1, L_ROTATE_SAMPLING, L_BRING_IN_WHITE, w, h);
for (i = 1; i < NTIMES; i++) {
if ((i % MODSIZE) == 0) {
if (i == MODSIZE) {
pixSaveTiled(pixd, pixa, scale, 1, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
} else {
pixSaveTiled(pixd, pixa, scale, 0, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
}
}
pixt = pixRotate(pixd, ANGLE1, L_ROTATE_SAMPLING,
L_BRING_IN_WHITE, w, h);
pixDestroy(&pixd);
pixd = pixt;
}
pixDestroy(&pixd);
pixd = pixRotate(pixs, ANGLE1, L_ROTATE_AREA_MAP, L_BRING_IN_WHITE, w, h);
for (i = 1; i < NTIMES; i++) {
if ((i % MODSIZE) == 0) {
if (i == MODSIZE) {
pixSaveTiled(pixd, pixa, scale, 1, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
} else {
pixSaveTiled(pixd, pixa, scale, 0, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
}
}
pixt = pixRotate(pixd, ANGLE1, L_ROTATE_AREA_MAP,
L_BRING_IN_WHITE, w, h);
pixDestroy(&pixd);
pixd = pixt;
}
pixDestroy(&pixd);
pixd = pixRotateAMCorner(pixs, ANGLE2, L_BRING_IN_WHITE);
for (i = 1; i < NTIMES; i++) {
if ((i % MODSIZE) == 0) {
if (i == MODSIZE) {
pixSaveTiled(pixd, pixa, scale, 1, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
} else {
pixSaveTiled(pixd, pixa, scale, 0, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
}
}
pixt = pixRotateAMCorner(pixd, ANGLE2, L_BRING_IN_WHITE);
pixDestroy(&pixd);
pixd = pixt;
}
pixDestroy(&pixd);
if (d == 32) {
pixd = pixRotateAMColorFast(pixs, ANGLE1, 0xb0ffb000);
for (i = 1; i < NTIMES; i++) {
if ((i % MODSIZE) == 0) {
if (i == MODSIZE) {
pixSaveTiled(pixd, pixa, scale, 1, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
} else {
pixSaveTiled(pixd, pixa, scale, 0, 20, 32);
regTestWritePixAndCheck(rp, pixd, outformat);
}
}
pixt = pixRotateAMColorFast(pixd, ANGLE1, 0xb0ffb000);
pixDestroy(&pixd);
pixd = pixt;
}
}
//.........这里部分代码省略.........
开发者ID:xmarston,项目名称:BillRecognizer,代码行数:101,代码来源:rotate1_reg.c
示例15: main
main(int argc,
char **argv)
{
l_float32 sum, sumx, sumy, diff;
L_DEWARP *dew;
L_DEWARPA *dewa;
FPIX *fpixs, *fpixs2, *fpixs3, *fpixs4, *fpixg, *fpixd;
FPIX *fpix1, *fpix2, *fpixt1, *fpixt2;
DPIX *dpix, *dpix2;
L_KERNEL *kel, *kelx, *kely;
PIX *pixs, *pixs2, *pixs3, *pixt, *pixd, *pixg, *pixb, *pixn;
PIX *pixt1, *pixt2, *pixt3, *pixt4, *pixt5, *pixt6;
PIXA *pixa;
PTA *ptas, *ptad;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
pixa = pixaCreate(0);
/* Gaussian kernel */
kel = makeGaussianKernel(5, 5, 3.0, 4.0);
kernelGetSum(kel, &sum);
if (rp->display) fprintf(stderr, "Sum for 2d gaussian kernel = %f\n", sum);
pixt = kernelDisplayInPix(kel, 41, 2);
regTestWritePixAndCheck(rp, pixt, IFF_PNG); /* 0 */
pixSaveTiled(pixt, pixa, 1, 1, 20, 8);
pixDestroy(&pixt);
/* Separable gaussian kernel */
makeGaussianKernelSep(5, 5, 3.0, 4.0, &kelx, &kely);
kernelGetSum(kelx, &sumx);
if (rp->display) fprintf(stderr, "Sum for x gaussian kernel = %f\n", sumx);
kernelGetSum(kely, &sumy);
if (rp->display) fprintf(stderr, "Sum for y gaussian kernel = %f\n", sumy);
if (rp->display) fprintf(stderr, "Sum for x * y gaussian kernel = %f\n",
sumx * sumy);
pixt = kernelDisplayInPix(kelx, 41, 2);
regTestWritePixAndCheck(rp, pixt, IFF_PNG); /* 1 */
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
pixt = kernelDisplayInPix(kely, 41, 2);
regTestWritePixAndCheck(rp, pixt, IFF_PNG); /* 2 */
pixSaveTiled(pixt, pixa, 1, 0, 20, 8);
pixDestroy(&pixt);
/* Use pixRasterop() to generate source image */
pixs = pixRead("test8.jpg");
pixs2 = pixRead("karen8.jpg");
pixRasterop(pixs, 150, 125, 150, 100, PIX_SRC, pixs2, 75, 100);
regTestWritePixAndCheck(rp, pixs, IFF_JFIF_JPEG); /* 3 */
/* Convolution directly with pix */
pixt1 = pixConvolve(pixs, kel, 8, 1);
regTestWritePixAndCheck(rp, pixt1, IFF_JFIF_JPEG); /* 4 */
pixSaveTiled(pixt1, pixa, 1, 1, 20, 8);
pixt2 = pixConvolveSep(pixs, kelx, kely, 8, 1);
regTestWritePixAndCheck(rp, pixt2, IFF_JFIF_JPEG); /* 5 */
pixSaveTiled(pixt2, pixa, 1, 0, 20, 8);
/* Convolution indirectly with fpix, using fpixRasterop()
* to generate the source image. */
fpixs = pixConvertToFPix(pixs, 3);
fpixs2 = pixConvertToFPix(pixs2, 3);
fpixRasterop(fpixs, 150, 125, 150, 100, fpixs2, 75, 100);
fpixt1 = fpixConvolve(fpixs, kel, 1);
pixt3 = fpixConvertToPix(fpixt1, 8, L_CLIP_TO_ZERO, 1);
regTestWritePixAndCheck(rp, pixt3, IFF_JFIF_JPEG); /* 6 */
pixSaveTiled(pixt3, pixa, 1, 1, 20, 8);
fpixt2 = fpixConvolveSep(fpixs, kelx, kely, 1);
pixt4 = fpixConvertToPix(fpixt2, 8, L_CLIP_TO_ZERO, 1);
regTestWritePixAndCheck(rp, pixt4, IFF_JFIF_JPEG); /* 7 */
pixSaveTiled(pixt4, pixa, 1, 0, 20, 8);
pixDestroy(&pixs2);
fpixDestroy(&fpixs2);
fpixDestroy(&fpixt1);
fpixDestroy(&fpixt2);
/* Comparison of results */
pixCompareGray(pixt1, pixt2, L_COMPARE_ABS_DIFF, 0, NULL,
&diff, NULL, NULL);
if (rp->display)
fprintf(stderr, "Ave diff of pixConvolve and pixConvolveSep: %f\n",
diff);
pixCompareGray(pixt3, pixt4, L_COMPARE_ABS_DIFF, 0, NULL,
&diff, NULL, NULL);
if (rp->display)
fprintf(stderr, "Ave diff of fpixConvolve and fpixConvolveSep: %f\n",
diff);
pixCompareGray(pixt1, pixt3, L_COMPARE_ABS_DIFF, 0, NULL,
&diff, NULL, NULL);
if (rp->display)
fprintf(stderr, "Ave diff of pixConvolve and fpixConvolve: %f\n", diff);
pixCompareGray(pixt2, pixt4, L_COMPARE_ABS_DIFF, GPLOT_PNG, NULL,
&diff, NULL, NULL);
if (rp->display)
fprintf(stderr, "Ave diff of pixConvolveSep and fpixConvolveSep: %f\n",
diff);
pixDestroy(&pixt1);
//.........这里部分代码省略.........
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:101,代码来源:fpix_reg.c
示例16: main
main(int argc,
char **argv)
{
l_int32 i, j, w1, h1, w2, h2, w, h, same;
BOX *box1, *box2;
PIX *pixs, *pixs1, *pixs2, *pix1, *pix2;
PIX *pixg, *pixg1, *pixg2, *pixc2, *pixbl, *pixd;
PIXA *pixa;
static char mainName[] = "blend2_reg";
/* --- Set up the 8 bpp blending image --- */
pixg = pixCreate(660, 500, 8);
for (i = 0; i < 500; i++)
for (j = 0; j < 660; j++)
pixSetPixel(pixg, j, i, (l_int32)(0.775 * j) % 256);
/* --- Set up the initial color images to be blended together --- */
pixs1 = pixRead("wyom.jpg");
pixs2 = pixRead("fish24.jpg");
pixGetDimensions(pixs1, &w1, &h1, NULL);
pixGetDimensions(pixs2, &w2, &h2, NULL);
h = L_MIN(h1, h2);
w = L_MIN(w1, w2);
box1 = boxCreate(0, 0, w1, h1);
box2 = boxCreate(0, 300, 660, 500);
pix1 = pixClipRectangle(pixs1, box1, NULL);
pix2 = pixClipRectangle(pixs2, box2, NULL);
pixDestroy(&pixs1);
pixDestroy(&pixs2);
boxDestroy(&box1);
boxDestroy(&box2);
/* --- Blend 2 rgb images --- */
pixa = pixaCreate(0);
pixSaveTiled(pixg, pixa, 1, 1, 40, 32);
pixd = pixBlendWithGrayMask(pix1, pix2, pixg, 50, 50);
pixSaveTiled(pix1, pixa, 1, 1, 40, 32);
pixSaveTiled(pix2, pixa, 1, 0, 40, 32);
pixSaveTiled(pixd, pixa, 1, 0, 40, 32);
pixDestroy(&pixd);
/* --- Blend 2 grayscale images --- */
pixg1 = pixConvertRGBToLuminance(pix1);
pixg2 = pixConvertRGBToLuminance(pix2);
pixd = pixBlendWithGrayMask(pixg1, pixg2, pixg, 50, 50);
pixSaveTiled(pixg1, pixa, 1, 1, 40, 32);
pixSaveTiled(pixg2, pixa, 1, 0, 40, 32);
pixSaveTiled(pixd, pixa, 1, 0, 40, 32);
pixDestroy(&pixg1);
pixDestroy(&pixg2);
pixDestroy(&pixd);
/* --- Blend a colormap image and an rgb image --- */
pixc2 = pixFixedOctcubeQuantGenRGB(pix2, 2);
pixd = pixBlendWithGrayMask(pix1, pixc2, pixg, 50, 50);
pixSaveTiled(pix1, pixa, 1, 1, 40, 32);
pixSaveTiled(pixc2, pixa, 1, 0, 40, 32);
pixSaveTiled(pixd, pixa, 1, 0, 40, 32);
pixDestroy(&pixc2);
pixDestroy(&pixd);
/* --- Blend a colormap image and a grayscale image --- */
pixg1 = pixConvertRGBToLuminance(pix1);
pixc2 = pixFixedOctcubeQuantGenRGB(pix2, 2);
pixd = pixBlendWithGrayMask(pixg1, pixc2, pixg, 50, 50);
pixSaveTiled(pixg1, pixa, 1, 1, 40, 32);
pixSaveTiled(pixc2, pixa, 1, 0, 40, 32);
pixSaveTiled(pixd, pixa, 1, 0, 40, 32);
pixDestroy(&pixd);
pixd = pixBlendWithGrayMask(pixg1, pixc2, pixg, -100, -100);
pixSaveTiled(pixg1, pixa, 1, 1, 40, 32);
pixSaveTiled(pixc2, pixa, 1, 0, 40, 32);
pixSaveTiled(pixd, pixa, 1, 0, 40, 32);
pixDestroy(&pixd);
pixDestroy(&pixg1);
pixDestroy(&pixc2);
/* --- Test png read/write with alpha channel --- */
/* First make pixs1, using pixg as the alpha channel */
pixs = pixRead("fish24.jpg");
box1 = boxCreate(0, 300, 660, 500);
pixs1 = pixClipRectangle(pixs, box1, NULL);
pixSaveTiled(pixs1, pixa, 1, 1, 40, 32);
pixSetRGBComponent(pixs1, pixg, L_ALPHA_CHANNEL);
/* To see the alpha channel, blend with a black image */
pixbl = pixCreate(660, 500, 32);
pixd = pixBlendWithGrayMask(pixbl, pixs1, NULL, 0, 0);
pixSaveTiled(pixd, pixa, 1, 0, 40, 32);
pixDestroy(&pixd);
/* Write out the RGBA image and read it back */
l_pngSetWriteAlpha(1);
pixWrite("/tmp/junkpixs1.png", pixs1, IFF_PNG);
l_pngSetStripAlpha(0);
pixs2 = pixRead("/tmp/junkpixs1.png");
/* Make sure that the alpha channel image hasn't changed */
pixg2 = pixGetRGBComponent(pixs2, L_ALPHA_CHANNEL);
pixEqual(pixg, pixg2, &same);
if (same)
fprintf(stderr, "PNG with alpha read/write OK\n");
else
//.........这里部分代码省略.........
开发者ID:0xkasun,项目名称:Dummy_Tes,代码行数:101,代码来源:blend2_reg.c
示例17: main
main(int argc,
char **argv)
{
l_int32 i, j, x, y, val;
PIX *pixsq, *pixs, *pixc, *pixd;
PIXA *pixa;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
pixsq = pixCreate(3, 3, 32);
pixSetAllArbitrary(pixsq, 0x00ff0000);
pixa = pixaCreate(6);
/* Moderately dense */
pixs = pixCreate(300, 300, 8);
for (i = 0; i < 100; i++) {
x = (153 * i * i * i + 59) % 299;
y = (117 * i * i * i + 241) % 299;
val = (97 * i + 74) % 256;
pixSetPixel(pixs, x, y, val);
}
pixd = pixSeedspread(pixs, 4); /* 4-cc */
pixc = pixConvertTo32(pixd);
for (i = 0; i < 100; i++) {
x = (153 * i * i * i + 59) % 299;
y = (117 * i * i * i + 241) % 299;
pixRasterop(pixc, x - 1, y - 1, 3, 3, PIX_SRC, pixsq, 0, 0);
}
pixSaveTiled(pixc, pixa, REDUCTION, 1, 20, 32);
regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 0 */
pixDisplayWithTitle(pixc, 100, 100, "4-cc", rp->display);
pixDestroy(&pixd);
pixDestroy(&pixc);
pixd = pixSeedspread(pixs, 8); /* 8-cc */
pixc = pixConvertTo32(pixd);
for (i = 0; i < 100; i++) {
x = (153 * i * i * i + 59) % 299;
y = (117 * i * i * i + 241) % 299;
pixRasterop(pixc, x - 1, y - 1, 3, 3, PIX_SRC, pixsq, 0, 0);
}
pixSaveTiled(pixc, pixa, REDUCTION, 0, 20, 0);
regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 1 */
pixDisplayWithTitle(pixc, 410, 100, "8-cc", rp->display);
pixDestroy(&pixd);
pixDestroy(&pixc);
pixDestroy(&pixs);
/* Regular lattice */
pixs = pixCreate(200, 200, 8);
for (i = 5; i <= 195; i += 10) {
for (j = 5; j <= 195; j += 10) {
pixSetPixel(pixs, i, j, (7 * i + 17 * j) % 255);
}
}
pixd = pixSeedspread(pixs, 4); /* 4-cc */
pixc = pixConvertTo32(pixd);
for (i = 5; i <= 195; i += 10) {
for (j = 5; j <= 195; j += 10) {
pixRasterop(pixc, j - 1, i - 1, 3, 3, PIX_SRC, pixsq, 0, 0);
}
}
pixSaveTiled(pixc, pixa, REDUCTION, 1, 20, 0);
regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 2 */
pixDisplayWithTitle(pixc, 100, 430, "4-cc", rp->display);
pixDestroy(&pixd);
pixDestroy(&pixc);
pixd = pixSeedspread(pixs, 8); /* 8-cc */
pixc = pixConvertTo32(pixd);
for (i = 5; i <= 195; i += 10) {
for (j = 5; j <= 195; j += 10) {
pixRasterop(pixc, j - 1, i - 1, 3, 3, PIX_SRC, pixsq, 0, 0);
}
}
pixSaveTiled(pixc, pixa, REDUCTION, 0, 20, 0);
regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 3 */
pixDisplayWithTitle(pixc, 310, 430, "8-cc", rp->display);
pixDestroy(&pixd);
pixDestroy(&pixc);
pixDestroy(&pixs);
/* Very sparse points */
pixs = pixCreate(200, 200, 8);
pixSetPixel(pixs, 60, 20, 90);
pixSetPixel(pixs, 160, 40, 130);
pixSetPixel(pixs, 80, 80, 205);
pixSetPixel(pixs, 40, 160, 115);
pixd = pixSeedspread(pixs, 4); /* 4-cc */
pixc = pixConvertTo32(pixd);
pixRasterop(pixc, 60 - 1, 20 - 1, 3, 3, PIX_SRC, pixsq, 0, 0);
pixRasterop(pixc, 160 - 1, 40 - 1, 3, 3, PIX_SRC, pixsq, 0, 0);
pixRasterop(pixc, 80 - 1, 80 - 1, 3, 3, PIX_SRC, pixsq, 0, 0);
pixRasterop(pixc, 40 - 1, 160 - 1, 3, 3, PIX_SRC, pixsq, 0, 0);
pixSaveTiled(pixc, pixa, REDUCTION, 1, 20, 0);
regTestWritePixAndCheck(rp, pixc, IFF_PNG); /* 4 */
pixDisplayWithTitle(pixc, 100, 600, "4-cc", rp->display);
//.........这里部分代码省略.........
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:101,代码来源:seedspread_reg.c
示例18: main
main(int argc,
char **argv)
{
const char *str;
l_int32 equal, index, w, h;
BOX *box;
PIX *pixs, *pixd, *pixt, *pixd1, *pixd2, *pixd3;
PIX *pixt0, *pixt1, *pixt2, *pixt3, *pixt4;
PIXA *pixa;
PIXCMAP *cmap;
static char mainName[] = "grayquant_reg";
if ((pixs = pixRead("test8.jpg")) == NULL)
exit(ERROR_INT("pixs not made", mainName, 1));
pixa = pixaCreate(0);
pixSaveTiled(pixs, pixa, 1, 1, 20, 8);
/* threshold to 1 bpp */
pixd = pixThresholdToBinary(pixs, THRESHOLD);
pixSaveTiled(pixd, pixa, 1, 1, 20, 0);
pixWrite("/tmp/junkthr0.png", pixd, IFF_PNG);
pixDestroy(&pixd);
/* dither to 2 bpp, with and without colormap */
pixd = pixDitherTo2bpp(pixs, 1);
pixt = pixDitherTo2bpp(pixs, 0);
pixt2 = pixConvertGrayToColormap(pixt);
pixSaveTiled(pixd, pixa, 1, 1, 20, 0);
pixSaveTiled(pixt, pixa, 1, 0, 20, 0);
pixSaveTiled(pixt2, pixa, 1, 0, 20, 0);
pixWrite("/tmp/junkthr1.png", pixd, IFF_PNG);
pixWrite("/tmp/junkthr2.png", pixt, IFF_PNG);
pixWrite("/tmp/junkthr3.png", pixt2, IFF_PNG);
/* pixcmapWriteStream(stderr, pixGetColormap(pixd)); */
pixEqual(pixd, pixt2, &equal);
if (!equal)
fprintf(stderr, "Error: thr2 != thr3\n");
pixDestroy(&pixt);
pixDestroy(&pixt2);
pixDestroy(&pixd);
/* threshold to 2 bpp, with and without colormap */
pixd = pixThresholdTo2bpp(pixs, 4, 1);
pixt = pixThresholdTo2bpp(pixs, 4, 0);
pixt2 = pixConvertGrayToColormap(pixt);
pixSaveTiled(pixd, pixa, 1, 1, 20, 0);
pixSaveTiled(pixt, pixa, 1, 0, 20, 0);
pixSaveTiled(pixt2, pixa, 1, 0, 20, 0);
pixWrite("/tmp/junkthr4.png", pixd, IFF_PNG);
pixWrite("/tmp/junkthr5.png", pixt2, IFF_PNG);
pixEqual(pixd, pixt2, &equal);
if (!equal)
fprintf(stderr, "Error: thr4 != thr5\n");
pixDestroy(&pixt);
pixDestroy(&pixt2);
pixDestroy(&pixd);
pixd = pixThresholdTo2bpp(pixs, 3, 1);
pixt = pixThresholdTo2bpp(pixs, 3, 0);
pixSaveTiled(pixd, pixa, 1, 1, 20, 0);
pixSaveTiled(pixt, pixa, 1, 0, 20, 0);
pixWrite("/tmp/junkthr6.png", pixd, IFF_PNG);
pixWrite("/tmp/junkthr7.png", pixt, IFF_PNG);
pixDestroy(&pixt);
pixDestroy(&pixd);
/* threshold to 4 bpp, with and without colormap */
pixd = pixThresholdTo4bpp(pixs, 9, 1);
pixt = pixThresholdTo4bpp(pixs, 9, 0);
pixt2 = pixConvertGrayToColormap(pixt);
pixSaveTiled(pixd, pixa, 1, 1, 20, 0);
pixSaveTiled(pixt, pixa, 1, 0, 20, 0);
pixSaveTiled(pixt2, pixa, 1, 0, 20, 0);
pixWrite("/tmp/junkthr8.png", pixd, IFF_PNG);
pixWrite("/tmp/junkthr9.png", pixt, IFF_PNG);
pixWrite("/tmp/junkthr10.png", pixt2, IFF_PNG);
/* pixcmapWriteStream(stderr, pixGetColormap(pixd)); */
pixDestroy(&pixt);
pixDestroy(&pixt2);
pixDestroy(&pixd);
/* threshold on 8 bpp, with and without colormap */
pixd = pixThresholdOn8bpp(pixs, 9, 1);
pixt = pixThresholdOn8bpp(pixs, 9, 0);
pixt2 = pixConvertGrayToColormap(pixt);
pixSaveTiled(pixd, pixa, 1, 1, 20, 0);
pixSaveTiled(pixt, pixa, 1, 0, 20, 0);
pixSaveTiled(pixt2, pixa, 1, 0, 20, 0);
pixWrite("/tmp/junkthr11.png", pixd, IFF_PNG);
pixWrite("/tmp/junkthr12.png", pixt2, IFF_PNG);
/* pixcmapWriteStream(stderr, pixGetColormap(pixd)); */
pixEqual(pixd, pixt2, &equal);
if (!equal)
fprintf(stderr, "Error: thr11 != thr12\n");
pixDestroy(&pixt);
pixDestroy(&pixt2);
pixDestroy(&pixd);
pixd1 = pixaDisplay(pixa, 0, 0);
//.........这里部分代码省略.........
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:101,代码来源:grayquant_reg.c
示例19: TestDistance
static void
TestDistance(PIXA *pixa,
PIX *pixs,
l_int32 conn,
l_int32 depth,
l_int32 bc,
l_int32 *pcount,
L_REGPARAMS *rp)
{
PIX *pixt1, *pixt2, *pixt3, *pixt4, *pixt5;
/* Test the distance function and display */
pixInvert(pixs, pixs);
pixt1 = pixDistanceFunction(pixs, conn, depth, bc);
regTestWritePixAndCheck(pixt1, IFF_PNG, pcount, rp);
pixSaveTiled(pixt1, pixa, 1, 1, 20, 0);
pixInvert(pixs, pixs);
pixt2 = pixMaxDynamicRange(pixt1, L_LOG_SCALE);
regTestWritePixAndCheck(pixt2, IFF_JFIF_JPEG, pcount, rp);
pixSaveTiled(pixt2, pixa, 1, 0, 20, 0);
pixDestroy(&pixt1);
pixDestroy(&pixt2);
/* Test the distance function and display with contour rendering */
pixInvert(pixs, pixs);
pixt1 = pixDistanceFunction(pixs, conn, depth, bc);
regTestWritePixAndCheck(pixt1, IFF_PNG, pcount, rp);
pixSaveTiled(pixt1, pixa, 1, 1, 20, 0);
pixInvert(pixs, pixs);
pixt2 = pixRenderContours(pixt1, 2, 4, 1); /* binary output */
regTestWritePixAndCheck(pixt2, IFF_PNG, pcount, rp);
pixSaveTiled(pixt2, pixa, 1, 0, 20, 0);
pixt3 = pixRenderContours(pixt1, 2, 4, depth);
pixt4 = pixMaxDynamicRange(pixt3, L_LINEAR_SCALE);
regTestWritePixAndCheck(pixt4, IFF_JFIF_JPEG, pcount, rp);
pixSaveTiled(pixt4, pixa, 1, 0, 20, 0);
pixt5 = pixMaxDynamicRange(pixt3, L_LOG_SCALE);
regTestWritePixAndCheck(pixt5, IFF_JFIF_JPEG, pcount, rp);
pixSaveTiled(pixt5, pixa, 1, 0, 20, 0);
pixDestroy(&pixt1);
pixDestroy(&pixt2);
pixDestroy(&pixt3);
pixDestroy(&pixt4);
pixDestroy(&pixt5);
/* Label all pixels in each c.c. with a color equal to the
* max distance of any pixel within that c.c. from the bg.
* Note that we've normalized so the dynamic range extends
* to 255. For the image here, each unit of distance is
* represented by about 21 grayscale units. The largest
* distance is 12. */
if (depth == 8) {
pixt1 = pixDistanceFunction(pixs, conn, depth, bc);
pixt4 = pixMaxDynamicRange(pixt1, L_LOG_SCALE);
regTestWritePixAndCheck(pixt4, IFF_JFIF_JPEG, pcount, rp);
pixSaveTiled(pixt4, pixa, 1, 1, 20, 0);
pixt2 = pixCreateTemplate(pixt1);
pixSetMasked(pixt2, pixs, 255);
regTestWritePixAndCheck(pixt2, IFF_JFIF_JPEG, pcount, rp);
pixSaveTiled(pixt2, pixa, 1, 0, 20, 0);
pixSeedfillGray(pixt1, pixt2, 4);
pixt3 = pixMaxDynamicRange(pixt1, L_LINEAR_SCALE);
regTestWritePixAndCheck(pixt3, IFF_JFIF_JPEG, pcount, rp);
pixSaveTiled(pixt3, pixa, 1, 0, 20, 0);
pixDestroy(&pixt1);
pixDestroy(&pixt2);
pixDestroy(&pixt3);
pixDestroy(&pixt4);
}
return;
}
开发者ID:AngusHardie,项目名称:TesseractOCR-For-Mac,代码行数:72,代码来源:distance_reg.c
示例20: main
main(int argc,
char **argv)
{
l_int32 i, n, ws, hs, w, h, rval, gval, bval, order;
l_float32 *mat1, *mat2, *mat3;
l_float32 matd[9];
BOX *box, *boxt;
BOXA *boxa, *boxat, *boxa1, *boxa2, *boxa3, *boxa4, *boxa5;
PIX *pix, *pixs, *pixb, *pixc, *pixt, *pixt1, *pixt2, *pixt3;
PIXA *pixa;
static char mainName[] = "xformbox_reg";
/* ----------------------------------------------------------- *
* Test hash rendering in 3 modes *
* ----------------------------------------------------------- */
pixs = pixRead("fey
|
请发表评论