From 3fa15ebe267b3c2d8fa5642364f229290241af0f Mon Sep 17 00:00:00 2001 From: "Gregory J. Ward" Date: Fri, 4 Feb 2022 20:11:48 +0000 Subject: [PATCH] feat(pvalue,pextrem): Added -O option to report watts/sr/meter^2 always --- doc/man/man1/pextrem.1 | 8 ++++++-- doc/man/man1/pvalue.1 | 7 ++++--- doc/notes/ReleaseNotes | 3 +++ src/px/pextrem.c | 21 +++++++++++---------- src/px/phisto.csh | 6 +++--- src/px/phisto.pl | 10 +++++----- src/px/pvalue.c | 16 ++++++++++++++-- 7 files changed, 46 insertions(+), 25 deletions(-) diff --git a/doc/man/man1/pextrem.1 b/doc/man/man1/pextrem.1 index 12f999427..8518ab55e 100644 --- a/doc/man/man1/pextrem.1 +++ b/doc/man/man1/pextrem.1 @@ -1,11 +1,11 @@ -.\" RCSid "$Id: pextrem.1,v 1.2 2003/12/09 15:59:06 greg Exp $" +.\" RCSid "$Id: pextrem.1,v 1.3 2022/02/04 20:11:48 greg Exp $" .TH PEXTREM 1 11/15/93 RADIANCE .SH NAME pextrem - find minimum and maximum values in RADIANCE picture .SH SYNOPSIS .B pextrem [ -.B \-o +.B "-o | -O" ] [ picture @@ -25,6 +25,10 @@ The .I \-o option prints the original (radiance) values, undoing any exposure or color correction done on the picture. +If the input is XYZE, then the second channel is in candelas/meter^2, +unless +.I \-O +is specified, when watts/sr/meter^2 are always reported. .PP If no input .I picture diff --git a/doc/man/man1/pvalue.1 b/doc/man/man1/pvalue.1 index f7bbad6b0..09d139169 100644 --- a/doc/man/man1/pvalue.1 +++ b/doc/man/man1/pvalue.1 @@ -1,4 +1,4 @@ -.\" RCSid "$Id: pvalue.1,v 1.11 2019/07/18 14:45:59 greg Exp $" +.\" RCSid "$Id: pvalue.1,v 1.12 2022/02/04 20:11:48 greg Exp $" .TH PVALUE 1 1/15/99 RADIANCE .SH NAME pvalue - convert RADIANCE picture to/from alternate formats @@ -53,8 +53,9 @@ turns this option off, which is the default. .BR \-o Print original values, before exposure compensation. If the input file is in XYZE format, the Y (green) channel -will correspond to units of candelas/meter^2. -Otherwise, the RGB values should be in spectral watts/steradian/meter^2. +will correspond to units of candelas/meter^2, unless +.I \-O +is specified, when watts/sr/meter^2 are always reported. Specifying .I \+o uses final exposed values, which is the default. diff --git a/doc/notes/ReleaseNotes b/doc/notes/ReleaseNotes index bcde3da9a..d09f18f99 100644 --- a/doc/notes/ReleaseNotes +++ b/doc/notes/ReleaseNotes @@ -2501,3 +2501,6 @@ discovered and reported by Jon Sargent. Created checkBSDF tool to test XML BSDF reciprocity and perform similar sanity checks. + +Added -O option to pvalue and pextrem to report watts/sr/m^2 even if +picture is XYZE. diff --git a/src/px/pextrem.c b/src/px/pextrem.c index 9312935bd..756d0999f 100644 --- a/src/px/pextrem.c +++ b/src/px/pextrem.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pextrem.c,v 2.14 2019/07/19 17:37:56 greg Exp $"; +static const char RCSid[] = "$Id: pextrem.c,v 2.15 2022/02/04 20:11:49 greg Exp $"; #endif /* * Find extrema points in a Radiance picture. @@ -15,10 +15,10 @@ static const char RCSid[] = "$Id: pextrem.c,v 2.14 2019/07/19 17:37:56 greg Exp int orig = 0; -int wrongformat = 0; - COLOR expos = WHTCOLOR; +char fmt[MAXFMTLEN]; + static gethfunc headline; @@ -28,14 +28,11 @@ headline( /* check header line */ void *p ) { - char fmt[MAXFMTLEN]; double d; COLOR ctmp; - if (isformat(s)) { /* format */ - formatval(fmt, s); - wrongformat = !globmatch(PICFMT, fmt); - } + if (formatval(fmt, s)) /* format */ + return(0); if (!orig) return(0); if (isexpos(s)) { /* exposure */ @@ -66,7 +63,9 @@ main( SET_FILE_BINARY(stdin); for (i = 1; i < argc; i++) /* get options */ if (!strcmp(argv[i], "-o")) - orig++; + orig = 1; + else if (!strcmp(argv[i], "-O")) + orig = -1; else break; @@ -76,11 +75,13 @@ main( exit(1); } /* get our header */ - if (getheader(stdin, headline, NULL) < 0 || wrongformat || + if (getheader(stdin, headline, NULL) < 0 || !globmatch(PICFMT, fmt) || fgetresolu(&xres, &yres, stdin) < 0) { fprintf(stderr, "%s: bad picture format\n", argv[0]); exit(1); } + if (orig < 0 && !strcmp(CIEFMT, fmt)) + scalecolor(expos, 1./WHTEFFICACY); if ((scan = (COLR *)malloc(xres*sizeof(COLR))) == NULL) { fprintf(stderr, "%s: out of memory\n", argv[0]); exit(1); diff --git a/src/px/phisto.csh b/src/px/phisto.csh index 9d317c564..91cd04f1a 100644 --- a/src/px/phisto.csh +++ b/src/px/phisto.csh @@ -1,5 +1,5 @@ #!/bin/csh -f -# RCSid: $Id: phisto.csh,v 3.7 2015/08/21 05:48:28 greg Exp $ +# RCSid: $Id: phisto.csh,v 3.8 2022/02/04 20:11:49 greg Exp $ # # Compute foveal histogram for picture set # @@ -7,12 +7,12 @@ set tf=`mktemp /tmp/phdat.XXXXX` onintr quit if ( $#argv == 0 ) then pfilt -1 -x 128 -y 128 -p 1 \ - | pvalue -o -h -H -df -b > $tf + | pvalue -O -h -H -df -b > $tf else rm -f $tf foreach i ( $* ) pfilt -1 -x 128 -y 128 -p 1 $i \ - | pvalue -o -h -H -df -b >> $tf + | pvalue -O -h -H -df -b >> $tf if ( $status ) exit 1 end endif diff --git a/src/px/phisto.pl b/src/px/phisto.pl index 9411e1220..adc44e2a3 100644 --- a/src/px/phisto.pl +++ b/src/px/phisto.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# RCSid $Id: phisto.pl,v 2.1 2020/01/03 20:05:14 greg Exp $ +# RCSid $Id: phisto.pl,v 2.2 2022/02/04 20:11:49 greg Exp $ # # Compute foveal histogram for picture set # @@ -18,11 +18,11 @@ chomp $tf; if ($#ARGV < 0) { system "pfilt -1 -x 128 -y 128 -p 1 " . - "| pvalue -o -h -H -d -b > $tf"; + "| pvalue -O -h -H -d -b > $tf"; } else { foreach (@ARGV) { system "pfilt -1 -x 128 -y 128 -p 1 $_" . - "| pvalue -o -h -H -d -b >> $tf"; + "| pvalue -O -h -H -d -b >> $tf"; die "Bad picture '$_'\n" if ( $? ); } } @@ -37,11 +37,11 @@ chomp $tf; if ($#ARGV < 0) { system "pfilt -1 -x 128 -y 128 -p 1 " . - "| pvalue -o -h -H -df -b > $tf"; + "| pvalue -O -h -H -df -b > $tf"; } else { foreach (@ARGV) { system "pfilt -1 -x 128 -y 128 -p 1 '$_'" . - "| pvalue -o -h -H -df -b >> $tf"; + "| pvalue -O -h -H -df -b >> $tf"; die "Bad picture '$_'\n" if ( $? ); } } diff --git a/src/px/pvalue.c b/src/px/pvalue.c index 660c4bb49..b85e90370 100644 --- a/src/px/pvalue.c +++ b/src/px/pvalue.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pvalue.c,v 2.40 2020/06/30 22:30:29 greg Exp $"; +static const char RCSid[] = "$Id: pvalue.c,v 2.41 2022/02/04 20:11:49 greg Exp $"; #endif /* * pvalue.c - program to print pixel values. @@ -118,6 +118,9 @@ main( case 'o': /* original values */ original = argv[i][0] == '-'; break; + case 'O': /* original watts/sr/m^2 */ + original = -(argv[i][0] == '-'); + break; case 'g': /* gamma correction */ gamcor = atof(argv[i+1]); if (argv[i][0] == '+') @@ -353,8 +356,13 @@ main( if (outprims != stdprims) fputprims(outprims, stdout); fputformat(COLRFMT, stdout); - } else /* XYZ data */ + } else { /* XYZ data */ + if (original < 0) { + scalecolor(exposure, WHTEFFICACY); + doexposure++; + } fputformat(CIEFMT, stdout); + } putchar('\n'); fputsresolu(&picres, stdout); /* always put resolution */ valtopix(); @@ -373,6 +381,10 @@ main( fprintf(stderr, "%s: missing resolution\n", progname); quit(1); } + if (original < 0 && mybright == &xyz_bright) { + scalecolor(exposure, 1./WHTEFFICACY); + doexposure++; + } if (header) { printargs(i, argv, stdout); printf("NCOMP=%d\n", putprim==ALL ? 3 : 1);