Merge pull request #1728 from lovell/lch-prefer-atan-over-atan2

Performance: improve LAB to LCH conversion by ~30%
This commit is contained in:
John Cupitt 2020-07-20 13:31:07 +01:00 committed by GitHub
commit 8eefe9f4fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,11 +63,6 @@ vips_col_ab2h( double a, double b )
{
double h;
#ifdef HAVE_ATAN2
h = VIPS_DEG( atan2( b, a ) );
if( h < 0.0 )
h += 360;
#else
/* We have to get the right quadrant!
*/
if( a == 0 ) {
@ -89,7 +84,6 @@ vips_col_ab2h( double a, double b )
else
h = VIPS_DEG( t + VIPS_PI );
}
#endif
return( h );
}
@ -97,13 +91,7 @@ vips_col_ab2h( double a, double b )
void
vips_col_ab2Ch( float a, float b, float *C, float *h )
{
#ifdef HAVE_ATAN2
*h = VIPS_DEG( atan2( b, a ) );
if( *h < 0.0 )
*h += 360;
#else
*h = vips_col_ab2h( a, b );
#endif
#ifdef HAVE_HYPOT
*C = hypot( a, b );