Skip to content

Commit

Permalink
feat(pvalue,pextrem): Added -O option to report watts/sr/meter^2 always
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregungory committed Feb 4, 2022
1 parent 56ae573 commit 3fa15eb
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 25 deletions.
8 changes: 6 additions & 2 deletions doc/man/man1/pextrem.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions doc/man/man1/pvalue.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions doc/notes/ReleaseNotes
Original file line number Diff line number Diff line change
Expand Up @@ -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.
21 changes: 11 additions & 10 deletions src/px/pextrem.c
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;


Expand All @@ -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 */
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/px/phisto.csh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/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
#
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
Expand Down
10 changes: 5 additions & 5 deletions src/px/phisto.pl
Original file line number Diff line number Diff line change
@@ -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
#
Expand All @@ -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 ( $? );
}
}
Expand All @@ -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 ( $? );
}
}
Expand Down
16 changes: 14 additions & 2 deletions src/px/pvalue.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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] == '+')
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 3fa15eb

Please sign in to comment.