| 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 |
< |
|
| 320 |
> |
|
| 321 |
> |
/* evalglare.c, v2.03 2017/08/12 ad of -O option - disk replacement by providing luminance, not documented |
| 322 |
> |
remove some minor memory leakages, clean up initialization by C. Reetz |
| 323 |
> |
*/ |
| 324 |
> |
|
| 325 |
> |
|
| 326 |
> |
|
| 327 |
> |
#ifndef EVALGLARE |
| 328 |
|
#define EVALGLARE |
| 329 |
+ |
#endif |
| 330 |
|
#define PROGNAME "evalglare" |
| 331 |
< |
#define VERSION "2.02 release 28.02.2017 by EPFL, J.Wienold" |
| 331 |
> |
#define VERSION "2.03 release 12.08.2017 by EPFL, J.Wienold" |
| 332 |
|
#define RELEASENAME PROGNAME " " VERSION |
| 333 |
|
|
| 334 |
|
|
| 1396 |
|
i_split, posindex_2, task_lum, checkfile, rval, i, i_max, x, y,x2,y2,x_zone,y_zone, i_z1, i_z2, |
| 1397 |
|
igs, actual_igs, lastpixelwas_gs, icol, xt, yt, change,checkpixels, before_igs, sgs, splithigh,uniform_gs,x_max, y_max,y_mid, |
| 1398 |
|
detail_out, posindex_picture, non_cos_lb, rx, ry, rmx,rmy,apply_disability,band_calc,band_color,masking,i_mask,no_glaresources,force; |
| 1399 |
< |
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, |
| 1399 |
> |
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, |
| 1400 |
|
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, |
| 1401 |
|
search_pix, a1, a2, a3, a4, a5, c3, c1, c2, r_split, max_angle,r_actual,lum_actual,dir_ill, |
| 1402 |
|
omegat, sang, E_v, E_v2, E_v_dir, avlum, act_lum, ang, angle_z1, angle_z2,per_95_band,per_75_band,pos, |
| 1410 |
|
float lum_task, lum_thres, dgi, vcp, cgi, ugr, limit, dgr, |
| 1411 |
|
abs_max, Lveil; |
| 1412 |
|
char maskfile[500],file_out[500], file_out2[500], version[500]; |
| 1413 |
< |
char *cline; |
| 1413 |
> |
char *cline = NULL; |
| 1414 |
|
VIEW userview = STDVIEW; |
| 1415 |
|
int gotuserview = 0; |
| 1416 |
< |
struct muc_rvar* s_mask; |
| 1416 |
> |
struct muc_rvar* s_mask = NULL; |
| 1417 |
> |
struct muc_rvar* s_band = NULL; |
| 1418 |
> |
struct muc_rvar* s_z1 = NULL; |
| 1419 |
> |
struct muc_rvar* s_z2 = NULL; |
| 1420 |
> |
struct muc_rvar* s_noposweight = NULL; |
| 1421 |
> |
struct muc_rvar* s_posweight = NULL; |
| 1422 |
> |
struct muc_rvar* s_posweight2 = NULL; |
| 1423 |
> |
|
| 1424 |
> |
// initializing variables .... |
| 1425 |
> |
Lveil = lum_backg_cos = 0; |
| 1426 |
> |
dgi = ugr = ugp = ugr_exp = dgi_mod = cgi = dgr = vcp = 0.0; |
| 1427 |
> |
lum_task = lum_thres = limit = 0; |
| 1428 |
|
s_mask = muc_rvar_create(); |
| 1429 |
< |
muc_rvar_set_dim(s_mask, 1); |
| 1429 |
> |
muc_rvar_set_dim(s_mask, 1); |
| 1430 |
|
muc_rvar_clear(s_mask); |
| 1412 |
– |
struct muc_rvar* s_band; |
| 1431 |
|
s_band = muc_rvar_create(); |
| 1432 |
< |
muc_rvar_set_dim(s_band, 1); |
| 1432 |
> |
muc_rvar_set_dim(s_band, 1); |
| 1433 |
|
muc_rvar_clear(s_band); |
| 1416 |
– |
struct muc_rvar* s_z1; |
| 1434 |
|
s_z1 = muc_rvar_create(); |
| 1435 |
< |
muc_rvar_set_dim(s_z1, 1); |
| 1435 |
> |
muc_rvar_set_dim(s_z1, 1); |
| 1436 |
|
muc_rvar_clear(s_z1); |
| 1437 |
|
|
| 1421 |
– |
struct muc_rvar* s_z2; |
| 1438 |
|
s_z2 = muc_rvar_create(); |
| 1439 |
< |
muc_rvar_set_dim(s_z2, 1); |
| 1439 |
> |
muc_rvar_set_dim(s_z2, 1); |
| 1440 |
|
muc_rvar_clear(s_z2); |
| 1441 |
|
|
| 1426 |
– |
struct muc_rvar* s_noposweight; |
| 1442 |
|
s_noposweight = muc_rvar_create(); |
| 1443 |
< |
muc_rvar_set_dim(s_noposweight, 1); |
| 1443 |
> |
muc_rvar_set_dim(s_noposweight, 1); |
| 1444 |
|
muc_rvar_clear(s_noposweight); |
| 1445 |
|
|
| 1431 |
– |
struct muc_rvar* s_posweight; |
| 1446 |
|
s_posweight = muc_rvar_create(); |
| 1447 |
< |
muc_rvar_set_dim(s_posweight, 1); |
| 1447 |
> |
muc_rvar_set_dim(s_posweight, 1); |
| 1448 |
|
muc_rvar_clear(s_posweight); |
| 1449 |
|
|
| 1436 |
– |
struct muc_rvar* s_posweight2; |
| 1450 |
|
s_posweight2 = muc_rvar_create(); |
| 1451 |
< |
muc_rvar_set_dim(s_posweight2, 1); |
| 1451 |
> |
muc_rvar_set_dim(s_posweight2, 1); |
| 1452 |
|
muc_rvar_clear(s_posweight2); |
| 1453 |
|
|
| 1454 |
|
/*set required user view parameters to invalid values*/ |
| 1555 |
|
omega_mask=0.0; |
| 1556 |
|
i_mask=0; |
| 1557 |
|
actual_igs=0; |
| 1558 |
+ |
LUM_replace=0; |
| 1559 |
|
/* command line for output picture*/ |
| 1560 |
|
|
| 1561 |
|
cline = (char *) malloc(CLINEMAX+1); |
| 1694 |
|
strcpy(file_out2, argv[++i]); |
| 1695 |
|
/* printf("max lum set to %f\n",new_lum_max);*/ |
| 1696 |
|
break; |
| 1697 |
+ |
case 'O': |
| 1698 |
+ |
img_corr = 1; |
| 1699 |
+ |
set_lum_max2 = 3; |
| 1700 |
+ |
x_disk = atoi(argv[++i]); |
| 1701 |
+ |
y_disk = atoi(argv[++i]); |
| 1702 |
+ |
angle_disk = atof(argv[++i]); |
| 1703 |
+ |
LUM_replace = atof(argv[++i]); |
| 1704 |
+ |
strcpy(file_out2, argv[++i]); |
| 1705 |
+ |
/* printf("max lum set to %f\n",new_lum_max);*/ |
| 1706 |
+ |
break; |
| 1707 |
|
|
| 1708 |
+ |
|
| 1709 |
|
case 'n': |
| 1710 |
|
non_cos_lb = 0; |
| 1711 |
|
break; |
| 2108 |
|
lum_pos_mean= lum_pos_mean/sang; |
| 2109 |
|
lum_pos2_mean= lum_pos2_mean/sang; |
| 2110 |
|
|
| 2111 |
< |
if (set_lum_max2 >= 1 && E_v_contr > 0 && (E_vl_ext - E_v) > 0) { |
| 2111 |
> |
// XXX: sure this works? I'd suggest parenthesis. |
| 2112 |
> |
if ((set_lum_max2 >= 1 && E_v_contr > 0 && (E_vl_ext - E_v) > 0) || set_lum_max2==3) { |
| 2113 |
|
|
| 2114 |
+ |
if (set_lum_max2<3){ |
| 2115 |
|
lum_ideal = (E_vl_ext - E_v + E_v_contr) / omega_cos_contr; |
| 2116 |
|
if (set_lum_max2 == 2 && lum_ideal >= 2e9) { |
| 2117 |
|
printf("warning! luminance of replacement pixels would be larger than 2e9 cd/m2. Value set to 2e9cd/m2!\n") ; |
| 2122 |
|
} |
| 2123 |
|
printf("change luminance values!! lum_ideal,setvalue,E_vl_ext,E_v,E_v_contr %f %f %f %f %f\n", |
| 2124 |
|
lum_ideal, setvalue, E_vl_ext, E_v, E_v_contr); |
| 2125 |
+ |
}else{setvalue=LUM_replace; |
| 2126 |
+ |
} |
| 2127 |
|
|
| 2128 |
|
|
| 2129 |
|
for (x = 0; x < pict_get_xsize(p); x++) |
| 2143 |
|
pict_get_color(p, x, y)[BLU] = |
| 2144 |
|
setvalue / 179.0; |
| 2145 |
|
|
| 2146 |
< |
}else{ if(set_lum_max2 ==2 ) { |
| 2146 |
> |
}else{ if(set_lum_max2 >1 ) { |
| 2147 |
|
r_actual =acos(DOT(pict_get_cached_dir(p, x_disk, y_disk), pict_get_cached_dir(p, x, y))) * 2; |
| 2148 |
|
if (x_disk == x && y_disk==y ) r_actual=0.0; |
| 2149 |
|
|
| 2156 |
|
pict_get_color(p, x, y)[BLU] = |
| 2157 |
|
setvalue / 179.0; |
| 2158 |
|
|
| 2159 |
< |
} |
| 2131 |
< |
|
| 2132 |
< |
|
| 2159 |
> |
} |
| 2160 |
|
} |
| 2161 |
|
} |
| 2162 |
|
} |
| 2921 |
|
} |
| 2922 |
|
|
| 2923 |
|
|
| 2924 |
< |
|
| 2924 |
> |
pict_free(p); |
| 2925 |
> |
pict_free(pm); |
| 2926 |
> |
muc_rvar_free(s_mask); |
| 2927 |
> |
muc_rvar_free(s_band); |
| 2928 |
> |
muc_rvar_free(s_z1); |
| 2929 |
> |
muc_rvar_free(s_z2); |
| 2930 |
> |
muc_rvar_free(s_noposweight); |
| 2931 |
> |
muc_rvar_free(s_posweight); |
| 2932 |
> |
muc_rvar_free(s_posweight2); |
| 2933 |
> |
free(cline); |
| 2934 |
|
return EXIT_SUCCESS; |
| 2899 |
– |
exit(0); |
| 2935 |
|
|
| 2936 |
|
userr: |
| 2937 |
|
fprintf(stderr, |
| 2938 |
|
"Usage: %s [-s][-d][-c picture][-t xpos ypos angle] [-T xpos ypos angle] [-b fact] [-r angle] [-y] [-Y lum] [-i Ev] [-I Ev ymax ymin] [-v] picfile\n", |
| 2939 |
|
progname); |
| 2940 |
< |
exit(1); |
| 2940 |
> |
pict_free(p); |
| 2941 |
> |
pict_free(pm); |
| 2942 |
> |
muc_rvar_free(s_mask); |
| 2943 |
> |
muc_rvar_free(s_band); |
| 2944 |
> |
muc_rvar_free(s_z1); |
| 2945 |
> |
muc_rvar_free(s_z2); |
| 2946 |
> |
muc_rvar_free(s_noposweight); |
| 2947 |
> |
muc_rvar_free(s_posweight); |
| 2948 |
> |
muc_rvar_free(s_posweight2); |
| 2949 |
> |
free(cline); |
| 2950 |
> |
return 1; |
| 2951 |
|
} |
| 2952 |
|
|
| 2953 |
|
|