Skip to content

Commit 67f8048

Browse files
jenshannoschwalmTurboGit
authored andcommitted
Fix a few capture UI irritations
1. As the radius calculating algorithm has been verified for good results for some time now we don't need the "validation" any more and trust returned data to be in the 0.0 -> 1.5 range. 2. Fixed a subtle autoradius-once-in-UI flag issue. 3. Instead of avoiding the radius calculation we accept to do so also while being zoomed in or with active cropping but leave a control log notice about imprecise results, also modified the tooltip for clearer information. Also evaluated: if a radius calculation is requested we expand roi_in to full image and calculate radius on those data before restarting pipe with current roi. There are definitely differences - especially if being zoomed/cropped at image borders - for the calculated radius but those are pretty small (mostly <0.05) so it's not worth to do so.
1 parent 5087d46 commit 67f8048

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

src/iop/demosaic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,8 +1782,8 @@ void gui_init(dt_iop_module_t *self)
17821782
"ringing especially when used with a large 'iterations' setting.\n\n"
17831783
"Note: a radius set to zero will be recalculated automatically the next run. use for presets"));
17841784
dt_bauhaus_widget_set_quad(g->cs_radius, self, dtgtk_cairo_paint_reset, FALSE, _cs_radius_callback,
1785-
_("calculate the capture sharpen radius from sensor data.\n"
1786-
"this should be done in zoomed out darkroom"));
1785+
_("calculate the capture sharpen radius from available raw sensor data.\n"
1786+
"for best results avoid cropping or darkroom zooming in"));
17871787

17881788
g->cs_thrs = dt_bauhaus_slider_from_params(self, "cs_thrs");
17891789
gtk_widget_set_tooltip_text(g->cs_thrs, _("restrict capture sharpening to areas with high local contrast,\n"

src/iop/demosaicing/capture.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static float _calc_auto_radius(float *const in,
384384
: _calcRadiusXtrans(input, width, height, xtrans);
385385

386386
if(in != input) dt_free_align(input);
387-
return radius;
387+
return CLAMP(radius, 0.0f, 1.5f);
388388
}
389389

390390

@@ -620,38 +620,37 @@ static void _capture_radius(dt_iop_module_t *self,
620620
{
621621
dt_iop_demosaic_params_t *p = self->params;
622622
const dt_image_t *img = &self->dev->image_storage;
623-
const gboolean enough = ((float)width / (float)img->p_width) > 0.6f
624-
&& ((float)height / (float)img->p_height) > 0.6f;
623+
const gboolean reliable = ((float)width / (float)img->p_width) > 0.5f
624+
&& ((float)height / (float)img->p_height) > 0.5f;
625+
const gboolean enough = width > 200 && height > 200;
625626

626627
dt_iop_demosaic_data_t *d = piece->data;
627628
dt_iop_demosaic_gui_data_t *g = self->gui_data;
628629
const dt_dev_pixelpipe_t *pipe = piece->pipe;
629630
const gboolean fullpipe = pipe->type & DT_DEV_PIXELPIPE_FULL;
630631
const dt_iop_buffer_dsc_t *dsc = &pipe->dsc;
631-
const float radius = 0.01f * (int)(enough ? 100.0f * _calc_auto_radius(in, width, height, filters, xtrans, dsc) : 10);
632-
const gboolean valid = radius > 0.1f && radius < 1.5f;
632+
const float radius = 0.01f * (int)(enough ? 100.0f * _calc_auto_radius(in, width, height, filters, xtrans, dsc) : 50);
633633
const gboolean same_radius = feqf(p->cs_radius, radius, CAPTURE_GAUSS_FRACTION);
634634

635635
dt_print_pipe(DT_DEBUG_PIPE, filters != 9u ? "bayer autoradius" : "xtrans autoradius",
636636
pipe, self, DT_DEVICE_NONE, NULL, NULL,
637-
"%sradius=%.2f from %s is %svalid",
638-
same_radius ? "unchanged" : "", radius, enough ? "enough" : "small", valid ? "" : "not ");
637+
"%sradius=%.2f from %s image data is %s reliable",
638+
same_radius ? "unchanged" : "", radius,
639+
enough ? "enough" : "small",
640+
reliable ? "" : "not ");
639641

640-
if(fullpipe)
642+
if(fullpipe && g)
641643
{
642-
if(valid && !same_radius)
644+
g->autoradius = TRUE;
645+
if(!same_radius || g->new_radius < 0.0f)
643646
{
644647
p->cs_radius = radius;
645-
if(g)
646-
{
647-
g->new_radius = radius;
648-
g->autoradius = TRUE;
649-
}
648+
g->new_radius = radius;
650649
}
651-
if(!enough)
652-
dt_control_log(_("can't calculate a reliable capture radius as you are zoomed in too much"));
650+
if(!reliable)
651+
dt_control_log(_("imprecise radius calculation due to cropping or because you are zoomed in too much"));
653652
}
654-
d->cs_radius = valid ? radius : 0.5f;
653+
d->cs_radius = radius;
655654
}
656655

657656
static void _capture_noise(dt_iop_module_t *self,
@@ -668,13 +667,13 @@ static void _capture_noise(dt_iop_module_t *self,
668667
dt_print_pipe(DT_DEBUG_PIPE, "capture threshold",
669668
pipe, self, DT_DEVICE_NONE, NULL, NULL, "threshold=%.2f", thrs);
670669

671-
if(fullpipe && !same_thrs)
670+
if(fullpipe && g)
672671
{
673-
p->cs_thrs = thrs;
674-
if(g)
672+
g->autothrs = TRUE;
673+
if(!same_thrs)
675674
{
675+
p->cs_thrs = thrs;
676676
g->new_thrs = thrs;
677-
g->autothrs = TRUE;
678677
}
679678
}
680679
d->cs_thrs = thrs;
@@ -710,7 +709,7 @@ static inline gboolean _radius_requested(dt_iop_module_t *self,
710709
// do we require a calculation of the capture radius?
711710

712711
// if the calc-radius button in UI has been clicked
713-
if(g && (g->new_radius < 0.0f)) return TRUE;
712+
if(g && fullpipe && (g->new_radius < 0.0f)) return TRUE;
714713

715714
// if running in gui the first fullpipe for this image and there is an invalid radius
716715
if(g && fullpipe && !g->autoradius && invalid_radius) return TRUE;

0 commit comments

Comments
 (0)