Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add module : scene-referred blurs #9521

Merged
merged 4 commits into from Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 55 additions & 0 deletions data/kernels/blurs.cl
@@ -0,0 +1,55 @@
/*
This file is part of darktable,
copyright (c) 2021 darktable developers.

darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

darktable is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with darktable. If not, see <http://www.gnu.org/licenses/>.
*/

#include "common.h"

// use our own coordinate sampler
const sampler_t samplerA = CLK_NORMALIZED_COORDS_FALSE |
CLK_ADDRESS_NONE |
CLK_FILTER_NEAREST;

kernel void
convolve(read_only image2d_t in, read_only image2d_t kern, write_only image2d_t out,
const int width, const int height, const int radius)
{
const int x = get_global_id(0);
const int y = get_global_id(1);

if(x >= width || y >= height) return;

float4 pix_in = read_imagef(in, samplerA, (int2)(x, y));
float4 acc = 0.f;

for(int l = -radius; l <= radius; l++)
for(int m = -radius; m <= radius; m++)
{
const int ii = clamp(y + l, 0, height - 1);
const int jj = clamp(x + m, 0, width - 1);
const float4 pix = read_imagef(in, samplerA, (int2)(jj, ii));

const int ik = l + radius;
const int jk = m + radius;
const float k = read_imagef(kern, samplerA, (int2)(jk, ik)).x;

acc += k * pix;
}

// copy alpha
acc.w = pix_in.w;
write_imagef(out, (int2)(x, y), acc);
}
1 change: 1 addition & 0 deletions data/kernels/programs.conf
Expand Up @@ -34,3 +34,4 @@ negadoctor.cl 30
demosaic_rcd.cl 31
channelmixer.cl 32
diffuse.cl 33
blurs.cl 34
1 change: 1 addition & 0 deletions po/POTFILES.in
Expand Up @@ -186,6 +186,7 @@ src/iop/basicadj.c
src/iop/bilat.c
src/iop/bilateral.cc
src/iop/bloom.c
src/iop/blurs.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do it just after merging, but for reference you always have two entries to add, one for the module itself and one for the generated introspection code.

src/iop/borders.c
src/iop/cacorrect.c
src/iop/cacorrectrgb.c
Expand Down
3 changes: 3 additions & 0 deletions src/common/iop_order.c
Expand Up @@ -110,6 +110,7 @@ const dt_iop_order_entry_t legacy_order[] = {
{ {27.5f }, "channelmixerrgb", 0},
{ {27.5f }, "censorize", 0},
{ {27.5f }, "negadoctor", 0},
{ {27.5f }, "blurs", 0},
{ {27.5f }, "basicadj", 0},
{ {28.0f }, "colorreconstruct", 0},
{ {29.0f }, "colorchecker", 0},
Expand Down Expand Up @@ -199,6 +200,7 @@ const dt_iop_order_entry_t v30_order[] = {
{ {28.5f }, "channelmixerrgb", 0},
{ {28.5f }, "censorize", 0},
{ {28.5f }, "negadoctor", 0}, // Cineon film encoding comes after scanner input color profile
{ {28.5f }, "blurs", 0}, // physically-accurate blurs (motion and lens)
{ {29.0f }, "nlmeans", 0}, // signal processing (denoising)
// -> needs a signal as scene-referred as possible (even if it works in Lab)
{ {30.0f }, "colorchecker", 0}, // calibration to "neutral" exchange colour space
Expand Down Expand Up @@ -664,6 +666,7 @@ GList *dt_ioppr_get_iop_order_list(int32_t imgid, gboolean sorted)
_insert_before(iop_order_list, "ashift", "cacorrectrgb");
_insert_before(iop_order_list, "graduatednd", "crop");
_insert_before(iop_order_list, "channelmixerrgb", "diffuse");
_insert_before(iop_order_list, "nlmeans", "blurs");
}
}
else if(version == DT_IOP_ORDER_LEGACY)
Expand Down
2 changes: 2 additions & 0 deletions src/iop/CMakeLists.txt
Expand Up @@ -148,6 +148,8 @@ add_iop(censorize "censorize.c")
add_iop(colorbalancergb "colorbalancergb.c")
add_iop(cacorrectrgb "cacorrectrgb.c")
add_iop(diffuse "diffuse.c")
add_iop(blurs "blurs.c")


if(Rsvg2_FOUND)
add_iop(watermark "watermark.c")
Expand Down