Skip to content

Commit

Permalink
17178: Added color picker lab->rgb, lab->hsl. Broken.
Browse files Browse the repository at this point in the history
  • Loading branch information
kofa73 committed Sep 29, 2024
1 parent 91262b6 commit 6cbd22d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
55 changes: 53 additions & 2 deletions src/common/color_picker.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ static inline void _color_picker_rgb_or_lab(dt_aligned_pixel_t acc,
_update_stats_by_ch(acc, low, high, k, pixels[i + k]);
}


static inline void _color_picker_Lab_2_JzCzhz(dt_aligned_pixel_t acc,
dt_aligned_pixel_t low,
dt_aligned_pixel_t high,
Expand All @@ -127,6 +126,39 @@ static inline void _color_picker_Lab_2_JzCzhz(dt_aligned_pixel_t acc,
}
}

static inline void _color_picker_Lab_2_rgb(dt_aligned_pixel_t acc,
dt_aligned_pixel_t low,
dt_aligned_pixel_t high,
const float *const pixels,
const size_t width,
const void *const data)
{
for(size_t i = 0; i < width; i += 4)
{
dt_aligned_pixel_t pick;
dt_Lab_2_Rec709_D50(pixels + i, pick);
_update_stats_4ch(acc, low, high, pick);
}
}

static inline void _color_picker_Lab_2_hsl(dt_aligned_pixel_t acc,
dt_aligned_pixel_t low,
dt_aligned_pixel_t high,
const float *const pixels,
const size_t width,
const void *const data)
{
for(size_t i = 0; i < width; i += 4)
{
dt_aligned_pixel_t rgb;
dt_Lab_2_Rec709_D50(pixels + i, rgb);

dt_aligned_pixel_t pick;
dt_RGB_2_HSL(rgb, pick);
pick[3] = pick[0] < 0.5f ? pick[0] + 0.5f : pick[0] - 0.5f;
_update_stats_4ch(acc, low, high, pick);
}
}

static inline void _color_picker_lch(dt_aligned_pixel_t acc,
dt_aligned_pixel_t low,
Expand Down Expand Up @@ -489,6 +521,17 @@ void dt_color_picker_helper(const dt_iop_buffer_dsc_t *dsc,
const dt_iop_colorspace_type_t effective_cst =
image_cst == IOP_CS_RAW ? IOP_CS_RGB : image_cst;


dt_print(DT_DEBUG_ALWAYS,
"[colorpicker] @@@kofa DEBUG colorspace conversion from %s to %s\n",
dt_iop_colorspace_to_name(image_cst), dt_iop_colorspace_to_name(picker_cst));

/* TODO kofa
* cover conversions:
* from IOP_CS_LAB to IOP_CS_RGB
* from IOP_CS_LAB to IOP_CS_HSL local contrast / RGB display / pick H
*/

if(effective_cst == IOP_CS_LAB && picker_cst == IOP_CS_LCH)
{
// blending for Lab modules (e.g. color zones and tone curve)
Expand All @@ -504,10 +547,18 @@ void dt_color_picker_helper(const dt_iop_buffer_dsc_t *dsc,
// scene-referred blending for RGB modules
_color_picker_work_4ch(source, roi, box, pick, profile, _color_picker_jzczhz, 10);
}
else if(effective_cst == IOP_CS_JZCZHZ && picker_cst == IOP_CS_LAB)
else if(effective_cst == IOP_CS_LAB && picker_cst == IOP_CS_JZCZHZ)
{
_color_picker_work_4ch(source, roi, box, pick, NULL, _color_picker_Lab_2_JzCzhz, 10);
}
else if(effective_cst == IOP_CS_LAB && picker_cst == IOP_CS_RGB)
{
_color_picker_work_4ch(source, roi, box, pick, NULL, _color_picker_Lab_2_rgb, 10);
}
else if(effective_cst == IOP_CS_LAB && picker_cst == IOP_CS_HSL)
{
_color_picker_work_4ch(source, roi, box, pick, NULL, _color_picker_Lab_2_hsl, 10);
}
else if(effective_cst == picker_cst)
{
// most iop pickers and the global picker
Expand Down
9 changes: 9 additions & 0 deletions src/common/colorspaces_inline_conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,15 @@ static inline void dt_Lab_2_JzCzhz(const dt_aligned_pixel_t Lab, dt_aligned_pixe
}


static inline void dt_Lab_2_Rec709_D50(const dt_aligned_pixel_t Lab, dt_aligned_pixel_t rgb)
{
dt_aligned_pixel_t XYZ;
dt_Lab_to_XYZ(Lab, XYZ);

dt_XYZ_to_Rec709_D50(XYZ, rgb);
}


DT_OMP_DECLARE_SIMD(aligned(JzCzhz, JzAzBz: 16))
static inline void dt_JzCzhz_2_JzAzBz(const dt_aligned_pixel_t JzCzhz, dt_aligned_pixel_t JzAzBz)
{
Expand Down

0 comments on commit 6cbd22d

Please sign in to comment.