Re: "even out" textures
Posted: 2013-07-12T18:32:40-07:00
how did you get those values?The left part has approx hue = 330 degrees, saturation = 11%, lightness = 17%.
The right part has hue = 113 degrees, sat = 30%, lightness = 24%.
Use https://github.com/ImageMagick/ImageMagick/discussions instead.
https://imagemagick.com/discourse-server/
https://imagemagick.com/discourse-server/viewtopic.php?t=23727
how did you get those values?The left part has approx hue = 330 degrees, saturation = 11%, lightness = 17%.
The right part has hue = 113 degrees, sat = 30%, lightness = 24%.
Code: Select all
D:\web\im>%IM%convert test_field.png -crop 512x1024+256+0 +repage -colorspace Lab -resize 1x1! -colorspace HSL txt:
# ImageMagick pixel enumeration: 1,1,255,hsla
0,0: ( 80, 45, 51,255) #502D33 hsla(31.4382%,17.7493%,19.8505%,1)
D:\web\im>%IM%convert test_field.png -crop 512x1024+256+0 +repage -resize 1x1! -colorspace HSL txt:
# ImageMagick pixel enumeration: 1,1,255,hsla
0,0: ( 80, 46, 51,255) #502E33 hsla(31.4656%,17.9477%,20.0702%,1)
Code: Select all
D:\web\im>%IM%convert test_field.png -crop 128x1024+0+0 +repage -colorspace Lab
-resize 1x1! -colorspace HSL txt:
# ImageMagick pixel enumeration: 1,1,255,hsla
0,0: (246, 16, 42,255) #F6102A hsla(96.5743%,6.35691%,16.585%,1)
D:\web\im>%IM%convert test_field.png -crop 128x1024+0+0 +repage -resize 1x1! -co
lorspace HSL txt:
# ImageMagick pixel enumeration: 1,1,255,hsla
0,0: (247, 16, 43,255) #F7102B hsla(96.6857%,6.31876%,16.701%,1)
Code: Select all
%IM%convert test_field.png ^
-blur 0x5 ^
-write tbl.png ^
( +clone -fill rgb(17.6394%%,15.5306%%,15.964%%) -colorize 100 ) ^
-colorspace HSL ^
-compose Difference -composite ^
-set colorspace HSL ^
-separate +delete ^
( -clone 0 -equalize -solarize 50%% -evaluate Multiply 2 -write tm0.png ) -delete 0 ^
( -clone 0 -equalize -write tm1.png ) -delete 0 ^
-compose Multiply -composite ^
-threshold 2%% ^
-negate ^
mask.png
rem Use the mask:
%IM%convert ^
test_field.png ^
( +clone -modulate 119,281,165.2 ) ^
mask.png ^
-compose Over -composite ^
tBlended.png
Code: Select all
rgb(17.6394%%,15.5306%%,15.964%%)
Code: Select all
rem Find the average RGB on the left ...
%IM%convert test_field.png ^
-depth 16 ^
-crop 128x1024+0+0 +repage ^
-colorspace Lab -resize "1x1^!" -colorspace sRGB ^
txt:
rem ... use the found average RGB in the "rgb(...)" in following:
%IM%convert test_field.png ^
-write tbl.png ^
( +clone -fill rgb(17.6394%%,15.5306%%,15.964%%) -colorize 100 ) ^
{... continue as in my code above.}
Code: Select all
D:\web\im>c:\im\ImageMagick-6.8.6-Q16fix\convert test_field.png -depth 16 -crop 128x1024+0+0 +repage -colorspace Lab -resize "1x1^!" -colorspace sRGB txt:
# ImageMagick pixel enumeration: 1,1,65535,srgba
0,0: (11560,10178,10462,65535) #2D2827C228DE srgba(17.6394%,15.5306%,15.964%,1)
Code: Select all
alejandro@desktop:~$ convert test.png -depth 16 -crop 128x1024+0+0 +repage -colorspace Lab -resize 1x1! -colorspace sRGB txt:
# ImageMagick pixel enumeration: 1,1,65535,srgba
0,0: ( 1591, 1264, 1363,65535) #063704F00553 srgba(2.42771%,1.92874%,2.0798%,1)
Code: Select all
alejandro@desktop:~$ convert -version
Version: ImageMagick 6.6.0-4 2012-05-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP
Code: Select all
alejandro@desktop:~$ convert new-test.png -depth 16 -crop 64x1024+0+0 +repage -colorspace Lab -resize 1x1! -colorspace sRGB txt:
# ImageMagick pixel enumeration: 1,1,65535,srgba
0,0: ( 3603, 2766, 2571,65535) #0E130ACE0A0B srgba(5.49783%,4.22065%,3.92309%,1)
Code: Select all
alejandro@desktop:~$ convert new-test.png -depth 16 -crop 64x1024+0+0 +repage -colorspace Lab -resize 1x1! -colorspace sRGB txt:
# ImageMagick pixel enumeration: 1,1,65535,srgba
0,0: (17295,15135,14566,65535) #438F3B1F38E6 srgba(26.3905%,23.0945%,22.2263%,1)
Code: Select all
alejandro@desktop:~$ convert test2.png -depth 16 -crop 128x1024+0+0 +repage -colorspace Lab -resize 1x1! -colorspace sRGB txt:
# ImageMagick pixel enumeration: 1,1,65535,srgba
0,0: (11560,10178,10462,65535) #2D2827C228DE srgba(17.6394%,15.5306%,15.964%,1)
Code: Select all
#!/bin/bash
ARGS=2
if [ $# -ne $ARGS ]
then
echo "Usage: `basename $0` {input-texture} {output-texture}"
else
IN="$1"
OUT="$2"
AREA_A="1024x2048+0+0"
AREA_B="400x2048+1560+0"
#AREA_B="512x512+64+0"
#RGB='17.6394%%,15.5306%%,15.964%%'
#MODULATE='119,281,165.2'
HSL_A=`convert "$IN" -crop "$AREA_A" +repage -colorspace Lab -resize 1x1! -colorspace HSL txt: | tail -1 | awk '{print $NF}' |sed 's/,1)//g' | sed 's/hsla(//g' | sed 's/%//g' | sed 's/,/ /g'`
#HSL_A=`convert "$IN" -crop "$AREA_A" +repage -resize 1x1! -colorspace HSL txt: | tail -1 | awk '{print $NF}'| sed 's/,1)//g' | sed 's/hsla(//g' | sed 's/%//g' | sed 's/,/ /g'`
H_A=`echo "$HSL_A" | awk '{print $1}'`
S_A=`echo "$HSL_A" | awk '{print $2}'`
L_A=`echo "$HSL_A" | awk '{print $3}'`
HSL_B=`convert "$IN" -crop "$AREA_B" +repage -colorspace Lab -resize 1x1! -colorspace HSL txt: | tail -1 | awk '{print $NF}' |sed 's/,1)//g' | sed 's/hsla(//g' | sed 's/%//g' | sed 's/,/ /g'`
#HSL_B=`convert "$IN" -crop "$AREA_B" +repage -resize 1x1! -colorspace HSL txt: | tail -1 | awk '{print $NF}'| sed 's/,1)//g' | sed 's/hsla(//g' | sed 's/%//g' | sed 's/,/ /g'`
H_B=`echo "$HSL_B" | awk '{print $1}'`
S_B=`echo "$HSL_B" | awk '{print $2}'`
L_B=`echo "$HSL_B" | awk '{print $3}'`
MODULATE_H=$(perl -e "print ( 100 + "$H_A" - "$H_B" )")
MODULATE_S=$(perl -e "print ( 100 * "$S_B" / "$S_A" )")
MODULATE_L=$(perl -e "print ( 100 * "$L_B" / "$L_A" )")
MODULATE="$MODULATE_L,$MODULATE_S,$MODULATE_H"
echo "$MODULATE"
RGB_A=`convert "$IN" -depth 16 -crop "$AREA_A" +repage -colorspace Lab -resize 1x1! -colorspace sRGB txt:| tail -1 | awk '{print $NF}' | sed 's/,1)//g' | sed 's/srgba(//g'`
RGB_B=`convert "$IN" -depth 16 -crop "$AREA_B" +repage -colorspace Lab -resize 1x1! -colorspace sRGB txt:| tail -1 | awk '{print $NF}' | sed 's/,1)//g' | sed 's/srgba(//g'`
echo "$RGB_A"
convert "$IN" -blur 0x5 -write tbl.png \( +clone -fill rgb\("$RGB_A"\) -colorize 100 \) -colorspace HSL -compose Difference -composite -set colorspace HSL -separate +delete \( -clone 0 -equalize -solarize 50%% -evaluate Multiply 2 -write tm0.png \) -delete 0 \( -clone 0 -equalize -write tm1.png \) -delete 0 -compose Multiply -composite -threshold 2%% -negate mask.png
convert "$IN" \( +clone -modulate "$MODULATE" \) mask.png -compose Over -composite "$OUT"
rm tbl.png tm0.png tm1.png mask.png
fi