30#define gbuf(BUF, A, B) ((BUF)[4 * (width * ((B)) + ((A))) + ch])
36 return (uint8_t)CLAMP(i + 127, 0, 255);
46 const int step = 1 << l;
47 const int st = step / 2;
50#pragma omp parallel for default(none) \
51 dt_omp_firstprivate(height, st, step, width, ch) \
55 for(
int j = 0; j <
height; j++)
60 for(; i <
width - st; i += step)
67 for(i = step; i <
width - st; i += step)
73#pragma omp parallel for default(none) \
74 dt_omp_firstprivate(height, st, step, width, ch) \
78 for(
int i = 0; i <
width; i++)
83 for(; j <
height - st; j += step)
90 for(j = step; j <
height - st; j += step)
103 int fx = i / (float)wd * fcols;
104 int fy = j / (float)ht * frows;
105 int fi = fcols * fy + fx;
117 f[fi].x2 += (float)i * i;
121 f[fi].y2 += (float)j * j;
136 int buffer_width,
int buffer_height)
139 const int wd = buffer_width;
140 const int ht = buffer_height;
141 const int fs = frows * fcols;
149#pragma omp parallel for schedule(static) default(shared)
151 for(
int j = 0; j < ht - 1; j += 4)
152 for(
int i = 0; i < wd - 1; i += 4)
161 int num_clusters = 0;
162 for(
int k = 0; k < fs; k++)
163 if(focus[k].n * 4 > wd * ht / (
float)fs * 0.01f) num_clusters++;
169#pragma omp parallel for schedule(static) default(shared)
171 for(
int j = 0; j < ht - 1; j += 8)
173 for(
int i = 0; i < wd - 1; i += 8)
182 for(
int k = 0; k < fs; k++)
184 if(focus[k].n * 6.0f > wd * ht / (
float)fs * 0.01f)
197#pragma omp parallel for schedule(static) default(shared)
199 for(
int j=1;j<ht-1;j++)
201 int index = 4*j*wd+4;
202 for(
int i=1;i<wd-1;i++)
204 int32_t diff = 4*buffer[index+1]
207 - buffer[index-4*wd+1]
208 - buffer[index+4*wd+1];
215 for(
int k = 0; k < fs; k++)
217 focus[k].
thrs /= fabsf((
float)focus[k].n);
218 focus[k].
x /= fabsf((
float)focus[k].n);
219 focus[k].
x2 /= fabsf((
float)focus[k].n);
220 focus[k].
y /= fabsf((
float)focus[k].n);
221 focus[k].
y2 /= fabsf((
float)focus[k].n);
227 float full_zoom,
float full_x,
float full_y)
229 const int fs = frows * fcols;
238 int wd = buffer_width + image.
crop_x;
239 int ht = buffer_height + image.
crop_y;
242 float *pos = malloc(fs * 6 *
sizeof(
float));
243 float *offx = pos + fs * 2, *offy = pos + fs * 4;
245 for(
int k = 0; k < fs; k++)
247 const float stddevx = sqrtf(focus[k].x2 - focus[k].x * focus[k].x);
248 const float stddevy = sqrtf(focus[k].y2 - focus[k].y * focus[k].y);
251 const float x = focus[k].
x + image.
crop_x;
252 const float y = focus[k].
y + image.
crop_y;
256 offx[2 * k + 0] = x + stddevx;
259 offy[2 * k + 1] = y + stddevy;
286 const float scale = fminf((
width - 2 * tb) / (
float)wd, (
height - 2 * tb) / (
float)ht) * full_zoom;
287 cairo_scale(cr, scale, scale);
293 fx = fminf((wd * scale -
width) / 2, fabsf(full_x));
294 if(full_x < 0) fx = -fx;
295 if(wd * scale <=
width) fx = 0;
296 fy = fminf((ht * scale -
height) / 2, fabsf(full_y));
297 if(full_y < 0) fy = -fy;
298 if(ht * scale <=
height) fy = 0;
303 cairo_rectangle(cr, 0, 0, wd, ht);
307 const int ndash =
sizeof(dashes) /
sizeof(dashes[0]);
308 double offset = 0.0f;
309 cairo_set_dash(cr, dashes, ndash, offset);
312 for(
int k = 0; k < fs; k++)
315 const float col = fminf(1.0f, intens);
317 if(focus[k].n * 4.0f > buffer_width * buffer_height / (
float)fs * 0.01f)
319 else if(-focus[k].n * 6.0f > buffer_width * buffer_height / (
float)fs * 0.01f)
323 for(
int i = 0; i < 2; i++)
328 cairo_set_source_rgb(cr, .1f, .1f, col);
330 cairo_set_source_rgb(cr, col, .1f, .1f);
331 cairo_set_dash(cr, dashes, ndash, dashes[0]);
335 cairo_set_source_rgb(cr, .1f, .1f, .1f);
336 cairo_set_dash(cr, dashes, ndash, 0);
338 cairo_move_to(cr, offx[2 * k + 0], offx[2 * k + 1]);
339 cairo_curve_to(cr, -pos[2 * k + 0] + offx[2 * k + 0] + offy[2 * k + 0],
340 -pos[2 * k + 1] + offx[2 * k + 1] + offy[2 * k + 1],
341 -pos[2 * k + 0] + offx[2 * k + 0] + offy[2 * k + 0],
342 -pos[2 * k + 1] + offx[2 * k + 1] + offy[2 * k + 1], offy[2 * k + 0], offy[2 * k + 1]);
343 cairo_curve_to(cr, pos[2 * k + 0] - offx[2 * k + 0] + offy[2 * k + 0],
344 pos[2 * k + 1] - offx[2 * k + 1] + offy[2 * k + 1],
345 pos[2 * k + 0] - offx[2 * k + 0] + offy[2 * k + 0],
346 pos[2 * k + 1] - offx[2 * k + 1] + offy[2 * k + 1],
347 2 * pos[2 * k + 0] - offx[2 * k + 0], 2 * pos[2 * k + 1] - offx[2 * k + 1]);
348 cairo_curve_to(cr, 3 * pos[2 * k + 0] - offx[2 * k + 0] - offy[2 * k + 0],
349 3 * pos[2 * k + 1] - offx[2 * k + 1] - offy[2 * k + 1],
350 3 * pos[2 * k + 0] - offx[2 * k + 0] - offy[2 * k + 0],
351 3 * pos[2 * k + 1] - offx[2 * k + 1] - offy[2 * k + 1],
352 2 * pos[2 * k + 0] - offy[2 * k + 0], 2 * pos[2 * k + 1] - offy[2 * k + 1]);
353 cairo_curve_to(cr, pos[2 * k + 0] + offx[2 * k + 0] - offy[2 * k + 0],
354 pos[2 * k + 1] + offx[2 * k + 1] - offy[2 * k + 1],
355 pos[2 * k + 0] + offx[2 * k + 0] - offy[2 * k + 0],
356 pos[2 * k + 1] + offx[2 * k + 1] - offy[2 * k + 1], offx[2 * k + 0], offx[2 * k + 1]);
359 cairo_scale(cr, 1. / scale, 1. / scale);
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
const double thrs
Definition chart/main.c:41
darktable_t darktable
Definition darktable.c:111
#define UNKNOWN_IMAGE
Definition darktable.h:139
void dt_dev_cleanup(dt_develop_t *dev)
Definition develop.c:150
void dt_dev_init(dt_develop_t *dev, int32_t gui_attached)
Definition develop.c:52
int dt_dev_distort_transform_plus(dt_develop_t *dev, dt_dev_pixelpipe_t *pipe, const double iop_order, const int transf_direction, float *points, size_t points_count)
Definition develop.c:1234
int dt_dev_load_image(dt_develop_t *dev, const int32_t imgid)
Definition develop.c:738
@ DT_DEV_TRANSFORM_DIR_ALL
Definition develop.h:72
static void dt_focus_draw_clusters(cairo_t *cr, int width, int height, int32_t imgid, int buffer_width, int buffer_height, dt_focus_cluster_t *focus, int frows, int fcols, float full_zoom, float full_x, float full_y)
Definition focus.h:225
static void dt_focus_create_clusters(dt_focus_cluster_t *focus, int frows, int fcols, uint8_t *buffer, int buffer_width, int buffer_height)
Definition focus.h:135
#define gbuf(BUF, A, B)
Definition focus.h:30
static void _dt_focus_cdf22_wtf(uint8_t *buf, const int l, const int width, const int height)
Definition focus.h:42
static void _dt_focus_update(dt_focus_cluster_t *f, int frows, int fcols, int i, int j, int wd, int ht, int diff)
Definition focus.h:97
#define CHANNEL
Definition focus.h:32
#define FOCUS_THRS
Definition focus.h:31
static int _from_uint8(uint8_t i)
Definition focus.h:38
static uint8_t _to_uint8(int i)
Definition focus.h:34
static float f(const float t, const float c, const float x)
Definition graduatednd.c:173
#define DT_PIXEL_APPLY_DPI(value)
Definition gtk.h:38
static gboolean draw(GtkWidget *widget, cairo_t *cr, dt_iop_module_t *self)
Definition hotpixels.c:358
void dt_image_cache_read_release(dt_image_cache_t *cache, const dt_image_t *img)
Definition image_cache.c:239
dt_image_t * dt_image_cache_get(dt_image_cache_t *cache, const int32_t imgid, char mode)
Definition image_cache.c:217
@ DT_MIPMAP_NONE
Definition mipmap_cache.h:42
void dt_dev_pixelpipe_get_roi_out(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, const int width_in, const int height_in, int *width, int *height)
Definition pixelpipe_hb.c:2114
void dt_dev_pixelpipe_create_nodes(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev)
Definition pixelpipe_hb.c:352
int dt_dev_pixelpipe_init_dummy(dt_dev_pixelpipe_t *pipe, int32_t width, int32_t height)
Definition pixelpipe_hb.c:152
void dt_dev_pixelpipe_set_input(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, int32_t imgid, int width, int height, float iscale, dt_mipmap_size_t size)
Definition pixelpipe_hb.c:230
void dt_dev_pixelpipe_cleanup(dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:253
#define dt_dev_pixelpipe_synch_all(pipe, dev)
Definition pixelpipe_hb.h:289
struct dt_gui_gtk_t * gui
Definition darktable.h:541
struct dt_image_cache_t * image_cache
Definition darktable.h:543
struct dt_develop_t * develop
Definition darktable.h:536
Definition pixelpipe_hb.h:127
int iwidth
Definition pixelpipe_hb.h:133
int processed_width
Definition pixelpipe_hb.h:137
int processed_height
Definition pixelpipe_hb.h:137
int iheight
Definition pixelpipe_hb.h:133
int32_t border_size
Definition develop.h:200
float y
Definition focus.h:26
float x
Definition focus.h:26
float y2
Definition focus.h:26
float x2
Definition focus.h:26
int64_t n
Definition focus.h:25
float thrs
Definition focus.h:27
double ppd
Definition gtk.h:117
Definition common/image.h:195
int32_t crop_y
Definition common/image.h:224
int32_t crop_x
Definition common/image.h:224