func Sigmoid(midpoint, factor float32) Filter {
	a := minf32(maxf32(midpoint, 0), 1)
	b := absf32(factor)
	sig0 := sigmoid(a, b, 0)
	sig1 := sigmoid(a, b, 1)
	e := float32(1.0e-5)

	return &colorchanFilter{
		fn: func(x float32) float32 {
			if factor == 0 {
				return x
			} else if factor > 0 {
				sig := sigmoid(a, b, x)
				return (sig - sig0) / (sig1 - sig0)
			} else {
				arg := minf32(maxf32((sig1-sig0)*x+sig0, e), 1-e)
				return a - logf32(1/arg-1)/b
			}
		},
		lut: true,
	}
}
// Sigmoid creates a filter that changes the contrast of an image using a sigmoidal function and returns the adjusted image.
// It's a non-linear contrast change useful for photo adjustments as it preserves highlight and shadow detail.
// The midpoint parameter is the midpoint of contrast that must be between 0 and 1, typically 0.5.
// The factor parameter indicates how much to increase or decrease the contrast, typically in range (-10, 10).
// If the factor parameter is positive the image contrast is increased otherwise the contrast is decreased.
//
// Example:
//
//	g := gift.New(
//		gift.Sigmoid(0.5, 5),
//	)
//	dst := image.NewRGBA(g.Bounds(src.Bounds()))
//	g.Draw(dst, src)
//
Sigmoid creates a filter that changes the contrast of an image using a sigmoidal function and returns the adjusted image.
It's a non-linear contrast change useful for photo adjustments as it preserves highlight and shadow detail.
The midpoint parameter is the midpoint of contrast that must be between 0 and 1, typically 0.5.
The factor parameter indicates how much to increase or decrease the contrast, typically in range (-10, 10).
If the factor parameter is positive the image contrast is increased otherwise the contrast is decreased.



g := gift.New(
gift.Sigmoid(0.5, 5),
)
dst := image.NewRGBA(g.Bounds(src.Bounds()))
g.Draw(dst, src)
// Sigmoid creates a filter that changes the contrast of an image using a sigmoidal function and returns the adjusted image . // It ' s a non - linear contrast change useful for photo adjustments as it preserves highlight and shadow detail . // The midpoint parameter is the midpoint of contrast that must be between 0 and 1 typically 0 . 5 . // The factor parameter indicates how much to increase or decrease the contrast typically in range ( - 10 10 ) . // If the factor parameter is positive the image contrast is increased otherwise the contrast is decreased . // // Example : // // g : = gift . New ( // gift . Sigmoid ( 0 . 5 5 ) // ) // dst : = image . NewRGBA ( g . Bounds ( src . Bounds () )) // g . Draw ( dst src ) //
func Sigmoid(midpoint, factor float32) Filter {
	a := minf32(maxf32(midpoint, 0), 1)
	b := absf32(factor)
	sig0 := sigmoid(a, b, 0)
	sig1 := sigmoid(a, b, 1)
	e := float32(1.0e-5)
	return &colorchanFilter{
		fn: func(x float32) float32 {
			if factor == 0 {
				return x
			} else if factor > 0 {
				sig := sigmoid(a, b, x)
				return (sig - sig0) / (sig1 - sig0)
			} else {
				arg := minf32(maxf32((sig1-sig0)*x+sig0, e), 1-e)
				return a - logf32(1/arg-1)/b
			}
		},
		lut: true,
	}
}
func Sigmoid ( midpoint , factor float32 ) Filter { a := minf32 ( maxf32 ( midpoint , 0 ) , 1 ) b := absf32 ( factor ) sig0 := sigmoid ( a , b , 0 ) sig1 := sigmoid ( a , b , 1 ) e := float32 ( 1.0e-5 ) return & colorchanFilter { fn : func ( x float32 ) float32 { if factor == 0 { return x } else if factor > 0 { sig := sigmoid ( a , b , x ) return ( sig - sig0 ) / ( sig1 - sig0 ) } else { arg := minf32 ( maxf32 ( ( sig1 - sig0 ) * x + sig0 , e ) , 1 - e ) return a - logf32 ( 1 / arg - 1 ) / b } } , lut : true , } }
Sigmoid creates a filter that changes the contrast of an image using a sigmoidal function and returns the adjusted image.
Sigmoid creates a filter that changes the contrast of an image using a sigmoidal function and returns the adjusted image .