Skip to content

Commit

Permalink
spectra: shade better and extend outside by inpainting
Browse files Browse the repository at this point in the history
  • Loading branch information
hanatos committed Feb 21, 2025
1 parent c9b1c84 commit 32b4c8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/pipe/modules/pick/display.comp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ main()
rgb = max(rgb, picked_rgb * vec3(pow(smoothstep(t, 0.0, d), 3)));
// on white:
// rgb = mix(rgb, picked_rgb, vec3(pow(smoothstep(t, 0.0, d), 3)));
// shade below:
if(ipos.y / float(imageSize(img_out).y) > 1.0-val)
rgb = mix(rgb, picked_rgb, 0.1);
}
imageStore(img_out, ipos, vec4(rgb, 1));
}
Expand Down
15 changes: 12 additions & 3 deletions src/tools/spec/mkspectra.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ void init_coeffs(double coeffs[3])
void clamp_coeffs(double coeffs[3])
{
double max = fmax(fmax(fabs(coeffs[0]), fabs(coeffs[1])), fabs(coeffs[2]));
if (max > 1000) {
if (max > 100000.0) {
for (int j = 0; j < 3; ++j)
coeffs[j] *= 1000 / max;
coeffs[j] *= 100000.0 / max;
}
}

Expand Down Expand Up @@ -342,7 +342,7 @@ void parallel_run(uint32_t item, void *data)

int ii = (int)fmin(d->max_w - 1, fmax(0, x * d->max_w + 0.5));
int jj = (int)fmin(d->max_h - 1, fmax(0, y * d->max_h + 0.5));
double m = fmax(0.05, 0.5*d->max_b[ii + d->max_w * jj]);
double m = fmax(0.01, 0.5*d->max_b[ii + d->max_w * jj]);
double rgbm[3] = {rgb[0] * m, rgb[1] * m, rgb[2] * m};
double resid = gauss_newton(rgbm, coeffs);

Expand Down Expand Up @@ -425,6 +425,15 @@ int main(int argc, char **argv)
for(int k=0;k<res*res;k++)
parallel_run(k, &par);
#endif
{
dt_inpaint_buf_t inpaint_buf = {
.dat = (float *)out,
.wd = res,
.ht = res,
.cpp = 4,
};
dt_inpaint(&inpaint_buf);
}

{ // write spectra map: (x,y) |--> sigmoid coeffs + saturation
header_t head = (header_t) {
Expand Down

0 comments on commit 32b4c8d

Please sign in to comment.