Compare commits

...

3 Commits

Author SHA1 Message Date
tth
b0fe0091d4 another scaling computation... 2019-09-17 11:22:00 +02:00
tth
f3d2dd6034 trying a new scaling method for saving in pnm 2019-09-17 11:21:20 +02:00
tth
d4dbecc45d always triple check your patchen 2019-09-16 16:27:01 +02:00
3 changed files with 20 additions and 10 deletions

View File

@ -58,7 +58,7 @@ int fimg_sub(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_mul(FloatImg *a, FloatImg *b, FloatImg *d); int fimg_mul(FloatImg *a, FloatImg *b, FloatImg *d);
/* PNM files module */ /* PNM files module */
int fimg_save_as_pnm(FloatImg *head, char *fname, int notused); int fimg_save_as_pnm(FloatImg *head, char *fname, int flags);
int fimg_load_from_pnm(char *fname, FloatImg *head, int notused); int fimg_load_from_pnm(char *fname, FloatImg *head, int notused);
double fimg_timer_set(int whot); double fimg_timer_set(int whot);

View File

@ -131,17 +131,17 @@ fputs("\n", fp);
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* /*
* * bit 0 of flags : use fvalue/count
*/ */
int fimg_save_as_pnm(FloatImg *head, char *fname, int notused) int fimg_save_as_pnm(FloatImg *head, char *fname, int flags)
{ {
FILE *fp; FILE *fp;
float maximum, fk; float maximum, fk;
char *code; char *code;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %-25s ( %p '%s' %d )\n", __func__, head, fprintf(stderr, ">>> %-25s ( %p '%s' 0x%04x )\n", __func__, head,
fname, notused); fname, flags);
#endif #endif
if ( head->type != FIMG_TYPE_RGB && head->type != FIMG_TYPE_GRAY) { if ( head->type != FIMG_TYPE_RGB && head->type != FIMG_TYPE_GRAY) {
@ -163,10 +163,18 @@ switch(head->type) {
fprintf(fp, "%s\n%d %d\n", code, head->width, head->height); fprintf(fp, "%s\n%d %d\n", code, head->width, head->height);
maximum = fimg_get_maxvalue(head); if ( flags & 1 ) {
fprintf(fp, "# maxval %15f\n", maximum); fprintf(stderr, "%s using fval/count %f %d -> %f\n", __func__,
fk = maximum / 65535.0; head->fval, head->count,
fprintf(fp, "# divisor %15f\n", fk); head->fval * head->count);
fk = (head->fval * head->count) / 65535.0;
}
else {
maximum = fimg_get_maxvalue(head);
fk = maximum / 65535.0;
fprintf(fp, "# maxval %15f\n# divisor %15f\n", maximum, fk);
}
fprintf(fp, "65535\n"); fprintf(fp, "65535\n");
fflush(fp); fflush(fp);

View File

@ -129,6 +129,7 @@ while ((opt = getopt(argc, argv, "d:ghn:o:O:p:s:uv")) != -1) {
optarg); optarg);
exit(1); exit(1);
} }
period *= 1e6;
break; break;
case 's': parse_WxH(optarg, &width, &height); case 's': parse_WxH(optarg, &width, &height);
break; break;
@ -141,6 +142,7 @@ if (verbosity) {
fprintf(stderr, "running %s pid=%d\n", argv[0], getpid()); fprintf(stderr, "running %s pid=%d\n", argv[0], getpid());
fprintf(stderr, "period is %.3f milliseconds\n", period/1e3); fprintf(stderr, "period is %.3f milliseconds\n", period/1e3);
fprintf(stderr, "framesize is %dx%d\n", width, height); fprintf(stderr, "framesize is %dx%d\n", width, height);
fprintf(stderr, "upscaling is %s\n", upscaling ? "on" : "off");
} }
fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0); fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
@ -311,7 +313,7 @@ if (to_gray) {
// save cumul to file // save cumul to file
if (verbosity) fprintf(stderr, "saving to '%s'\n", outfile); if (verbosity) fprintf(stderr, "saving to '%s'\n", outfile);
foo = fimg_save_as_pnm(&cumul, outfile, 0); foo = fimg_save_as_pnm(&cumul, outfile, 1);
// free buffers // free buffers
fimg_destroy(&cumul); fimg_destroy(&cumul);