Skip to content

Commit 6f77776

Browse files
committed
wb: removed 'as-shot to reference' (same as 'as shot' + 'prepare data for color calibration' (late_correction)); fixed behaviour when WB disabled; removed unused code
1 parent e499d18 commit 6f77776

4 files changed

Lines changed: 37 additions & 100 deletions

File tree

src/common/exif.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ static bool _exif_decode_exif_data(dt_image_t *img, Exiv2::ExifData &exifData)
20572057
dt_dng_illuminant_t illu[3] = { DT_LS_Unknown, DT_LS_Unknown, DT_LS_Unknown };
20582058

20592059
// make sure for later testing fallback later via
2060-
// `find_temperature_from_raw_coeffs` if there is no valid illuminant
2060+
// `find_illuminant_xy_from_as_shot_coeffs` if there is no valid illuminant
20612061
dt_mark_colormatrix_invalid(&img->d65_color_matrix[0]);
20622062

20632063
#if EXIV2_TEST_VERSION(0,27,4)

src/common/illuminants.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -513,31 +513,6 @@ static inline float planckian_normal(const float x, const float t)
513513
}
514514

515515

516-
DT_OMP_DECLARE_SIMD()
517-
static inline void blackbody_xy_to_tinted_xy(const float x, const float y, const float t, const float tint,
518-
float *x_out, float *y_out)
519-
{
520-
// Move further away from planckian locus in the orthogonal direction, by an amount of "tint"
521-
const float n = planckian_normal(x, t);
522-
const float norm = sqrtf(1.f + n * n);
523-
*x_out = x + tint * n / norm;
524-
*y_out = y - tint / norm;
525-
}
526-
527-
528-
DT_OMP_DECLARE_SIMD()
529-
static inline float get_tint_from_tinted_xy(const float x, const float y, const float t)
530-
{
531-
// Find the distance between planckian locus and arbitrary x y chromaticity in the orthogonal direction
532-
const float n = planckian_normal(x, t);
533-
const float norm = sqrtf(1.f + n * n);
534-
float x_bb, y_bb;
535-
CCT_to_xy_blackbody(t, &x_bb, &y_bb);
536-
const float tint = -(y - y_bb) * norm;
537-
return tint;
538-
}
539-
540-
541516
DT_OMP_DECLARE_SIMD()
542517
static inline void xy_to_uv(const float xy[2], float uv[2])
543518
{

src/develop/develop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ typedef struct dt_dev_viewport_t
147147
- the currently used wb_coeffs in temperature module
148148
- D65coeffs and as_shot are read from exif data
149149
f) - late_correction set by temperature if we want to process data as following
150-
If we use the new DT_IOP_TEMP_D65_LATE mode or enable this in user modes of temperature.c
151-
and don't have any temp parameters changes later we can calc correction ratios
150+
If we enable this for non-D65 modes of temperature.c and don't have any
151+
temp parameters changes later we can calc correction ratios
152152
to take white-balanced (neutralized) data to D65
153153
*/
154154
typedef struct dt_dev_chroma_t

src/iop/temperature.c

Lines changed: 34 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@ DT_MODULE_INTROSPECTION(5, dt_iop_temperature_params_t)
5353
#define DT_IOP_LOWEST_TINT 0.135
5454
#define DT_IOP_HIGHEST_TINT 2.326
5555

56-
#define DT_IOP_NUM_OF_STD_TEMP_PRESETS 5
56+
#define DT_IOP_NUM_OF_STD_TEMP_PRESETS 4
5757

5858
// If you reorder presets combo, change this consts
5959
#define DT_IOP_TEMP_UNKNOWN -1
6060
#define DT_IOP_TEMP_AS_SHOT 0
6161
#define DT_IOP_TEMP_SPOT 1
6262
#define DT_IOP_TEMP_USER 2
6363
#define DT_IOP_TEMP_D65 3
64-
#define DT_IOP_TEMP_D65_LATE 4
6564

6665
static void _gui_sliders_update(dt_iop_module_t *self);
6766

