1 |
|
#ifndef lint |
2 |
|
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
< |
/* EVALGLARE V2.00 |
4 |
> |
/* EVALGLARE V2.06 |
5 |
|
* Evalglare Software License, Version 2.0 |
6 |
|
* |
7 |
|
* Copyright (c) 1995 - 2016 Fraunhofer ISE, EPFL. |
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 "2.02 release 28.02.2017 by EPFL, J.Wienold" |
340 |
> |
#define VERSION "2.06 release 29.08.2018 by EPFL, J.Wienold" |
341 |
|
#define RELEASENAME PROGNAME " " VERSION |
342 |
|
|
343 |
|
|
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,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, |
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; |
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; |
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); |
1611 |
|
break; |
1612 |
|
case 'b': |
1613 |
|
lum_thres = atof(argv[++i]); |
1614 |
+ |
thres_activate = 1; |
1615 |
|
break; |
1616 |
|
case 'c': |
1617 |
|
checkfile = 1; |
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; |
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 ) { |
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") ; |
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++) |
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 |
|
|
2170 |
|
pict_get_color(p, x, y)[BLU] = |
2171 |
|
setvalue / 179.0; |
2172 |
|
|
2173 |
< |
} |
2131 |
< |
|
2132 |
< |
|
2173 |
> |
} |
2174 |
|
} |
2175 |
|
} |
2176 |
|
} |
2553 |
|
if (non_cos_lb == 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) { |