Last active
May 4, 2023 21:11
-
-
Save ozwaldorf/7190054ca96a258a871f67a508af12ad to your computer and use it in GitHub Desktop.
Generate LUT from Arbitrary Color Palettes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -lt 3 ]; then | |
echo "Usage: `basename $0` <output filename> <noise level> color1 color2 ..." | |
exit 1 | |
fi | |
output=$1 | |
noise=$2 | |
shift 2 | |
p=($@) | |
# Create palette | |
for ((i=0; i<${#p[@]}; i++)); do | |
convert -size 100x100 xc:"${p[$i]}" "/tmp/swatch_$i.png" | |
done | |
montage -tile x1 -geometry +0+0 /tmp/swatch_*.png /tmp/palette.png | |
# Create LUT | |
convert HALD:8 -duplicate 512 -attenuate $noise +noise Gaussian -quantize LAB +dither -remap /tmp/palette.png -evaluate-sequence Mean $output | |
# Cleanup | |
rm /tmp/swatch_*.png | |
rm /tmp/palette.png | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example (Catppuccin Mocha)