Skip to content

Commit

Permalink
Add a prefilter denoise module
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelienpierre committed Dec 15, 2023
1 parent 53c609c commit 1b25ce9
Show file tree
Hide file tree
Showing 4 changed files with 908 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/common/iop_order.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const dt_iop_order_entry_t legacy_order[] = {
{ { 7.0f }, "rawdenoise", 0},
{ { 8.0f }, "demosaic", 0},
{ { 9.0f }, "mask_manager", 0},
{ { 9.5f }, "denoise", 0},
{ {10.0f }, "denoiseprofile", 0},
{ {11.0f }, "tonemap", 0},
{ {12.0f }, "exposure", 0},
Expand Down Expand Up @@ -175,6 +176,7 @@ const dt_iop_order_entry_t v30_order[] = {
{ { 6.0f }, "hotpixels", 0},
{ { 7.0f }, "rawdenoise", 0},
{ { 8.0f }, "demosaic", 0},
{ { 8.5f }, "denoise", 0},
{ { 9.0f }, "denoiseprofile", 0},
{ {10.0f }, "bilateral", 0},
{ {11.0f }, "rotatepixels", 0},
Expand Down Expand Up @@ -284,6 +286,7 @@ const dt_iop_order_entry_t v30_jpg_order[] = {
// all the modules between [8; 28] expect linear RGB, so they need to be moved after colorin
{ { 28.0f }, "colorin", 0 },
// moved modules : (copy-pasted in the same order)
{ { 28.0f }, "denoise", 0},
{ { 28.0f }, "denoiseprofile", 0},
{ { 28.0f }, "bilateral", 0},
{ { 28.0f }, "rotatepixels", 0},
Expand Down Expand Up @@ -813,6 +816,7 @@ GList *dt_ioppr_get_iop_order_list(int32_t imgid, gboolean sorted)
_insert_before(iop_order_list, "graduatednd", "crop");
_insert_before(iop_order_list, "colorbalance", "diffuse");
_insert_before(iop_order_list, "nlmeans", "blurs");
_insert_before(iop_order_list, "denoiseprofile", "denoise");
}
}
else if(version == DT_IOP_ORDER_LEGACY)
Expand Down
1 change: 1 addition & 0 deletions src/iop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ add_iop(colorbalancergb "colorbalancergb.c")
add_iop(cacorrectrgb "cacorrectrgb.c")
add_iop(diffuse "diffuse.c")
add_iop(blurs "blurs.c")
add_iop(denoise "denoise.c")


if(Rsvg2_FOUND)
Expand Down
21 changes: 19 additions & 2 deletions src/iop/demosaic.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef enum dt_iop_demosaic_method_t
DT_IOP_DEMOSAIC_AMAZE_VNG = DEMOSAIC_DUAL | DT_IOP_DEMOSAIC_AMAZE, // $DESCRIPTION: "AMaZE + VNG4"
DT_IOP_DEMOSAIC_PASSTHROUGH_MONOCHROME = 3, // $DESCRIPTION: "passthrough (monochrome)"
DT_IOP_DEMOSAIC_PASSTHROUGH_COLOR = 4, // $DESCRIPTION: "photosite color (debug)"
DT_IOP_DEMOSAIC_BILINEAR = 7, // $DESCRIPTION: "bilinear"
// methods for x-trans images
DT_IOP_DEMOSAIC_VNG = DEMOSAIC_XTRANS | 0, // $DESCRIPTION: "VNG"
DT_IOP_DEMOSAIC_MARKESTEIJN = DEMOSAIC_XTRANS | 1, // $DESCRIPTION: "Markesteijn 1-pass"
Expand Down Expand Up @@ -396,6 +397,9 @@ static const char* method2string(dt_iop_demosaic_method_t method)
case DT_IOP_DEMOSAIC_PASSTHR_COLORX:
string = "photosites (XTrans)";
break;
case DT_IOP_DEMOSAIC_BILINEAR:
string = "bilinear";
break;
default:
string = "(unknown method)";
}
Expand Down Expand Up @@ -587,6 +591,19 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const
{
rcd_demosaic(piece, tmp, in, &roo, &roi, piece->pipe->dsc.filters);
}
else if(demosaicing_method == DT_IOP_DEMOSAIC_BILINEAR)
{
// separate out G1 and G2 in RGGB Bayer patterns
uint32_t filters4 = 0;
if(piece->pipe->dsc.filters == 9 || FILTERS_ARE_4BAYER(piece->pipe->dsc.filters)) // x-trans or CYGM/RGBE
filters4 = piece->pipe->dsc.filters;
else if((piece->pipe->dsc.filters & 3) == 1)
filters4 = piece->pipe->dsc.filters | 0x03030303u;
else
filters4 = piece->pipe->dsc.filters | 0x0c0c0c0cu;

lin_interpolate(tmp, in, &roo, &roi, filters4, xtrans);
}
else if(demosaicing_method == DT_IOP_DEMOSAIC_LMMSE)
{
if(gd->lmmse_gamma_in == NULL)
Expand Down Expand Up @@ -1567,11 +1584,11 @@ void gui_init(struct dt_iop_module_t *self)
GtkWidget *box_raw = self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_BAUHAUS_SPACE);

g->demosaic_method_bayer = dt_bauhaus_combobox_from_params(self, "demosaicing_method");
for(int i=0;i<7;i++) dt_bauhaus_combobox_remove_at(g->demosaic_method_bayer, 9);
for(int i=0;i<7;i++) dt_bauhaus_combobox_remove_at(g->demosaic_method_bayer, 10);
gtk_widget_set_tooltip_text(g->demosaic_method_bayer, _("Bayer sensor demosaicing method, PPG and RCD are fast, AMaZE and LMMSE are slow.\nLMMSE is suited best for high ISO images.\ndual demosaicers double processing time."));

g->demosaic_method_xtrans = dt_bauhaus_combobox_from_params(self, "demosaicing_method");
for(int i=0;i<9;i++) dt_bauhaus_combobox_remove_at(g->demosaic_method_xtrans, 0);
for(int i=0;i<10;i++) dt_bauhaus_combobox_remove_at(g->demosaic_method_xtrans, 0);
gtk_widget_set_tooltip_text(g->demosaic_method_xtrans, _("X-Trans sensor demosaicing method, Markesteijn 3-pass and frequency domain chroma are slow.\ndual demosaicers double processing time."));

g->median_thrs = dt_bauhaus_slider_from_params(self, "median_thrs");
Expand Down
Loading

0 comments on commit 1b25ce9

Please sign in to comment.