10
10
# an S-shaped curve which boosts the slope in the mid-tones and drops it for
11
11
# white and black.
12
12
13
- function sigmoid (float $ alpha , float $ beta , bool $ ushort = FALSE ): Vips \Image
13
+ function sigmoid (float $ alpha , float $ beta , bool $ ushort = false ): Vips \Image
14
14
{
15
15
# make a identity LUT, that is, a lut where each pixel has the value of
16
16
# its index ... if you map an image through the identity, you get the
@@ -33,7 +33,7 @@ function sigmoid(float $alpha, float $beta, bool $ushort = FALSE): Vips\Image
33
33
#
34
34
# though that's missing a term -- it should be
35
35
#
36
- # (1/(1+exp(β*(α-u))) - 1/(1+exp(β*α))) /
36
+ # (1/(1+exp(β*(α-u))) - 1/(1+exp(β*α))) /
37
37
# (1/(1+exp(β*(α-1))) - 1/(1+exp(β*α)))
38
38
#
39
39
# ie. there should be an extra α in the second term
@@ -47,7 +47,7 @@ function sigmoid(float $alpha, float $beta, bool $ushort = FALSE): Vips\Image
47
47
48
48
# and get the format right ... $result will be a float image after all
49
49
# that maths, but we want uchar or ushort
50
- $ result = $ result ->cast ($ ushort ?
50
+ $ result = $ result ->cast ($ ushort ?
51
51
Vips \BandFormat::USHORT : Vips \BandFormat::UCHAR );
52
52
53
53
return $ result ;
@@ -73,7 +73,7 @@ function sigLAB(Vips\Image $image, float $alpha, float $beta): Vips\Image
73
73
$ image = $ image ->colourspace (Vips \Interpretation::LABS );
74
74
75
75
# make a 16-bit LUT, then shrink by x2 to make it fit the range of L in labs
76
- $ lut = sigmoid ($ alpha , $ beta , TRUE );
76
+ $ lut = sigmoid ($ alpha , $ beta , true );
77
77
$ lut = $ lut ->shrinkh (2 )->multiply (0.5 );
78
78
$ lut = $ lut ->cast (Vips \BandFormat::SHORT );
79
79
@@ -89,8 +89,10 @@ function sigLAB(Vips\Image $image, float $alpha, float $beta): Vips\Image
89
89
# after the manipulation above, $image will just be tagged as a generic
90
90
# multiband image, vips will no longer know that it's a labs, so we need to
91
91
# tell colourspace what the source space is
92
- $ image = $ image ->colourspace ($ old_interpretation ,
93
- ["source_space " => Vips \Interpretation::LABS ]);
92
+ $ image = $ image ->colourspace (
93
+ $ old_interpretation ,
94
+ ["source_space " => Vips \Interpretation::LABS ]
95
+ );
94
96
95
97
return $ image ;
96
98
}
0 commit comments