Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controlling Hue Chroma ?
#1
Hi,

I would like to modify the hue-chroma of some images.

I tried the following function:


Code:
(gimp-drawable-hue-chroma drawable MODE-REPLACE -60 20 0 100.0)

But it gives me an error:


Code:
Error: eval: unbound variable: gimp-drawable-hue-chroma

If someone knows which command to use and what are the parameters ?
Reply
#2
(11-14-2024, 07:45 AM)Alpha504 Wrote: Hi,

I would like to modify the hue-chroma of some images.

I tried the following function:


Code:
(gimp-drawable-hue-chroma drawable MODE-REPLACE -60 20 0 100.0)

But it gives me an error:


Code:
Error: eval: unbound variable: gimp-drawable-hue-chroma

If someone knows which command to use and what are the parameters ?
There is no PDB function that contains chroma in its name. The nearest function is gimp-drawable-hue-saturation.

If you use "Filters/Script-Fu/Console" and click the "Browse..." button you can search for PDB functions by typing part of the name in the "Search:" box - you will then see which functions are associated with the part of the name that you entered and what the function parameters are.
Reply
#3
(11-14-2024, 07:45 AM)Alpha504 Wrote: Hi,

I would like to modify the hue-chroma of some images.

I tried the following function:


Code:
(gimp-drawable-hue-chroma drawable MODE-REPLACE -60 20 0 100.0)

But it gives me an error:


Code:
Error: eval: unbound variable: gimp-drawable-hue-chroma

If someone knows which command to use and what are the parameters ?

As the gegl icon indicates, these filters are GEGL filters, and there is no easy way to call them in Gimp2.10 (some people did it, but it's not a pretty sight).

Things are somewhat easier (but not outright easy yet) in Gimp3+Python3. See this for instance.

Note that for such simple transforms, utilities such as ImageMagick or Python image libraries such as Pillow probably have the functionality.
Reply
#4
Thanks for replies, I looked at the source code of gimp 2.10, and I quickly wrote a modification, in order to get it working.

I took the source code of gimp-drawable-hue-saturation as a base, and used babl library to switch between RGB and HCL.

With the same parameters, my implementation gives an image that is very close to the one manually created with gimp user interface. But the two images are not identical. I have compared them with Imagemagick tool "compare".

However, the images given by my implementation seem to be usable.

I think I will have to compare with other software tools and libraries to know what is the best option.
Reply
#5
On some images there are some color artifacts when I use gimp user interface.

But with my modified implementation of gimp and a gimp script, the image looks better.

Here is one of  my experiments, I changed hue to -60 and chroma to +20.

The original image:
   

The image given by gimp user interface, we can see some color artifacts in the bottom of the image, but maybe it is correct this algorithm to make them:
   

The image given by the script with the modified implementation of gimp, without artifacts, but the color of the part under the folder have changed to gold instead of silver in the original image:
   

And the differences between the two last images:
   

I have attached the original file, if someone wants to make experiments with other software or maybe gimp 3.0.


Attached Files Image(s)
   
Reply
#6
(11-17-2024, 06:23 PM)Alpha504 Wrote: everything
This is great!

I've registered just for this, as I'm trying to do the exact same thing but I clearly have waaaay less knowledge about coding.

Would you be so kind to share your wizardry with us Alpha504?

Personally i'd love to use just imagemagick as I'm not sure about Gimp 3.0 via flatpak and python scripting, but I'd love to try anything!

Thanks.
Reply
#7
*Actually, problem solved last night. Let me be the one that gives back to the community for once. Smile

it's enough to use imagemagick. I made a lil script to run it on all the pictures that are in /home/user/input folder.

---------------------------------
#! /bin/bash
# make sure to have your target pictures all in /home/user/input folder
mkdir -p /home/user/output/
for file in /home/user/input/*.{jpg,jpeg,png,bmp}; do
INDENT [ -f "$file" ] && convert "$file" -strip -set colorspace sRGB -define modulate:colorspace=LCHab -modulate 100,100,156 -colorspace sRGB "/home/ale/output/$(basename "$file")"
done
echo "END"
read
--------------------------------------------

Copy this text above in a file.txt, remove "INDENT" (make sure there's an actual indent there), rename it asyouwant.sh, make it executable, run it in the terminal. Works beautifully and fast. Grok3 FTW!

The 3 values control brightness, saturation, and hue. 100,100,100 leaves the image unchanged. The first 2 are percentage multipliers and go from 0 to, I don't know, millions. The third controls the hue wheel in the LCH color space, and go from 0 to 200. Try changing that number to play with the color spectrum till you achieve the desired hue. So yeah perfect for adjusting multicolor icon themes.

Alright, my job here is done!

.

Addendum: what about subfolders and maintaining the same directory tree in the output folder?
There you go:

-------------------------------------
#!/bin/bash
INPUT_DIR="/home/user/input"
OUTPUT_DIR="/home/user/output"
mkdir -p "$OUTPUT_DIR"
find "$INPUT_DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.bmp" \) | while read -r file; do
INDENT REL_PATH="${file#$INPUT_DIR/}"
INDENT OUT_DIR="$OUTPUT_DIR/$(dirname "$REL_PATH")"
INDENT mkdir -p "$OUT_DIR"
INDENT convert "$file" -strip -set colorspace sRGB -define modulate:colorspace=LCHab -modulate 100,100,16 -colorspace sRGB "$OUT_DIR/$(basename "$file")"
done
echo "END"
read
-----------------------------------
Reply


Forum Jump: