Skip to content

Commit f9e050a

Browse files
authored
Merge pull request #19688 from horazont/fix/denoise-highlight-preservation-checkbox
denoiseprofile: handle images w/o highlight preservation metadata better
2 parents 6715497 + fdb9e2f commit f9e050a

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/iop/denoiseprofile.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,6 +2822,20 @@ void init(dt_iop_module_t *self)
28222822
}
28232823
}
28242824

2825+
static int _get_iso_highlight_preservation_shift(dt_image_t *img)
2826+
{
2827+
const float hilight_pres = img->exif_highlight_preservation;
2828+
// Only compensate whole EV steps, as non-whole steps are (based on
2829+
// experience and discussion in #19624) handled by different means in the
2830+
// camera.
2831+
const int shift = floorf(hilight_pres);
2832+
if(shift <= 0)
2833+
{
2834+
return 0;
2835+
}
2836+
return shift;
2837+
}
2838+
28252839
/** this will be called to init new defaults if a new image is loaded
28262840
* from film strip mode. */
28272841
void reload_defaults(dt_iop_module_t *self)
@@ -2842,7 +2856,9 @@ void reload_defaults(dt_iop_module_t *self)
28422856
d->fix_anscombe_and_nlmeans_norm = TRUE;
28432857
d->use_new_vst = TRUE;
28442858
d->wavelet_color_mode = MODE_Y0U0V0;
2845-
d->compensate_hilite_pres = TRUE;
2859+
2860+
const int iso_shift = _get_iso_highlight_preservation_shift(&self->dev->image_storage);
2861+
d->compensate_hilite_pres = iso_shift > 0;
28462862

28472863
GList *profiles = dt_noiseprofile_get_matching(&self->dev->image_storage);
28482864
char name[512];
@@ -2983,19 +2999,8 @@ static dt_noiseprofile_t dt_iop_denoiseprofile_get_auto_profile(dt_iop_module_t
29832999
int shift = 0;
29843000
if(compensate_hilite_pres)
29853001
{
2986-
const float hilight_pres = self->dev->image_storage.exif_highlight_preservation;
2987-
// Only compensate whole EV steps, as non-whole steps are (based on
2988-
// experience and discussion in #19624) handled by different means in the
2989-
// camera.
2990-
shift = floorf(hilight_pres);
2991-
if(shift >= 0)
2992-
{
2993-
iso >>= shift;
2994-
}
2995-
else
2996-
{
2997-
shift = 0;
2998-
}
3002+
shift = _get_iso_highlight_preservation_shift(&self->dev->image_storage);
3003+
iso >>= shift;
29993004
}
30003005
dt_noiseprofile_t *last = NULL;
30013006
for(GList *iter = profiles; iter; iter = g_list_next(iter))
@@ -3289,6 +3294,10 @@ void gui_update(dt_iop_module_t *self)
32893294
!p->fix_anscombe_and_nlmeans_norm);
32903295
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g->use_new_vst), p->use_new_vst);
32913296
gtk_widget_set_visible(g->use_new_vst, !p->use_new_vst);
3297+
3298+
const int iso_shift = _get_iso_highlight_preservation_shift(&self->dev->image_storage);
3299+
gtk_widget_set_visible(g->compensate_hilite_pres, iso_shift > 0);
3300+
32923301
if((p->wavelet_color_mode == MODE_Y0U0V0) && (g->channel < DT_DENOISE_PROFILE_Y0))
32933302
{
32943303
g->channel = DT_DENOISE_PROFILE_Y0;

0 commit comments

Comments
 (0)