ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/phisto.pl
Revision: 2.1
Committed: Fri Jan 3 20:05:14 2020 UTC (4 years, 4 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R3
Log Message:
Converted phisto.csh to Perl script for Windows

File Contents

# User Rev Content
1 greg 2.1 #!/usr/bin/perl -w
2     # RCSid $Id: genBSDF.pl,v 2.83 2019/06/10 13:58:49 greg Exp $
3     #
4     # Compute foveal histogram for picture set
5     #
6     # G. Ward
7     #
8     use strict;
9     my $windoz = ($^O eq "MSWin32" or $^O eq "MSWin64");
10     use File::Temp qw/ :mktemp /;
11     my $minop = 'L=$1*179;$1=if(L-1e-7,log10(L)-.01,-7)';
12     my $maxop = '$1=log10($1*179)+.01';
13     my $tf;
14     if ($windoz) {
15     my $tmploc = `echo \%TMP\%`;
16     chomp $tmploc;
17     $tf = mktemp("$tmploc\\phdXXXXXX");
18     chomp $tf;
19     if ($#ARGV < 0) {
20     system "pfilt -1 -x 128 -y 128 -p 1 " .
21     "| pvalue -o -h -H -d -b > $tf";
22     } else {
23     foreach (@ARGV) {
24     system "pfilt -1 -x 128 -y 128 -p 1 $_" .
25     "| pvalue -o -h -H -d -b >> $tf";
26     die "Bad picture '$_'\n" if ( $? );
27     }
28     }
29     my $Lmin=`total -l $tf | rcalc -e "$minop"`;
30     my $Lmax=`total -u $tf | rcalc -e "$maxop"`;
31     chomp $Lmin;
32     chomp $Lmax;
33     system q[rcalc -e "L=$1*179;cond=L-1e-7;$1=log10(L)" ] . $tf .
34     " | histo $Lmin $Lmax 777";
35     } else {
36     $tf = mktemp("/tmp/phdXXXXXX");
37     chomp $tf;
38     if ($#ARGV < 0) {
39     system "pfilt -1 -x 128 -y 128 -p 1 " .
40     "| pvalue -o -h -H -df -b > $tf";
41     } else {
42     foreach (@ARGV) {
43     system "pfilt -1 -x 128 -y 128 -p 1 '$_'" .
44     "| pvalue -o -h -H -df -b >> $tf";
45     die "Bad picture '$_'\n" if ( $? );
46     }
47     }
48     my $Lmin=`total -if -l $tf | rcalc -e '$minop'`;
49     my $Lmax=`total -if -u $tf | rcalc -e '$maxop'`;
50     chomp $Lmin;
51     chomp $Lmax;
52     system q[rcalc -if -e 'L=$1*179;cond=L-1e-7;$1=log10(L)' ] . $tf .
53     " | histo $Lmin $Lmax 777";
54     }
55     unlink $tf;