@@ -85,9 +84,7 @@ typedef struct dt_iop_temperature_gui_data_t
8584
GtkWidget *btn_asshot; //As Shot
8685
GtkWidget *btn_user;
8786
GtkWidget *btn_d65;
88-
GtkWidget *btn_d65_late;
8987
GtkWidget *temp_label;
90-
GtkWidget *balance_label;
9188
GtkWidget *check_late_correction;
9289
int preset_cnt;
9390
int preset_num[54];
@@ -194,11 +191,21 @@ int legacy_params(dt_iop_module_t *self,
194191
}
195192
if(old_version == 4)
196193
{
194+
const int legacy_d65_late = 4;
197195
const dt_iop_temperature_params_v4_t *o = (dt_iop_temperature_params_v4_t *)old_params;
198196
dt_iop_temperature_params_v5_t *n = malloc(sizeof(dt_iop_temperature_params_v5_t));
199197

200198
memcpy(n, o, sizeof(dt_iop_temperature_params_v4_t));
201-
n->late_correction = FALSE;
199+
if(o->preset == legacy_d65_late)
200+
{
201+
n->preset = DT_IOP_TEMP_AS_SHOT;
202+
n->late_correction = TRUE;
203+
}
204+
else
205+
{
206+
n->preset = o->preset > legacy_d65_late ? o->preset - 1 : o->preset;
207+
n->late_correction = FALSE;
208+
}
202209
*new_params = n;
203210
*new_params_size = sizeof(dt_iop_temperature_params_v5_t);
204211
*new_version = 5;
@@ -742,30 +749,21 @@ void commit_params(dt_iop_module_t *self,
742749

743750
d->preset = p->preset;
744751

745-
gboolean effective_late_correction = FALSE;
746-
747-
if(p->preset == DT_IOP_TEMP_D65_LATE)
748-
effective_late_correction = TRUE;
749-
else if(p->preset == DT_IOP_TEMP_D65)
750-
effective_late_correction = FALSE;
751-
else
752-
effective_late_correction = p->late_correction;
752+
const gboolean effective_late_correction =
753+
p->preset == DT_IOP_TEMP_D65 ? FALSE : p->late_correction;
753754

754755
d->late_correction = effective_late_correction;
755-
chr->late_correction = effective_late_correction;
756+
// When the WB module is disabled it applies no coefficients (wb_coeffs are
757+
// published as 1.0 above), so it makes no promise that the data is white
758+
// balanced. Do not ask colorin (or any other consumer) to "finish" a
759+
// correction that never started, otherwise disabling WB would still pull the
760+
// image to D65 via D65coeffs/1.0.
761+
chr->late_correction = piece->enabled ? effective_late_correction : FALSE;
756762

757-
chr->temperature = piece->enabled ? self : NULL;
758763
/* Make sure the chroma information stuff is valid
759764
If piece is disabled we always clear the trouble message and
760765
make sure chroma does know there is no temperature module.
761766
*/
762-
if(p->preset == DT_IOP_TEMP_D65_LATE)
763-
chr->late_correction = TRUE;
764-
else if(p->preset == DT_IOP_TEMP_D65)
765-
chr->late_correction = FALSE;
766-
else
767-
chr->late_correction = p->late_correction;
768-
769767
chr->temperature = piece->enabled ? self : NULL;
770768
if(dt_pipe_is_preview(pipe) && !piece->enabled)
771769
dt_iop_set_module_trouble_message(self, NULL, NULL, NULL);
@@ -1198,7 +1196,6 @@ static inline const char *_preset_to_str(const int preset)
11981196
case DT_IOP_TEMP_SPOT: return "by spot";
11991197
case DT_IOP_TEMP_USER: return "user defined";
12001198
case DT_IOP_TEMP_D65: return "camera reference";
1201-
case DT_IOP_TEMP_D65_LATE: return "as shot to reference";
12021199
default: return "other";
12031200
}
12041201
}
@@ -1209,10 +1206,8 @@ static void _update_preset(dt_iop_module_t *self, int mode)
12091206
dt_dev_chroma_t *chr = &self->dev->chroma;
12101207
dt_iop_temperature_gui_data_t *g = self->gui_data;
12111208

1212-
const gboolean is_current_reference = (p->preset == DT_IOP_TEMP_D65_LATE) ||
1213-
(p->preset == DT_IOP_TEMP_D65);
1214-
const gboolean is_new_mode_manual = (mode != DT_IOP_TEMP_D65_LATE) &&
1215-
(mode != DT_IOP_TEMP_D65);
1209+
const gboolean is_current_reference = p->preset == DT_IOP_TEMP_D65;
1210+
const gboolean is_new_mode_manual = mode != DT_IOP_TEMP_D65;
12161211

