ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/evalglare.c
(Generate patch)

Comparing ray/src/util/evalglare.c (file contents):
Revision 2.5 by greg, Tue Aug 2 16:35:01 2016 UTC vs.
Revision 2.8 by greg, Fri Aug 31 16:01:45 2018 UTC

# Line 1 | Line 1
1   #ifndef lint
2   static const char RCSid[] = "$Id$";
3   #endif
4 < /* EVALGLARE V1.31
4 > /* EVALGLARE V2.06
5   * Evalglare Software License, Version 2.0
6   *
7   * Copyright (c) 1995 - 2016 Fraunhofer ISE, EPFL.
# Line 312 | Line 312 | changed masking threshold to 0.05 cd/m2
312     */
313   /* evalglare.c, v1.31 2016/08/02  bug removal: default output did not calculate the amout of glare sources before and therefore no_glaresources was set to zero causing dgi,ugr being set to zero as well. Now renumbering of the glare sources and calculation of the amount of glare sources is done for all output versions.
314     */
315 + /* evalglare.c, v2.00 2016/11/15  add of a second fast calculation mode for annual calculations, activted by -2. Output: dgp,ugr
316 +   */
317 + /* evalglare.c, v2.01 2016/11/16  change of -2 option (now -2 dir_illum). External provision of the direct illuminance necessary, since the sun interpolation of daysim is causing problems in calculation of the background luminance.
318 +   */
319 + /* evalglare.c, v2.02 2017/02/28  change of warning message, when invalid exposure setting is found. Reason: tab removal is not in all cases the right measure - it depends which tool caused the invalid exposure entry   */
320 +
321 + /* evalglare.c, v2.03 2017/08/04  ad of -O option - disk replacement by providing luminance, not documented
322 +  */
323 +
324 + /* evalglare.c, v2.04 2017/08/04  adding -q option: use of Ev/pi as background luminance. not documented. no combination with -n option!!!
325 +  */
326 +
327 + /* evalglare.c, v2.05 2018/08/28  change of the -q option for the choice of the background luminance calculation mode: 0: CIE method (Ev-Edir)/pi, 1: mathematical correct average background luminance, 2: Ev/pi.
328 + change of default options:
329 + - cosinus weighted calculation of the background luminance (according to CIE) is now default.
330 + - absolute threshold for the glare source detection is now default (2000cd/m2), based on study of C. Pierson
331 +  */
332 +
333 + /* evalglare.c, v2.06 2018/08/29  
334 + change of default value of multiplier b to 5.0, if task options (-t or -T ) are activated AND -b NOT used. To be downward compatible when using the task method.
335 +  */
336 +
337 +  
338   #define EVALGLARE
339   #define PROGNAME "evalglare"
340 < #define VERSION "1.31 release 02.08.2016 by EPFL, J.Wienold"
340 > #define VERSION "2.06 release 29.08.2018 by EPFL, J.Wienold"
341   #define RELEASENAME PROGNAME " " VERSION
342  
343  
# Line 1201 | Line 1224 | float get_ugr(pict * p, double lum_backg, int igs, int
1224                  }
1225          }
1226          ugr = 8 * log10(0.25 / lum_backg * sum_glare);
1227 <
1227 >        if (sum_glare==0) {
1228 >        ugr=0.0;
1229 >        }
1230 >        if (lum_backg<=0) {
1231 >        ugr=-99.0;
1232 >        }
1233 >        
1234          return ugr;
1235  
1236   }
# Line 1373 | Line 1402 | int main(int argc, char **argv)
1402          pict *pm = pict_create();
1403          int     skip_second_scan,calcfast,age_corr,cut_view,cut_view_type,calc_vill, output, detail_out2, x1,y1, fill, yfillmax, yfillmin,
1404                  ext_vill, set_lum_max, set_lum_max2, img_corr,x_disk,y_disk,task_color, i_splitstart,zones,act_gsn,splitgs,
1405 <                i_split, posindex_2, task_lum, checkfile, rval, i, i_max, x, y,x2,y2,x_zone,y_zone, i_z1, i_z2,
1405 >                i_split, posindex_2, task_lum, checkfile, rval, i, i_max, x, y,x2,y2,x_zone,y_zone, i_z1, i_z2, thres_activate,
1406                  igs, actual_igs, lastpixelwas_gs, icol, xt, yt, change,checkpixels, before_igs, sgs, splithigh,uniform_gs,x_max, y_max,y_mid,
1407                  detail_out, posindex_picture, non_cos_lb, rx, ry, rmx,rmy,apply_disability,band_calc,band_color,masking,i_mask,no_glaresources,force;
1408 <        double  lum_total_max,age_corr_factor,age,dgp_ext,dgp,low_light_corr,omega_cos_contr, setvalue, lum_ideal, E_v_contr, sigma,om,delta_E,
1408 >        double  LUM_replace,lum_total_max,age_corr_factor,age,dgp_ext,dgp,low_light_corr,omega_cos_contr, setvalue, lum_ideal, E_v_contr, sigma,om,delta_E,
1409                  E_vl_ext, lum_max, new_lum_max, r_center, ugp, ugr_exp, dgi_mod,lum_a, pgsv,E_v_mask,pgsv_sat,angle_disk,dist,n_corner_px,zero_corner_px,
1410 <                search_pix, a1, a2, a3, a4, a5, c3, c1, c2, r_split, max_angle,r_actual,lum_actual,
1410 >                search_pix, a1, a2, a3, a4, a5, c3, c1, c2, r_split, max_angle,r_actual,lum_actual,dir_ill,
1411                  omegat, sang, E_v, E_v2, E_v_dir, avlum, act_lum, ang, angle_z1, angle_z2,per_95_band,per_75_band,pos,
1412                  l_max, lum_backg, lum_backg_cos, omega_sources, lum_sources,per_75_mask,per_95_mask,per_75_z1,per_95_z1,per_75_z2,per_95_z2,
1413                  lum, lum_source,teta,Lveil_cie,Lveil_cie_sum,disability_thresh,u_r,u_g,u_b,band_angle,band_avlum,
# Line 1427 | Line 1456 | int main(int argc, char **argv)
1456          muc_rvar_clear(s_posweight2);
1457  
1458          /*set required user view parameters to invalid values*/
1459 +        dir_ill=0.0;
1460          delta_E=0.0;
1461          no_glaresources=0;
1462          n_corner_px=0;
# Line 1489 | Line 1519 | int main(int argc, char **argv)
1519          omega_cos_contr = 0.0;
1520          lum_ideal = 0.0;
1521          max_angle = 0.2;
1522 <        lum_thres = 5.0;
1522 >        lum_thres = 2000.0;
1523          task_lum = 0;
1524          sgs = 0;
1525          splithigh = 1;
# Line 1507 | Line 1537 | int main(int argc, char **argv)
1537          c1 = 5.87e-05;
1538          c2 = 0.092;
1539          c3 = 0.159;
1540 <        non_cos_lb = 1;
1540 >        non_cos_lb = 0;
1541          posindex_2 = 0;
1542          task_color = 0;
1543          limit = 50000.0;
# Line 1529 | Line 1559 | int main(int argc, char **argv)
1559          omega_mask=0.0;
1560          i_mask=0;
1561          actual_igs=0;
1562 +        LUM_replace=0;
1563 +        thres_activate=0;
1564   /* command line for output picture*/
1565  
1566          cline = (char *) malloc(CLINEMAX+1);
# Line 1579 | Line 1611 | int main(int argc, char **argv)
1611                          break;
1612                  case 'b':
1613                          lum_thres = atof(argv[++i]);
1614 +                        thres_activate = 1;
1615                          break;
1616                  case 'c':
1617                          checkfile = 1;
# Line 1667 | Line 1700 | int main(int argc, char **argv)
1700                          strcpy(file_out2, argv[++i]);
1701   /*                      printf("max lum set to %f\n",new_lum_max);*/
1702                          break;
1703 +                case 'O':
1704 +                        img_corr = 1;
1705 +                        set_lum_max2 = 3;
1706 +                        x_disk = atoi(argv[++i]);
1707 +                        y_disk = atoi(argv[++i]);
1708 +                        angle_disk = atof(argv[++i]);
1709 +                        LUM_replace = atof(argv[++i]);
1710 +                        strcpy(file_out2, argv[++i]);
1711 + /*                      printf("max lum set to %f\n",new_lum_max);*/
1712 +                        break;
1713  
1714 <                case 'n':
1714 >
1715 > /* deactivated          case 'n':
1716                          non_cos_lb = 0;
1717                          break;
1718 + */
1719 +                case 'q':
1720 +                        non_cos_lb = atoi(argv[++i]);
1721 +                        break;
1722  
1723                  case 't':
1724                          task_lum = 1;
# Line 1739 | Line 1787 | int main(int argc, char **argv)
1787                  case '1':
1788                          output = 1;
1789                          break;
1790 +                case '2':
1791 +                        output = 2;
1792 +                        dir_ill = atof(argv[++i]);
1793 +                        break;
1794  
1795                  case 'v':
1796                          if (argv[i][2] == '\0') {
# Line 1768 | Line 1820 | int main(int argc, char **argv)
1820                  }
1821          }
1822  
1823 + /* set multiplier for task method to 5, if not specified */
1824 +
1825 + if ( task_lum == 1 && thres_activate == 0){
1826 +                lum_thres = 5.0;
1827 + }
1828   /*fast calculation, if gendgp_profile is used: No Vertical illuminance calculation, only dgp is calculated*/
1829  
1830 < if (output == 1 && ext_vill == 1) {
1830 > if (output == 1 && ext_vill == 1 ) {
1831                         calcfast=1;
1832                         }
1833 +                      
1834 + if (output == 2 && ext_vill == 1 ) {
1835 +                       calcfast=2;
1836 +                       }
1837 +                      
1838   /*masking and zoning cannot be applied at the same time*/
1839  
1840   if (masking ==1 && zones >0) {
# Line 2061 | Line 2123 | if (cut_view==2) {
2123          lum_pos_mean= lum_pos_mean/sang;
2124          lum_pos2_mean= lum_pos2_mean/sang;
2125  
2126 <        if (set_lum_max2 >= 1 && E_v_contr > 0 && (E_vl_ext - E_v) > 0) {
2126 >        if ((set_lum_max2 >= 1 && E_v_contr > 0 && (E_vl_ext - E_v) > 0 ) || set_lum_max2==3) {
2127  
2128 +                if (set_lum_max2<3){
2129                  lum_ideal = (E_vl_ext - E_v + E_v_contr) / omega_cos_contr;
2130                  if (set_lum_max2 == 2 && lum_ideal >= 2e9) {
2131                  printf("warning! luminance of replacement pixels would be larger than 2e9 cd/m2. Value set to 2e9cd/m2!\n") ;
# Line 2073 | Line 2136 | if (cut_view==2) {
2136                  }
2137                  printf("change luminance values!! lum_ideal,setvalue,E_vl_ext,E_v,E_v_contr %f  %f %f %f %f\n",
2138                           lum_ideal, setvalue, E_vl_ext, E_v, E_v_contr);
2139 +                          }else{setvalue=LUM_replace;
2140 +                         }
2141  
2142              
2143                  for (x = 0; x < pict_get_xsize(p); x++)
# Line 2092 | Line 2157 | if (cut_view==2) {
2157                                                          pict_get_color(p, x, y)[BLU] =
2158                                                                  setvalue / 179.0;
2159  
2160 <                                                }else{ if(set_lum_max2 ==2 ) {
2160 >                                                }else{ if(set_lum_max2 >1 ) {
2161                                                          r_actual =acos(DOT(pict_get_cached_dir(p, x_disk, y_disk), pict_get_cached_dir(p, x, y))) * 2;
2162                                                          if (x_disk == x && y_disk==y ) r_actual=0.0;
2163  
# Line 2105 | Line 2170 | if (cut_view==2) {
2170                                                          pict_get_color(p, x, y)[BLU] =
2171                                                                  setvalue / 179.0;
2172                                                        
2173 <                                                       }
2109 <                                                                
2110 <                                                
2173 >                                                       }                                                
2174                                                  }
2175                                                  }
2176                                          }
# Line 2223 | Line 2286 | if (cut_view==1) {
2286   /*      pict_write(p,"firstscan.pic");   */
2287  
2288  
2289 < if (calcfast == 1 || search_pix <= 1.0) {
2289 >
2290 >
2291 > if (calcfast ==1 || search_pix <= 1.0 || calcfast == 2 ) {
2292     skip_second_scan=1;
2293     }
2294 +  
2295  
2296   /* second glare source scan: combine glare sources facing each other */
2297          change = 1;
# Line 2400 | Line 2466 | if (calcfast == 1 || search_pix <= 1.0) {
2466  
2467   /* calculation of direct vertical illuminance for CGI and for disability glare, coloring glare sources*/
2468  
2469 <        if (calcfast == 0) {
2469 >        if (calcfast == 0 || calcfast == 2) {
2470          for (x = 0; x < pict_get_xsize(p); x++)
2471                  for (y = 0; y < pict_get_ysize(p); y++) {
2472                          if (pict_get_hangle(p, x, y, p->view.vdir, p->view.vup, &ang)) {
# Line 2488 | Line 2554 | if (calcfast == 1 || search_pix <= 1.0) {
2554                          lum_backg = lum_backg_cos;
2555          }
2556  
2557 +        if (non_cos_lb == 2) {
2558 +                        lum_backg = E_v / 3.1415927;
2559 +        }
2560 +
2561 +
2562   /* file writing NOT here
2563          if (checkfile == 1) {
2564                  pict_write(p, file_out);
# Line 2824 | Line 2895 | if (calcfast == 0) {
2895                                  if (E_vl_ext < 1000) {
2896                                  low_light_corr=1.0*exp(0.024*E_vl_ext-4)/(1+exp(0.024*E_vl_ext-4)); } else {low_light_corr=1.0 ;}
2897                                  dgp =low_light_corr*dgp;
2898 <                                dgp =age_corr_factor*dgp;
2899 <                printf("%f\n", dgp);
2898 >
2899 >                     if (calcfast == 2) {
2900 >                    
2901 >                         lum_backg_cos=(E_vl_ext-dir_ill)/3.1415927;
2902 >                         ugr = get_ugr(p, lum_backg_cos, igs, posindex_2);
2903 >                         printf("%f %f \n", dgp,ugr);
2904 >                     }else{      
2905 >                         printf("%f\n", dgp);
2906 >                }
2907          }
2908  
2909  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines