63#define USE_NEW_IMPL_CL 0
111 return _(
"astrophoto denoise");
116 return _(
"denoise (non-local means)");
123 _(
"non-linear, Lab, display-referred"),
124 _(
"non-linear, Lab"),
125 _(
"non-linear, Lab, display-referred"));
134 void *new_params,
const int new_version)
136 if(old_version == 1 && new_version == 2)
142 n->strength = 100.0f;
159#if defined(HAVE_OPENCL) && !USE_NEW_IMPL_CL
162 unsigned int current = *
state;
163 unsigned int next = (current >=
max - 1 ? 0 : current + 1);
179 const float scale = fminf(roi_in->
scale, 2.0f);
180 const int P = ceilf(
d->radius * scale);
181 const int K = ceilf(7 * scale);
182 const float sharpness = 3000.0f / (1.0f +
d->strength);
185 const float max_L = 120.0f, max_C = 512.0f;
186 const float nL = 1.0f / max_L, nC = 1.0f / max_C;
187 const float norm2[4] = { nL, nC };
190 const int devid = pipe->
devid;
205 .sharpness = sharpness,
210 .pipetype = pipe->
type,
218 if (err == CL_SUCCESS)
222 const float weight[4] = {
d->luma,
d->chroma,
d->chroma, 1.0f };
233 if (err == CL_SUCCESS)
244 const float scale = fminf(roi_in->
scale, 2.0f);
245 const int P = ceilf(
d->radius * scale);
246 const int K = ceilf(7 * scale);
247 const float sharpness = 3000.0f / (1.0f +
d->strength);
250 const float max_L = 120.0f, max_C = 512.0f;
251 const float nL = 1.0f / max_L, nC = 1.0f / max_C;
252 const float nL2 = nL * nL, nC2 = nC * nC;
255 const int devid = pipe->
devid;
260 unsigned int state = 0;
264 if(buckets[
k] == NULL)
goto error;
270 .cellsize =
sizeof(float), .overhead = 0,
271 .sizex = 1 << 16, .sizey = 1 };
274 hblocksize = hlocopt.
sizex;
281 .cellsize =
sizeof(float), .overhead = 0,
282 .sizex = 1, .sizey = 1 << 16 };
285 vblocksize = vlocopt.
sizey;
298 if(err != CL_SUCCESS)
goto error;
304 for(
int j = -K; j <= 0; j++)
305 for(
int i = -K;
i <= K;
i++)
318 if(err != CL_SUCCESS)
goto error;
323 local[0] = hblocksize;
335 if(err != CL_SUCCESS)
goto error;
342 local[1] = vblocksize;
354 if(err != CL_SUCCESS)
goto error;
364 if(err != CL_SUCCESS)
goto error;
375 if(err != CL_SUCCESS)
goto error;
402 const int P = ceilf(
d->radius * fmin(roi_in->
scale, 2.0f));
403 const int K = ceilf(7 * fmin(roi_in->
scale, 2.0f));
415 const void *
const ivoid,
418 void (*denoiser)(
const float *
const inbuf,
float *
const outbuf,
427 const float scale = fmin(roi_in->
scale, 2.0f);
428 const int P = ceilf(
d->radius * scale);
429 const int K = ceilf(7 * scale);
430 const float sharpness = 3000.0f / (1.0f +
d->strength);
433 float max_L = 120.0f, max_C = 512.0f;
434 float nL = 1.0f / max_L, nC = 1.0f / max_C;
446 .sharpness = sharpness,
449 .decimate = decimate,
451 denoiser(ivoid,
ovoid,roi_in,roi_out,¶ms);
467 const int program = 5;
497 memcpy(
d,
p,
sizeof(*
d));
498 d->luma =
MAX(0.0001f,
p->luma);
499 d->chroma =
MAX(0.0001f,
p->chroma);
521 gtk_widget_set_tooltip_text(
g->radius, _(
"radius of the patches to match"));
526 gtk_widget_set_tooltip_text(
g->strength, _(
"strength of the effect"));
529 gtk_widget_set_tooltip_text(
g->luma, _(
"how much to smooth brightness"));
532 gtk_widget_set_tooltip_text(
g->chroma, _(
"how much to smooth colors"));
static void error(char *msg)
void dt_bauhaus_slider_set_digits(GtkWidget *widget, int val)
void dt_bauhaus_slider_set_soft_max(GtkWidget *widget, float val)
void dt_bauhaus_slider_set_format(GtkWidget *widget, const char *format)
static const dt_aligned_pixel_simd_t const dt_adaptation_t const float p
void dt_print(dt_debug_thread_t thread, const char *msg,...)
#define dt_free_align(ptr)
static void * dt_calloc_align(size_t size)
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Enable aggressive floating-point arithmetic optimizations, in denormals handling. Set through user pr...
#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
gboolean dt_dev_pixelpipe_has_preview_output(const dt_develop_t *dev, const dt_dev_pixelpipe_t *pipe, const dt_iop_roi_t *roi)
@ DT_DEV_PIXELPIPE_DISPLAY_MASK
static void weight(const float *c1, const float *c2, const float sharpen, dt_aligned_pixel_t weight)
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)
@ IOP_FLAGS_SUPPORTS_BLENDING
#define IOP_GUI_ALLOC(module)
GtkWidget * dt_bauhaus_slider_from_params(dt_iop_module_t *self, const char *param)
float *const restrict const size_t k
static int bucket_next(unsigned int *state, unsigned int max)
const char ** description(struct dt_iop_module_t *self)
void commit_params(struct dt_iop_module_t *self, dt_iop_params_t *params, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void init_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
void gui_init(dt_iop_module_t *self)
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)
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 cleanup_pipe(struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
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)
dt_iop_nlmeans_params_t dt_iop_nlmeans_data_t
int legacy_params(dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
__DT_CLONE_TARGETS__ void nlmeans_denoise(const float *const inbuf, float *const outbuf, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_nlmeans_param_t *const params)
int nlmeans_denoise_cl(const dt_nlmeans_param_t *const params, const int devid, cl_mem dev_in, cl_mem dev_out, const dt_iop_roi_t *const roi_in)
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)
void * dt_opencl_alloc_device_buffer(const int devid, const size_t size)
int dt_opencl_create_kernel(const int prog, const char *name)
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)
@ DT_DEV_PIXELPIPE_THUMBNAIL
struct _GtkWidget GtkWidget
const float uint32_t state[4]
struct dt_iop_module_t *void * data
dt_dev_pixelpipe_type_t type
dt_iop_global_data_t * data
dt_iop_global_data_t * global_data
int kernel_nlmeans_finish
Region of interest passed through the pixelpipe.