fmw42 wrote:VanGog wrote:There is no point in converting from HSB (or RGB) to HSL and then changing the script to use HSL in place of HSB.
I dont agree with you. There is big difference between the two codes (HSB/HSL) because the HSL is at least 3x faster and performs less executions. Performance is high priority for me. I probably will use Javascript to calculate HSV values.
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<script>
function HSB2HSL(Hhsb,Shsb,B){
Shsb=Shsb/100;B=B/100;
L = 0.5 * B * (2 - Shsb)
Shsl = (Shsb*B)/(1-Math.abs(2*L-1) )
return {H:Hhsb, S:Shsl, L:L }
} </script>
<body onload="var HSL=HSB2HSL(37, 5, 35);document.write(HSL.H + ',' + HSL.S + ',' + HSL.L)">
</body>
</html>
In the example above I got:
37 , 0.02564102564102564 , 0.34125 (I hope it's correct)
New more complex converter in html here:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>HSB to HSL convertor for CMD/batch use - edit the file as needed</title>
</head>
<script>
function HSB2HSL(Hhsb,Shsb,B){
Shsb=Shsb/100;B=B/100;
L = 0.5 * B * (2 - Shsb)
Shsl = (Shsb*B)/(1-Math.abs(2*L-1) )
return {H:Hhsb, S:Shsl, L:L }
}
function printVariables(REM,groupNo){
document.write("<b>"+REM+"</b><br>");
// console.log(groupNo);
var Min = eval('c'+groupNo+'min');
var Max = eval('c'+groupNo+'max');
// console.log(Min);
// console.log(Max);
document.write(
'SET minH'+groupNo+'='+Min.H+'<br>'+
'SET maxH'+groupNo+'='+Max.H+'<br>'+
'SET minS'+groupNo+'='+(Min.S*100)+'<br>'+
'SET maxS'+groupNo+'='+(Max.S*100)+'<br>'+
'SET minL'+groupNo+'='+(Min.L*100)+'<br>'+
'SET maxL'+groupNo+'='+(Max.L*100)+'<br>'+
'<p>'
);
}
</script>
<script>
/*******************************************
EDIT SECTION BELLOW AS NEEDED
********************************************/
document.write(
'<h3>REM Use HSL colors. Convert raw HSB values from Adobe Photoshop Color Picker by HSB2HSL_converter:</h3></br>'
);
var c1min=HSB2HSL(186,21,23);
var c1max=HSB2HSL(240,52,54);
printVariables('REM Dark shadows on route and buildings',1);
var c2min=HSB2HSL(158,8,31);
var c2max=HSB2HSL(216,33,46);
printVariables('REM Light shadows on route and buildings',2);
var c3min=HSB2HSL(37,5,35);
var c3max=HSB2HSL(180,12,47);
printVariables('REM Light shadows Gray - on route and buildings',3);
</script>
</html>
I just hope that the calculation is correct:
HSB2HSL(186,21,23) converts to 186, 11.731843575418996, 20.585
I am not sure if the HSL code works because I got empty mask if I use first group of conditions.
This is the code I am trying with the converted colors (should be HSL):
Code: Select all
REM Use HSL colors. Convert raw HSB values from Adobe Photoshop Color Picker by HSB2HSL_converter:
REM Dark shadows on route and buildings
SET minH1=186
SET maxH1=240
SET minS1=11.731843575418996
SET maxS1=35.135135135135144
SET minL1=20.585
SET maxL1=39.96
REM Light shadows on route and buildings
SET minH2=158
SET maxH2=216
SET minS2=4.166666666666667
SET maxS2=19.76047904191617
SET minL2=29.759999999999998
SET maxL2=38.41
REM Light shadows Gray - on route and buildings
SET minH3=37
SET maxH3=180
SET minS3=2.564102564102564
SET maxS3=6.382978723404255
SET minL3=34.125
SET maxL3=44.18
convert -size 1x360 gradient: -fx "( u>%minH1%/360 && u<%maxH1%/360 )?white:black" red_hue_lut.png
convert -size 1x360 gradient: -fx "( u>%minS1%/255 && u<%maxS1%/255 )?white:black" green_sat_lut.png
convert -size 1x360 gradient: -fx "( u>%minL1%/255 && u<%maxL1%/255 )?white:black" blue_light_lut.png
convert red_hue_lut.png green_sat_lut.png blue_light_lut.png -evaluate-sequence multiply lut.png
convert ( test.jpg -colorspace HSL ) lut.png -clut mask.png
convert test.jpg -mask mask.png <processing> result.png