106 return _(
"_highlight reconstruction");
112 _(
"corrective"), _(
"linear, raw, scene-referred"), _(
"reconstruction, raw"),
113 _(
"linear, raw, scene-referred"));
143 const float *
const restrict in = (
const float *)input;
144 float max_RGB[3] = { 0.0f };
147 for(
size_t i = 0;
i < roi_out->
height;
i++)
148 for(
size_t j = 0; j < roi_out->
width; j++)
154 max_RGB[channel] =
MAX(max_RGB[channel], pixel_max);
157 p->clip =
MIN(
MIN(max_RGB[0], max_RGB[1]), max_RGB[2]);
161 const int new_version)
163 if(old_version == 1 && new_version == 4)
171 memcpy(new_params, old_params,
176 n->noise_level = 0.0f;
177 n->reconstructing = 0.4f;
182 n->solid_color = 0.f;
185 if(old_version == 2 && new_version == 4)
197 memcpy(new_params, old_params,
202 n->reconstructing = 0.4f;
207 n->solid_color = 0.f;
210 if(old_version == 3 && new_version == 4)
228 cl_mem dev_in, cl_mem dev_out)
237 const int devid = pipe->
devid;
244 const gboolean visualizing
248 cl_mem dev_xtrans = NULL;
272 if(err != CL_SUCCESS)
goto error;
283 const float clip =
d->clip
298 if(err != CL_SUCCESS)
goto error;
314 if(err != CL_SUCCESS)
goto error;
329 if(err != CL_SUCCESS)
goto error;
334 int blocksizex, blocksizey;
340 .cellsize =
sizeof(float),
347 blocksizex = locopt.
sizex;
348 blocksizey = locopt.
sizey;
351 blocksizex = blocksizey = 1;
358 size_t local[] = { blocksizex, blocksizey, 1 };
368 sizeof(
float) * (blocksizex + 4) * (blocksizey + 4), NULL);
371 if(err != CL_SUCCESS)
goto error;
381 if(err != CL_SUCCESS)
goto error;
390 if(err != CL_SUCCESS)
goto error;
416 const float final_radius = (float)((
int)(1 <<
d->scales)) / scale;
417 const int scales = CLAMP((
int)ceilf(log2f(final_radius)), 1,
MAX_NUM_SCALES);
418 const int max_filter_radius = (1 << scales);
440 tiling->xalign = (filters == 9u) ? 6 : 2;
441 tiling->yalign = (filters == 9u) ? 6 : 2;
481 const void *
const ivoid,
void *
const ovoid)
497 const gboolean visualizing
511 const float clip = data->
clip
531 const uint8_t(*
const xtrans)[6] = (
const uint8_t(*
const)[6])piece->
dsc_in.
xtrans;
533 for(
int j = 0; j < roi_out->
height; j++)
540 for(
int i = 0;
i < roi_out->
width;
i++)
549 for(
int j = 0; j < roi_out->
height; j++)
558 for(
int i = 0;
i < roi_out->
width;
i++)
609 memcpy(
d,
p,
sizeof(*
p));
616 dt_iop_fmt_log(self,
"commit: class=%s filters=%u mode=%d -> enabled=%d",
666 const gboolean
state = current_state && active;
667 dt_iop_fmt_log(self,
"force_enable: class=%s supported=%d current=%d -> %d",
675 const int program = 2;
680 const int harmonic_program = 38;
681 const int sparse_program = 37;
790 const int wavelets = 35;
938 gtk_widget_set_visible(
g->noise_level,
942 gtk_widget_set_visible(
g->solid_color,
958 gtk_stack_set_visible_child_name(GTK_STACK(self->
widget), self->
default_enabled ?
"default" :
"monochrome");
970 g->show_visualize =
FALSE;
980 module->default_enabled = enable(&module->dev->image_storage);
981 module->hide_enable_button = !enable(&module->dev->image_storage);
982 dt_iop_fmt_log(module,
"reload_defaults: class=%s default_enabled=%d",
1012 const gboolean was_visualize =
g->show_visualize;
1014 g->show_visualize =
FALSE;
1025 gtk_widget_set_tooltip_text(
g->mode, _(
"highlight reconstruction method"));
1029 gtk_widget_set_tooltip_text(
g->clip, _(
"manually adjust the clipping threshold against "
1030 "magenta highlights\nthe mask icon shows the clipped area\n"
1031 "(you shouldn't ever need to touch this)"));
1038 gtk_widget_set_tooltip_text(
g->noise_level, _(
"add noise to visually blend the reconstructed areas\n"
1039 "into the rest of the noisy image. useful at high ISO."));
1043 gtk_widget_set_tooltip_text(
g->iterations, _(
"increase if magenta highlights don't get fully corrected\n"
1044 "each new iteration brings a performance penalty."));
1048 gtk_widget_set_tooltip_text(
g->solid_color,
1049 _(
"increase if magenta highlights don't get fully corrected.\n"
1050 "this may produce non-smooth boundaries between valid and clipped regions."));
1053 gtk_widget_set_tooltip_text(
g->scales, _(
"increase to correct larger clipped areas.\n"
1054 "large values bring huge performance penalties"));
1057 gtk_widget_set_tooltip_text(monochromes, _(
"no highlights reconstruction for monochrome images"));
1060 self->
widget = gtk_stack_new();
1061 gtk_stack_set_homogeneous(GTK_STACK(self->
widget),
FALSE);
1062 gtk_stack_add_named(GTK_STACK(self->
widget), monochromes,
"monochrome");
1063 gtk_stack_add_named(GTK_STACK(self->
widget), box_raw,
"default");
static void error(char *msg)
void dt_bauhaus_slider_set_soft_range(GtkWidget *widget, float soft_min, float soft_max)
void dt_bauhaus_slider_set_digits(GtkWidget *widget, int val)
void dt_bauhaus_widget_set_quad_toggle(GtkWidget *widget, int toggle)
int dt_bauhaus_combobox_length(GtkWidget *widget)
void dt_bauhaus_widget_set_quad_active(GtkWidget *widget, int active)
void dt_bauhaus_combobox_add_full(GtkWidget *widget, const char *text, dt_bauhaus_combobox_alignment_t align, gpointer data, void(free_func)(void *data), gboolean sensitive)
int dt_bauhaus_widget_get_quad_active(GtkWidget *widget)
void dt_bauhaus_widget_set_quad_visibility(GtkWidget *widget, const gboolean visible)
void dt_bauhaus_slider_set_format(GtkWidget *widget, const char *format)
void dt_bauhaus_widget_set_quad_paint(GtkWidget *widget, dt_bauhaus_quad_paint_f f, int paint_flags, void *paint_data)
@ DT_BAUHAUS_COMBOBOX_ALIGN_RIGHT
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
__DT_CLONE_TARGETS__ void process_visualize(const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const uint32_t filters, dt_iop_highlights_data_t *data)
__DT_CLONE_TARGETS__ void process_clip(const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const float clip)
dt_image_pipe_class_t dt_image_pipe_class(const dt_image_t *img)
const char * dt_image_pipe_class_name(const dt_image_pipe_class_t klass)
gboolean dt_image_is_monochrome(const dt_image_t *img)
gboolean dt_image_needs_rawprepare(const dt_image_t *img)
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define dt_free_align(ptr)
static void * dt_calloc_align(size_t size)
void void void gboolean dt_gui_widgets_suppressed(void)
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
#define __DT_CLONE_TARGETS__
#define __OMP_PARALLEL_FOR__(...)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
static int FCxtrans(const int row, const int col, global const unsigned char(*const xtrans)[6])
static int FC(const int row, const int col, const unsigned int filters)
#define dt_dev_pixelpipe_update_history_main(dev)
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
@ DT_DEV_PIXELPIPE_DISPLAY_PASSTHRU
@ DT_DEV_PIXELPIPE_DISPLAY_NONE
void dtgtk_cairo_paint_showmask(cairo_t *cr, gint x, gint y, gint w, gint h, gint flags, void *data)
#define DT_GUI_BOX_SPACING
static GtkWidget * dt_ui_label_new(const gchar *str)
void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
const char ** description(struct dt_iop_module_t *self)
__DT_CLONE_TARGETS__ int process(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid)
void reload_defaults(dt_iop_module_t *module)
static gboolean enable(dt_image_t *image)
void gui_focus(struct dt_iop_module_t *self, gboolean in)
void init_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void output_format(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
void gui_update(struct dt_iop_module_t *self)
Refresh GUI controls from current params and configuration.
void gui_init(struct dt_iop_module_t *self)
void gui_changed(dt_iop_module_t *self, GtkWidget *w, void *previous)
void tiling_callback(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, struct dt_develop_tiling_t *tiling)
void cleanup_global(dt_iop_module_so_t *module)
int default_colorspace(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
void autoset(struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const void *input)
gboolean force_enable(struct dt_iop_module_t *self, const gboolean current_state)
void cleanup_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
static void _visualize_callback(GtkWidget *quad, gpointer user_data)
void init_global(dt_iop_module_so_t *module)
int process_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
int legacy_params(dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
uint32_t dt_dev_get_roi_filters(const dt_dev_pixelpipe_iop_t *const piece, const dt_iop_roi_t *const roi_in)
const char ** dt_iop_set_description(dt_iop_module_t *module, const char *main_text, const char *purpose, const char *input, const char *process, const char *output)
float dt_dev_get_module_scale(const dt_dev_pixelpipe_t *const pipe, const dt_iop_roi_t *const roi_in)
void dt_iop_set_cache_bypass(dt_iop_module_t *module, gboolean state)
#define dt_iop_fmt_log(module, fmt,...)
Debug helper to trace a module's input-format-driven decisions on the -d pipe channel (DT_DEBUG_PIPE)...
@ IOP_FLAGS_SUPPORTS_BLENDING
#define IOP_GUI_ALLOC(module)
GtkWidget * dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *param)
GtkWidget * dt_bauhaus_combobox_from_params(dt_iop_module_t *self, const char *param)
__DT_CLONE_TARGETS__ int process_laplacian_bayer(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
cl_int process_laplacian_bayer_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
cl_int process_laplacian_xtrans_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
__DT_CLONE_TARGETS__ int process_laplacian_xtrans(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
__DT_CLONE_TARGETS__ void process_lch_bayer(dt_iop_module_t *self, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const float clip)
void interpolate_color(const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_out, int dim, int dir, int other, const float *clip, const uint32_t filters, const int pass)
__DT_CLONE_TARGETS__ void process_lch_xtrans(dt_iop_module_t *self, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const float clip)
void interpolate_color_xtrans(const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, int dim, int dir, int other, const float *const clip, const uint8_t(*const xtrans)[6], const int pass)
float *const restrict const size_t k
float dt_aligned_pixel_t[4]
int dt_opencl_local_buffer_opt(const int devid, const int kernel, dt_opencl_local_buffer_t *factors)
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
int dt_opencl_create_kernel(const int prog, const char *name)
void * dt_opencl_copy_host_to_device_constant(const int devid, const size_t size, void *host)
void dt_opencl_free_kernel(const int kernel)
int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg)
int dt_opencl_enqueue_kernel_2d_with_local(const int dev, const int kernel, const size_t *sizes, const size_t *local)
void dt_opencl_release_mem_object(cl_mem mem)
#define DT_OPENCL_DEFAULT_ERROR
cl_int process_harmonic_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
__DT_CLONE_TARGETS__ int process_harmonic_bayer(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
__DT_CLONE_TARGETS__ int process_harmonic_xtrans(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
struct _GtkWidget GtkWidget
const float uint32_t state[4]
@ DT_IOP_HIGHLIGHTS_HARMONIC
@ DT_IOP_HIGHLIGHTS_INPAINT
@ DT_IOP_HIGHLIGHTS_LAPLACIAN
dt_atrous_wavelets_scales_t
dt_iop_highlights_params_t dt_iop_highlights_data_t
dt_iop_buffer_dsc_t dsc_out
dt_iop_buffer_dsc_t dsc_in
struct dt_iop_module_t *void * data
gboolean cache_output_on_ram
struct dt_dev_pixelpipe_t * pipe
dt_aligned_pixel_t processed_maximum
int kernel_highlights_diffuse_color
int kernel_hl_cf_eval_pair
int kernel_hl_cf_pack_joint
int kernel_highlights_1f_clip
int kernel_sparse_chol_final_level
int kernel_hl_cf_fit_pair
int kernel_hl_aniso_splat
int kernel_hl_window_unpack
int kernel_hl_aniso_reassemble
int kernel_hl_cf_fit_joint
int kernel_hl_aniso_pyr_down
int kernel_hl_aniso_obs_flags
int kernel_hl_aniso_obs_full
int kernel_hl_knee_apply_interp
int kernel_highlights_guide_laplacians
int kernel_hl_pyr_project
int kernel_hl_knee_joint_reg
int kernel_hl_grad_reduce
int kernel_hl_pde_scatter
int kernel_highlights_1f_lch_xtrans
int kernel_hl_fill_jacobi_block
int kernel_highlights_1f_lch_bayer
int kernel_hl_cf_pack_pair
int kernel_highlights_remosaic_and_replace
int kernel_hl_cf_eval_deep
int kernel_sparse_chol_fwd_level
int kernel_hl_cfa_jacobi_block
int kernel_hl_region_gather
int kernel_filmic_bspline_horizontal_local
int kernel_hl_ratio_plane
int kernel_highlights_normalize_reduce_first
int kernel_hl_fill_seed_up
int kernel_hl_region_stats
int kernel_hl_knee_pair_reg
int kernel_hl_cf_pack_deepmask
int kernel_hl_cf_lref_partials
int kernel_highlights_4f_clip
int kernel_highlights_bilinear_and_mask_xtrans
int kernel_hl_aniso_scatter
int kernel_highlights_normalize_reduce_first_xtrans
int kernel_hl_aniso_iter_block
int kernel_interpolate_bilinear
int kernel_filmic_bspline_horizontal
int kernel_hl_aniso_tensor
int kernel_hl_fill_jacobi
int kernel_highlights_box_blur
int kernel_hl_cmean_reduce
int kernel_filmic_bspline_vertical
int kernel_sparse_chol_bwd_level
int kernel_hl_window_pack
int kernel_hl_mask_to_img1
int kernel_highlights_normalize_reduce_second
int kernel_sparse_chol_update_level
int kernel_hl_region_scatter
int kernel_highlights_remosaic_and_replace_xtrans
int kernel_highlights_false_color
int kernel_highlights_bilinear_and_mask
int kernel_hl_cf_eval_joint
int kernel_hl_aniso_weights
int kernel_filmic_bspline_vertical_local
int kernel_hl_cfa_weights
dt_iop_highlights_mode_t mode
dt_iop_global_data_t * data
int32_t hide_enable_button
struct dt_develop_t * dev
dt_iop_gui_data_t * gui_data
dt_iop_global_data_t * global_data
Region of interest passed through the pixelpipe.