12171212
if(is_current_reference && is_new_mode_manual)
12181213
{
@@ -1222,17 +1217,13 @@ static void _update_preset(dt_iop_module_t *self, int mode)
12221217

12231218
p->preset = mode;
12241219

1225-
if(mode == DT_IOP_TEMP_D65_LATE)
1226-
{
1227-
chr->late_correction = TRUE;
1228-
}
1229-
else if(mode == DT_IOP_TEMP_D65)
1220+
if(mode == DT_IOP_TEMP_D65)
12301221
{
12311222
chr->late_correction = FALSE;
12321223
}
12331224
else
12341225
{
1235-
// For manual modes, use the parameter
1226+
// For non-D65 modes, use the parameter
12361227
chr->late_correction = p->late_correction;
12371228
}
12381229

@@ -1250,9 +1241,6 @@ void gui_update(dt_iop_module_t *self)
12501241
{
12511242
dt_iop_temperature_gui_data_t *g = self->gui_data;
12521243
dt_iop_temperature_params_t *p = self->params;
1253-
dt_iop_temperature_params_t *d = self->default_params;
1254-
1255-
d->preset = dt_is_scene_referred() ? DT_IOP_TEMP_D65_LATE : DT_IOP_TEMP_AS_SHOT;
12561244

12571245
const gboolean true_monochrome =
12581246
dt_image_monochrome_flags(&self->dev->image_storage) & DT_IMAGE_MONOCHROME;
@@ -1285,13 +1273,7 @@ void gui_update(dt_iop_module_t *self)
12851273
gboolean found = FALSE;
12861274
const dt_dev_chroma_t *chr = &self->dev->chroma;
12871275
// is this a "as shot" white balance?
1288-
if(dt_dev_equal_chroma((float *)p, chr->as_shot) && (p->preset == DT_IOP_TEMP_D65_LATE))
1289-
{
1290-
dt_bauhaus_combobox_set(g->presets, DT_IOP_TEMP_D65_LATE);
1291-
found = TRUE;
1292-
}
1293-
1294-
else if(dt_dev_equal_chroma((float *)p, chr->as_shot))
1276+
if(dt_dev_equal_chroma((float *)p, chr->as_shot))
12951277
{
12961278
dt_bauhaus_combobox_set(g->presets, DT_IOP_TEMP_AS_SHOT);
12971279
p->preset = DT_IOP_TEMP_AS_SHOT;
@@ -1439,8 +1421,6 @@ void gui_update(dt_iop_module_t *self)
14391421
p->preset == DT_IOP_TEMP_USER);
14401422
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_d65),
14411423
p->preset == DT_IOP_TEMP_D65);
1442-
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_d65_late),
1443-
p->preset == DT_IOP_TEMP_D65_LATE);
14441424

14451425
_color_temptint_sliders(self);
14461426
_color_rgb_sliders(self);
@@ -1593,8 +1573,8 @@ void reload_defaults(dt_iop_module_t *self)
15931573
dt_iop_temperature_params_t *d = self->default_params;
15941574
dt_iop_temperature_params_t *p = self->params;
15951575

1596-
d->preset = dt_is_scene_referred() ? DT_IOP_TEMP_D65_LATE : DT_IOP_TEMP_AS_SHOT;
1597-
d->late_correction = dt_is_scene_referred();
1576+
d->preset = p->preset = DT_IOP_TEMP_AS_SHOT;
1577+
d->late_correction = p->late_correction = dt_is_scene_referred();
15981578

15991579
float *dcoeffs = (float *)d;
16001580
for_four_channels(k)
@@ -1703,7 +1683,8 @@ void reload_defaults(dt_iop_module_t *self)
17031683
{
17041684
for_four_channels(k)
17051685
dcoeffs[k] = as_shot[k];
1706-
d->preset = p->preset = DT_IOP_TEMP_D65_LATE;
1686+
d->preset = p->preset = DT_IOP_TEMP_AS_SHOT;
1687+
d->late_correction = p->late_correction = TRUE;
17071688
}
17081689
else
17091690
{
@@ -1713,6 +1694,7 @@ void reload_defaults(dt_iop_module_t *self)
17131694
dcoeffs[2] = coeffs[2]/coeffs[1];
17141695
dcoeffs[3] = coeffs[3]/coeffs[1];
17151696
dcoeffs[1] = 1.0f;
1697+
d->late_correction = p->late_correction = FALSE;
17161698
}
17171699
}
17181700
}
@@ -1750,7 +1732,6 @@ void reload_defaults(dt_iop_module_t *self)
17501732
dt_bauhaus_combobox_add(g->presets, C_("white balance", "user modified"));
17511733
// old "camera neutral", reason: better matches intent
17521734
dt_bauhaus_combobox_add(g->presets, C_("white balance", "camera reference"));
1753-
dt_bauhaus_combobox_add(g->presets, C_("white balance", "as shot to reference"));
17541735

17551736
g->preset_cnt = DT_IOP_NUM_OF_STD_TEMP_PRESETS;
17561737
memset(g->preset_num, 0, sizeof(g->preset_num));
@@ -1760,7 +1741,6 @@ void reload_defaults(dt_iop_module_t *self)
17601741
_gui_sliders_update(self);
17611742

