1 #include "jpeg-utils/jpeg-utils.h"
8 int main(
int argc,
char *argv[])
10 char *path = NULL, *outPath = NULL;
11 int n = 6, retval = EXIT_FAILURE, benchmark = 0;
13 double scaleDown = 0.45;
14 unsigned long long ctr, maxCtr = 1;
15 double startTime, endTime;
18 ImageData imgData, outData;
25 fprintf(stderr,
"Usage ./kaleidoscope <Input Image Path> <Output Image Path> <N>\n");
27 "Usage ./kaleidoscope <Input Image Path> <Output Image Path> <N> <Dim constant> <Scale factor>\n");
30 fprintf(stderr,
"Start...\n");
38 maxCtr = atoll(argv[4]);
43 scaleDown = atof(argv[5]);
49 fprintf(stderr,
"n should be greater than 2");
52 if (scaleDown < 0.0 || scaleDown > 1.0)
54 fprintf(stderr,
"Scale factor should be between 0.0 and 1.0");
59 fprintf(stderr,
"Reading %s ... ", path);
60 if ((retval = readImage(path, &imgData)))
62 fprintf(stderr,
" %d\n", !retval);
64 fprintf(stderr,
"Initializing ... ");
65 if (initImageData(&outData, imgData.width, imgData.height, imgData.nComponents))
67 if ((retval =
initKaleidoscope(&handler, n, imgData.
width, imgData.height, imgData.nComponents, scaleDown)))
69 fprintf(stderr,
" %d\n", !retval);
71 fprintf(stderr,
"Processing ...");
72 startTime = (float)clock() / CLOCKS_PER_SEC;
73 for (ctr = 0; ctr < maxCtr; ++ctr)
79 endTime = (float)clock() / CLOCKS_PER_SEC;
80 fprintf(stderr,
" 1\n");
83 fprintf(stderr,
"FPS %5.3f\n", 1 / ((endTime - startTime) / maxCtr));
85 fprintf(stderr,
"Saving %s... ", outPath);
86 if ((retval = saveImage(outPath, &outData, TJPF_RGB, TJSAMP_444, 90)))
88 fprintf(stderr,
" %d\n", !retval);
90 deInitImageData(&imgData);
91 deInitImageData(&outData);
94 fprintf(stderr,
"Done...\n");
int main(int argc, char *argv[])
char * getKaleidoscopeLibraryInfo()
Get the Kaleidoscope Library info as string.
int initKaleidoscope(KaleidoscopeHandle *handler, int n, int width, int height, int nComponents, double scaleDown)
Initializes kaleidoscope handler.
void processKaleidoscope(KaleidoscopeHandle *handler, double k, unsigned char *imgIn, unsigned char *imgOut)
Applies kaleidoscope effect to image.
void deInitKaleidoscope(KaleidoscopeHandle *handler)
Deinitializes kaleidoscope handler.
Struct for kaleidoscope effect generator.