[gegl] hue-chroma: Fix artifacts in when operating on gray
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] hue-chroma: Fix artifacts in when operating on gray
- Date: Wed, 27 May 2020 16:51:09 +0000 (UTC)
commit 4b04f4e1076c650466e4f5c5548c9d2366d8dfcf
Author: Elle Stone <ellestone ninedegreesbelow com>
Date: Wed May 27 11:22:55 2020 -0400
hue-chroma: Fix artifacts in when operating on gray
Previously gray portions of the image were producing chroma/hue changes
after apply hue-chroma operation that raised chroma.
operations/common/hue-chroma.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/operations/common/hue-chroma.c b/operations/common/hue-chroma.c
index 666c8f92e..f82b5b0f5 100644
--- a/operations/common/hue-chroma.c
+++ b/operations/common/hue-chroma.c
@@ -43,6 +43,8 @@ property_double (lightness, _("Lightness"), 0.0)
#include "gegl-op.h"
+#define EPSILON 1e-6f
+
static void
prepare (GeglOperation *operation)
{
@@ -77,18 +79,26 @@ process (GeglOperation *op,
while (n_pixels--)
{
- out_pixel[0] = in_pixel[0] + lightness;
- out_pixel[1] = in_pixel[1] + chroma;
- out_pixel[2] = in_pixel[2] + hue;
-
- out_pixel[1] = CLAMP (out_pixel[1], 0, 200.0);
-
+ if ( ( abs(in_pixel[0]-in_pixel[1])>EPSILON)
+ && ( abs(in_pixel[1]-in_pixel[2])>EPSILON ) )
+ {
+ out_pixel[0] = in_pixel[0] + lightness;
+ out_pixel[1] = in_pixel[1] + chroma;
+ out_pixel[2] = in_pixel[2] + hue;
+ }
+ else
+ {
+ out_pixel[0] = in_pixel[0] + lightness;
+ out_pixel[1] = in_pixel[1];
+ out_pixel[2] = in_pixel[2];
+ }
+
+ out_pixel[1] = CLAMP (out_pixel[1], 0, 300.0);
out_pixel[3] = in_pixel[3];
in_pixel += 4;
out_pixel += 4;
}
-
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]