17621743
dt_bauhaus_combobox_set(g->presets, p->preset);
1763-
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_d65_late), p->preset == DT_IOP_TEMP_D65_LATE);
17641744
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_asshot), p->preset == DT_IOP_TEMP_AS_SHOT);
17651745
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_user), FALSE);
17661746
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_d65), FALSE);
@@ -1836,7 +1816,6 @@ static gboolean _btn_toggled(GtkWidget *togglebutton,
18361816

18371817
const int preset = togglebutton == g->btn_asshot ? DT_IOP_TEMP_AS_SHOT :
18381818
togglebutton == g->btn_d65 ? DT_IOP_TEMP_D65 :
1839-
togglebutton == g->btn_d65_late ? DT_IOP_TEMP_D65_LATE :
18401819
togglebutton == g->btn_user ? DT_IOP_TEMP_USER : 0;
18411820

18421821
if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglebutton)))
@@ -1879,8 +1858,6 @@ static void _preset_tune_callback(GtkWidget *widget, dt_iop_module_t *self)
18791858
pos == DT_IOP_TEMP_USER);
18801859
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_d65),
18811860
pos == DT_IOP_TEMP_D65);
1882-
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_d65_late),
1883-
pos == DT_IOP_TEMP_D65_LATE);
18841861

18851862
gboolean show_finetune = FALSE;
18861863
dt_dev_chroma_t *chr = &self->dev->chroma;
@@ -1910,9 +1887,6 @@ static void _preset_tune_callback(GtkWidget *widget, dt_iop_module_t *self)
19101887
case DT_IOP_TEMP_D65: // camera reference d65
19111888
_temp_params_from_array(p, chr->D65coeffs);
19121889
break;
1913-
case DT_IOP_TEMP_D65_LATE: // as shot wb just for now
1914-
_temp_params_from_array(p, chr->as_shot);
1915-
break;
19161890
default: // camera WB presets
19171891
{
19181892
gboolean found = FALSE;
@@ -2188,21 +2162,11 @@ void gui_init(dt_iop_module_t *self)
21882162
(g->btn_d65,
21892163
_("set white balance to camera reference point\nin most cases it should be D65"));
21902164

2191-
g->btn_d65_late = dt_iop_togglebutton_new(self,
2192-
N_("settings"),
2193-
N_("as shot to reference"), NULL,
2194-
G_CALLBACK(_btn_toggled), FALSE, 0, 0,
2195-
dtgtk_cairo_paint_bulb_mod, NULL);
2196-
gtk_widget_set_tooltip_text
2197-
(g->btn_d65_late,
2198-
_("set white balance to as shot and later correct to camera reference point,\nin most cases it should be D65"));
2199-
22002165
// put buttons at top. fill later.
22012166
g->buttonbar = dt_gui_hbox(dt_gui_expand(g->btn_asshot),
22022167
dt_gui_expand(g->colorpicker),
22032168
dt_gui_expand(g->btn_user),
2204-
dt_gui_expand(g->btn_d65),
2205-
dt_gui_expand(g->btn_d65_late));
2169+
dt_gui_expand(g->btn_d65));
22062170
dt_gui_add_class(g->buttonbar, "dt_iop_toggle");
22072171

22082172
g->presets = dt_bauhaus_combobox_new(self);
@@ -2253,7 +2217,7 @@ void gui_init(dt_iop_module_t *self)
22532217

22542218
gtk_widget_set_tooltip_text(g->check_late_correction,
22552219
_("ensures the white balance coefficients are treated as a reference for the color calibration module.\n"
2256-
"keep this checked if you use the modern scene-referred workflow but want to manually adjust white balance."));
2220+
"keep this checked for non-reference white balance in the modern scene-referred workflow."));
22572221

22582222
GtkWidget *box_enabled = dt_gui_vbox(g->buttonbar,
22592223
g->check_late_correction,
@@ -2318,9 +2282,9 @@ void gui_cleanup(dt_iop_module_t *self)
23182282
void gui_reset(dt_iop_module_t *self)
23192283
{
23202284
dt_iop_temperature_gui_data_t *g = self->gui_data;
2321-
dt_iop_temperature_params_t *d = self->default_params;
2285+
dt_iop_temperature_params_t *p = self->params;
23222286

2323-
const int preset = d->preset = dt_is_scene_referred() ? DT_IOP_TEMP_D65_LATE : DT_IOP_TEMP_AS_SHOT;
2287+
const int preset = p->preset;
23242288
dt_iop_color_picker_reset(self, TRUE);
23252289

23262290
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_asshot),
@@ -2329,8 +2293,6 @@ void gui_reset(dt_iop_module_t *self)
23292293
preset == DT_IOP_TEMP_USER);
23302294
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_d65),
23312295
preset == DT_IOP_TEMP_D65);
2332-
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->btn_d65_late),
2333-
preset == DT_IOP_TEMP_D65_LATE);
23342296

23352297
_color_finetuning_slider(self);
23362298
_color_rgb_sliders(self);

0 commit comments

Comments
 (0)