redo im_Lab2XYZ() as a class
This commit is contained in:
parent
5af7d75180
commit
a38fa9302e
@ -1,5 +1,5 @@
|
||||
31/8/12 started 7.31.0
|
||||
- work on moving colour to vips8
|
||||
- redone im_Lab2XYZ() as a class
|
||||
|
||||
13/9/12 started 7.30.3
|
||||
- linecache sized itself too large
|
||||
|
14
TODO
14
TODO
@ -1,3 +1,15 @@
|
||||
- can we make DOUBLE ARRAY args easier from C?
|
||||
|
||||
at the moment they are horrible or ad-hoc, see vips_linear() etc. and
|
||||
the im_Lab2XYZ_temp() wrapper
|
||||
|
||||
can the thing that collects args from the stack spot array objects? eg.
|
||||
|
||||
double fred[3];
|
||||
|
||||
vips_Lab2XYZ( in, out, "temp", fred, 3, NULL );
|
||||
|
||||
|
||||
colour
|
||||
|
||||
colour operations:
|
||||
@ -58,6 +70,8 @@ how about a base colour class with 1 in, 1 out,
|
||||
pass extra bands through though
|
||||
|
||||
|
||||
- CMC(l:c) needs optional args for l and c
|
||||
|
||||
|
||||
|
||||
|
||||
|
247
libvips/colour/Lab2XYZ.c
Normal file
247
libvips/colour/Lab2XYZ.c
Normal file
@ -0,0 +1,247 @@
|
||||
/* Lab to XYZ.
|
||||
*
|
||||
* Modified:
|
||||
* 15/11/94 JC
|
||||
* - ANSIfied
|
||||
* - sets Type of output
|
||||
* - better error messages
|
||||
* 16/11/94 JC
|
||||
* - partialed
|
||||
* - in-line conversion
|
||||
* 8/2/95 JC
|
||||
* - new im_wrapone function
|
||||
* 2/11/09
|
||||
* - gtkdoc
|
||||
* - cleanups
|
||||
* 18/9/12
|
||||
* - redone as a class
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
#define VIPS_DEBUG
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/debug.h>
|
||||
|
||||
#include "colour.h"
|
||||
|
||||
typedef struct _VipsLab2XYZ {
|
||||
VipsColorimetric parent_instance;
|
||||
|
||||
/* The colour temperature -- default to D65.
|
||||
*/
|
||||
VipsArea *temp;
|
||||
|
||||
/* Broken out as xyz.
|
||||
*/
|
||||
double X0;
|
||||
double Y0;
|
||||
double Z0;
|
||||
|
||||
} VipsLab2XYZ;
|
||||
|
||||
typedef VipsColorimetricClass VipsLab2XYZClass;
|
||||
|
||||
G_DEFINE_TYPE( VipsLab2XYZ, vips_Lab2XYZ, VIPS_TYPE_COLORIMETRIC );
|
||||
|
||||
/* Process a buffer of data.
|
||||
*/
|
||||
static void
|
||||
vips_Lab2XYZ_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
|
||||
{
|
||||
VipsLab2XYZ *Lab2XYZ = (VipsLab2XYZ *) colour;
|
||||
float *p = (float *) in[0];
|
||||
float *q = (float *) out;
|
||||
|
||||
int x;
|
||||
|
||||
VIPS_DEBUG_MSG( "vips_Lab2XYZ_line: X0 = %g, Y0 = %g, Z0 = %g\n",
|
||||
Lab2XYZ->X0, Lab2XYZ->Y0, Lab2XYZ->Z0 );
|
||||
|
||||
for( x = 0; x < width; x++ ) {
|
||||
float L, a, b;
|
||||
float X, Y, Z;
|
||||
double cby, tmp;
|
||||
|
||||
L = p[0];
|
||||
a = p[1];
|
||||
b = p[2];
|
||||
p += 3;
|
||||
|
||||
if( L < 8.0 ) {
|
||||
Y = (L * Lab2XYZ->Y0) / 903.3;
|
||||
cby = 7.787 * (Y / Lab2XYZ->Y0) + 16.0 / 116.0;
|
||||
}
|
||||
else {
|
||||
cby = (L + 16.0) / 116.0;
|
||||
Y = Lab2XYZ->Y0 * cby * cby * cby;
|
||||
}
|
||||
|
||||
tmp = a / 500.0 + cby;
|
||||
if( tmp < 0.2069 )
|
||||
X = Lab2XYZ->X0 * (tmp - 0.13793) / 7.787;
|
||||
else
|
||||
X = Lab2XYZ->X0 * tmp * tmp * tmp;
|
||||
|
||||
tmp = cby - b / 200.0;
|
||||
if( tmp < 0.2069 )
|
||||
Z = Lab2XYZ->Z0 * (tmp - 0.13793) / 7.787;
|
||||
else
|
||||
Z = Lab2XYZ->Z0 * tmp * tmp * tmp;
|
||||
|
||||
/* Write.
|
||||
*/
|
||||
q[0] = X;
|
||||
q[1] = Y;
|
||||
q[2] = Z;
|
||||
q += 3;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
vips_Lab2XYZ_build( VipsObject *object )
|
||||
{
|
||||
VipsLab2XYZ *Lab2XYZ = (VipsLab2XYZ *) object;
|
||||
|
||||
if( Lab2XYZ->temp ) {
|
||||
if( vips_check_vector_length( "VipsLab2XYZ",
|
||||
Lab2XYZ->temp->n, 3 ) )
|
||||
return( -1 );
|
||||
Lab2XYZ->X0 = ((double *) Lab2XYZ->temp->data)[0];
|
||||
Lab2XYZ->Y0 = ((double *) Lab2XYZ->temp->data)[1];
|
||||
Lab2XYZ->Z0 = ((double *) Lab2XYZ->temp->data)[2];
|
||||
}
|
||||
|
||||
if( VIPS_OBJECT_CLASS( vips_Lab2XYZ_parent_class )->build( object ) )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_Lab2XYZ_class_init( VipsLab2XYZClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsColourClass *colour_class = VIPS_COLOUR_CLASS( class );
|
||||
|
||||
gobject_class->set_property = vips_object_set_property;
|
||||
gobject_class->get_property = vips_object_get_property;
|
||||
|
||||
object_class->nickname = "Lab2XYZ";
|
||||
object_class->description = _( "transform CIELAB to XYZ" );
|
||||
object_class->build = vips_Lab2XYZ_build;
|
||||
|
||||
colour_class->process_line = vips_Lab2XYZ_line;
|
||||
|
||||
VIPS_ARG_BOXED( class, "temp", 110,
|
||||
_( "Temperature" ),
|
||||
_( "Colour temperature" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsLab2XYZ, temp ),
|
||||
VIPS_TYPE_ARRAY_DOUBLE );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_Lab2XYZ_init( VipsLab2XYZ *Lab2XYZ )
|
||||
{
|
||||
Lab2XYZ->X0 = VIPS_D65_X0;
|
||||
Lab2XYZ->Y0 = VIPS_D65_Y0;
|
||||
Lab2XYZ->Z0 = VIPS_D65_Z0;
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_Lab2XYZ:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
*
|
||||
* optional arguments:
|
||||
*
|
||||
* @temp: colour temperature
|
||||
*
|
||||
* Turn Lab to XYZ.
|
||||
*
|
||||
* The colour temperature defaults to D65, but can be specified with @temp.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int
|
||||
vips_Lab2XYZ( VipsImage *in, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "Lab2XYZ", ap, in, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_col_Lab2XYZ:
|
||||
* @L: Input CIE Lab value
|
||||
* @a: Input CIE Lab value
|
||||
* @b: Input CIE Lab value
|
||||
* @X: Return CIE XYZ colour
|
||||
* @Y: Return CIE XYZ colour
|
||||
* @Z: Return CIE XYZ colour
|
||||
*
|
||||
* Calculate XYZ from Lab, D65.
|
||||
*
|
||||
* See also: vips_Lab2XYZ().
|
||||
*/
|
||||
void
|
||||
vips_col_Lab2XYZ( float L, float a, float b, float *X, float *Y, float *Z )
|
||||
{
|
||||
float in[3], out[3];
|
||||
VipsLab2XYZ Lab2XYZ;
|
||||
|
||||
in[0] = L;
|
||||
in[1] = a;
|
||||
in[2] = b;
|
||||
Lab2XYZ.X0 = IM_D65_X0;
|
||||
Lab2XYZ.Y0 = IM_D65_Y0;
|
||||
Lab2XYZ.Z0 = IM_D65_Z0;
|
||||
vips_Lab2XYZ_line( (VipsColour *) &Lab2XYZ,
|
||||
(VipsPel *) out, (VipsPel **) &in, 1 );
|
||||
*X = out[0];
|
||||
*Y = out[1];
|
||||
*Z = out[2];
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ libcolour_la_SOURCES = \
|
||||
disp.c \
|
||||
colour_dispatch.c \
|
||||
derived.c \
|
||||
Lab2XYZ.c \
|
||||
im_icc_transform.c \
|
||||
im_LCh2Lab.c \
|
||||
im_LCh2UCS.c \
|
||||
im_Lab2LCh.c \
|
||||
im_Lab2LabQ.c \
|
||||
im_Lab2LabS.c \
|
||||
im_Lab2XYZ.c \
|
||||
im_LabQ2Lab.c \
|
||||
im_LabQ2LabS.c \
|
||||
im_LabQ2disp.c \
|
||||
|
@ -128,6 +128,7 @@ vips_colour_class_init( VipsColourClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class );
|
||||
VipsOperationClass *operation_class = VIPS_OPERATION_CLASS( class );
|
||||
|
||||
gobject_class->set_property = vips_object_set_property;
|
||||
gobject_class->get_property = vips_object_get_property;
|
||||
@ -136,6 +137,8 @@ vips_colour_class_init( VipsColourClass *class )
|
||||
vobject_class->description = _( "colour operations" );
|
||||
vobject_class->build = vips_colour_build;
|
||||
|
||||
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
|
||||
|
||||
VIPS_ARG_IMAGE( class, "out", 100,
|
||||
_( "Output" ),
|
||||
_( "Output image" ),
|
||||
@ -158,7 +161,7 @@ vips_colorimetric_build( VipsObject *object )
|
||||
|
||||
VipsImage **t;
|
||||
|
||||
t = (VipsImage **) vips_object_local_array( object, 1 );
|
||||
t = (VipsImage **) vips_object_local_array( object, 4 );
|
||||
|
||||
colour->n = 1;
|
||||
colour->in = (VipsImage **) vips_object_local_array( object, 1 );
|
||||
@ -178,7 +181,7 @@ vips_colorimetric_build( VipsObject *object )
|
||||
"n", t[0]->Bands - 3, NULL ) )
|
||||
return( -1 );
|
||||
|
||||
colour->in[0] = t[2];
|
||||
colour->in[0] = t[1];
|
||||
}
|
||||
|
||||
if( colour->in[0] )
|
||||
@ -190,10 +193,17 @@ vips_colorimetric_build( VipsObject *object )
|
||||
|
||||
/* Reattach higher bands, if necessary.
|
||||
*/
|
||||
if( t[0]->Bands > 3 )
|
||||
if( vips_bandjoin2( colour->out, t[2], &colour->out, NULL ) )
|
||||
if( t[0]->Bands > 3 ) {
|
||||
VipsImage *x;
|
||||
|
||||
if( vips_bandjoin2( colour->out, t[2], &x, NULL ) )
|
||||
return( -1 );
|
||||
|
||||
VIPS_UNREF( colour->out );
|
||||
|
||||
colour->out = x;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
@ -228,7 +238,7 @@ vips_colorimetric_init( VipsColorimetric *colorimetric )
|
||||
void
|
||||
vips_colour_operation_init( void )
|
||||
{
|
||||
extern GType vips_add_get_type( void );
|
||||
extern GType vips_Lab2XYZ_get_type( void );
|
||||
|
||||
vips_add_get_type();
|
||||
vips_Lab2XYZ_get_type();
|
||||
}
|
||||
|
@ -150,37 +150,6 @@ im_col_XYZ2Lab( float X, float Y, float Z, float *L, float *a, float *b )
|
||||
*b = out[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* im_col_Lab2XYZ:
|
||||
* @L: Input CIE Lab value
|
||||
* @a: Input CIE Lab value
|
||||
* @b: Input CIE Lab value
|
||||
* @X: Return CIE XYZ colour
|
||||
* @Y: Return CIE XYZ colour
|
||||
* @Z: Return CIE XYZ colour
|
||||
*
|
||||
* Calculate XYZ from Lab, D65.
|
||||
*
|
||||
* See also: im_Lab2XYZ_temp().
|
||||
*/
|
||||
void
|
||||
im_col_Lab2XYZ( float L, float a, float b, float *X, float *Y, float *Z )
|
||||
{
|
||||
float in[3], out[3];
|
||||
im_colour_temperature temp;
|
||||
|
||||
in[0] = L;
|
||||
in[1] = a;
|
||||
in[2] = b;
|
||||
temp.X0 = IM_D65_X0;
|
||||
temp.Y0 = IM_D65_Y0;
|
||||
temp.Z0 = IM_D65_Z0;
|
||||
imb_Lab2XYZ( in, out, 1, &temp );
|
||||
*X = out[0];
|
||||
*Y = out[1];
|
||||
*Z = out[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* im_col_pythagoras:
|
||||
* @L1: Input coordinate 1
|
||||
@ -895,19 +864,6 @@ vips_UCS2XYZ( VipsImage *in, VipsImage **out, ... )
|
||||
return( result );
|
||||
}
|
||||
|
||||
int
|
||||
vips_Lab2XYZ( VipsImage *in, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "im_Lab2XYZ", ap, in, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
int
|
||||
vips_XYZ2disp( VipsImage *in, VipsImage **out,
|
||||
struct im_col_display *disp, ... )
|
||||
|
@ -1,142 +0,0 @@
|
||||
/* Lab to XYZ.
|
||||
*
|
||||
* Modified:
|
||||
* 15/11/94 JC
|
||||
* - ANSIfied
|
||||
* - sets Type of output
|
||||
* - better error messages
|
||||
* 16/11/94 JC
|
||||
* - partialed
|
||||
* - in-line conversion
|
||||
* 8/2/95 JC
|
||||
* - new im_wrapone function
|
||||
* 2/11/09
|
||||
* - gtkdoc
|
||||
* - cleanups
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
|
||||
/* Process a buffer of data.
|
||||
*/
|
||||
void
|
||||
imb_Lab2XYZ( float *p, float *q, int n, im_colour_temperature *temp )
|
||||
{
|
||||
int x;
|
||||
|
||||
for( x = 0; x < n; x++ ) {
|
||||
float L, a, b;
|
||||
float X, Y, Z;
|
||||
double cby, tmp;
|
||||
|
||||
L = p[0];
|
||||
a = p[1];
|
||||
b = p[2];
|
||||
p += 3;
|
||||
|
||||
if( L < 8.0 ) {
|
||||
Y = (L * temp->Y0) / 903.3;
|
||||
cby = 7.787 * (Y / temp->Y0) + 16.0 / 116.0;
|
||||
}
|
||||
else {
|
||||
cby = (L + 16.0) / 116.0;
|
||||
Y = temp->Y0 * cby * cby * cby;
|
||||
}
|
||||
|
||||
tmp = a / 500.0 + cby;
|
||||
if( tmp < 0.2069 )
|
||||
X = temp->X0 * (tmp - 0.13793) / 7.787;
|
||||
else
|
||||
X = temp->X0 * tmp * tmp * tmp;
|
||||
|
||||
tmp = cby - b / 200.0;
|
||||
if( tmp < 0.2069 )
|
||||
Z = temp->Z0 * (tmp - 0.13793) / 7.787;
|
||||
else
|
||||
Z = temp->Z0 * tmp * tmp * tmp;
|
||||
|
||||
/* Write.
|
||||
*/
|
||||
q[0] = X;
|
||||
q[1] = Y;
|
||||
q[2] = Z;
|
||||
q += 3;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* im_Lab2XYZ_temp:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
* @X0: colour temperature
|
||||
* @Y0: colour temperature
|
||||
* @Z0: colour temperature
|
||||
*
|
||||
* Turn Lab to XYZ. @X0, @y0, @Z0 give the Lab colour temperature.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
im_Lab2XYZ_temp( IMAGE *in, IMAGE *out, double X0, double Y0, double Z0 )
|
||||
{
|
||||
im_colour_temperature *temp;
|
||||
|
||||
if( !(temp = IM_NEW( out, im_colour_temperature )) )
|
||||
return( -1 );
|
||||
temp->X0 = X0;
|
||||
temp->Y0 = Y0;
|
||||
temp->Z0 = Z0;
|
||||
|
||||
return( im__colour_unary( "im_Lab2XYZ_temp", in, out, IM_TYPE_XYZ,
|
||||
(im_wrapone_fn) imb_Lab2XYZ, temp, NULL ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* im_Lab2XYZ:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
*
|
||||
* Turn D65 Lab to XYZ.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
im_Lab2XYZ( IMAGE *in, IMAGE *out )
|
||||
{
|
||||
return( im_Lab2XYZ_temp( in, out, IM_D65_X0, IM_D65_Y0, IM_D65_Z0 ) );
|
||||
}
|
@ -705,4 +705,3 @@ im_flood_other( IMAGE *test, IMAGE *mark,
|
||||
{
|
||||
return( im_draw_flood_other( mark, test, x, y, serial, dout ) );
|
||||
}
|
||||
|
||||
|
@ -2143,3 +2143,45 @@ im_rightshift_size( IMAGE *in, IMAGE *out,
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
im_Lab2XYZ_temp( IMAGE *in, IMAGE *out, double X0, double Y0, double Z0 )
|
||||
{
|
||||
double ary[3];
|
||||
VipsArea *temp;
|
||||
VipsImage *x;
|
||||
|
||||
ary[0] = X0;
|
||||
ary[1] = Y0;
|
||||
ary[2] = Z0;
|
||||
temp = (VipsArea *) vips_array_double_new( ary, 3 );
|
||||
if( vips_Lab2XYZ( in, &x, "temp", temp, NULL ) ) {
|
||||
vips_area_unref( temp );
|
||||
return( -1 );
|
||||
}
|
||||
vips_area_unref( temp );
|
||||
|
||||
if( im_copy( x, out ) ) {
|
||||
g_object_unref( x );
|
||||
return( -1 );
|
||||
}
|
||||
g_object_unref( x );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
im_Lab2XYZ( IMAGE *in, IMAGE *out )
|
||||
{
|
||||
VipsImage *x;
|
||||
|
||||
if( vips_Lab2XYZ( in, &x, NULL ) )
|
||||
return( -1 );
|
||||
if( im_copy( x, out ) ) {
|
||||
g_object_unref( x );
|
||||
return( -1 );
|
||||
}
|
||||
g_object_unref( x );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -35,13 +35,63 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifndef IM_COLOUR_H
|
||||
#define IM_COLOUR_H
|
||||
#ifndef VIPS_COLOUR_H
|
||||
#define VIPS_COLOUR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/* Areas under curves for Dxx. 2 degree observer.
|
||||
*/
|
||||
#define VIPS_D93_X0 (89.7400)
|
||||
#define VIPS_D93_Y0 (100.0)
|
||||
#define VIPS_D93_Z0 (130.7700)
|
||||
|
||||
#define VIPS_D75_X0 (94.9682)
|
||||
#define VIPS_D75_Y0 (100.0)
|
||||
#define VIPS_D75_Z0 (122.5710)
|
||||
|
||||
/* D65 temp 6504.
|
||||
*/
|
||||
#define VIPS_D65_X0 (95.0470)
|
||||
#define VIPS_D65_Y0 (100.0)
|
||||
#define VIPS_D65_Z0 (108.8827)
|
||||
|
||||
#define VIPS_D55_X0 (95.6831)
|
||||
#define VIPS_D55_Y0 (100.0)
|
||||
#define VIPS_D55_Z0 (92.0871)
|
||||
|
||||
#define VIPS_D50_X0 (96.4250)
|
||||
#define VIPS_D50_Y0 (100.0)
|
||||
#define VIPS_D50_Z0 (82.4680)
|
||||
|
||||
/* A temp 2856k.
|
||||
*/
|
||||
#define VIPS_A_X0 (109.8503)
|
||||
#define VIPS_A_Y0 (100.0)
|
||||
#define VIPS_A_Z0 (35.5849)
|
||||
|
||||
/* B temp 4874k.
|
||||
*/
|
||||
#define VIPS_B_X0 (99.0720)
|
||||
#define VIPS_B_Y0 (100.0)
|
||||
#define VIPS_B_Z0 (85.2230)
|
||||
|
||||
/* C temp 6774k.
|
||||
*/
|
||||
#define VIPS_C_X0 (98.0700)
|
||||
#define VIPS_C_Y0 (100.0)
|
||||
#define VIPS_C_Z0 (118.2300)
|
||||
|
||||
#define VIPS_E_X0 (100.0)
|
||||
#define VIPS_E_Y0 (100.0)
|
||||
#define VIPS_E_Z0 (100.0)
|
||||
|
||||
#define VIPS_D3250_X0 (105.6590)
|
||||
#define VIPS_D3250_Y0 (100.0)
|
||||
#define VIPS_D3250_Z0 (45.8501)
|
||||
|
||||
struct im_col_display;
|
||||
|
||||
int vips_LabQ2disp( VipsImage *in, VipsImage **out,
|
||||
@ -69,62 +119,19 @@ int vips_XYZ2disp( VipsImage *in, VipsImage **out,
|
||||
struct im_col_display *disp, ... )
|
||||
__attribute__((sentinel));
|
||||
|
||||
/* Areas under curves for Dxx. 2 degree observer.
|
||||
*/
|
||||
#define IM_D93_X0 (89.7400)
|
||||
#define IM_D93_Y0 (100.0)
|
||||
#define IM_D93_Z0 (130.7700)
|
||||
void vips_col_Lab2XYZ( float L, float a, float b,
|
||||
float *X, float *Y, float *Z );
|
||||
|
||||
#define IM_D75_X0 (94.9682)
|
||||
#define IM_D75_Y0 (100.0)
|
||||
#define IM_D75_Z0 (122.5710)
|
||||
|
||||
/* D65 temp 6504.
|
||||
*/
|
||||
#define IM_D65_X0 (95.0470)
|
||||
#define IM_D65_Y0 (100.0)
|
||||
#define IM_D65_Z0 (108.8827)
|
||||
|
||||
#define IM_D55_X0 (95.6831)
|
||||
#define IM_D55_Y0 (100.0)
|
||||
#define IM_D55_Z0 (92.0871)
|
||||
|
||||
#define IM_D50_X0 (96.4250)
|
||||
#define IM_D50_Y0 (100.0)
|
||||
#define IM_D50_Z0 (82.4680)
|
||||
|
||||
/* A temp 2856k.
|
||||
*/
|
||||
#define IM_A_X0 (109.8503)
|
||||
#define IM_A_Y0 (100.0)
|
||||
#define IM_A_Z0 (35.5849)
|
||||
|
||||
/* B temp 4874k.
|
||||
*/
|
||||
#define IM_B_X0 (99.0720)
|
||||
#define IM_B_Y0 (100.0)
|
||||
#define IM_B_Z0 (85.2230)
|
||||
|
||||
/* C temp 6774k.
|
||||
*/
|
||||
#define IM_C_X0 (98.0700)
|
||||
#define IM_C_Y0 (100.0)
|
||||
#define IM_C_Z0 (118.2300)
|
||||
|
||||
#define IM_E_X0 (100.0)
|
||||
#define IM_E_Y0 (100.0)
|
||||
#define IM_E_Z0 (100.0)
|
||||
|
||||
#define IM_D3250_X0 (105.6590)
|
||||
#define IM_D3250_Y0 (100.0)
|
||||
#define IM_D3250_Z0 (45.8501)
|
||||
|
||||
/* Colour loading and conversion functions.
|
||||
*/
|
||||
void im_col_ab2Ch( float a, float b, float *C, float *h );
|
||||
void im_col_Ch2ab( float C, float h, float *a, float *b );
|
||||
void im_col_XYZ2Lab( float X, float Y, float Z, float *L, float *a, float *b );
|
||||
void im_col_Lab2XYZ( float L, float a, float b, float *X, float *Y, float *Z );
|
||||
float im_col_pythagoras( float L1, float a1, float b1,
|
||||
float L2, float a2, float b2 );
|
||||
|
||||
@ -151,9 +158,6 @@ int im_LCh2UCS( VipsImage *in, VipsImage *out );
|
||||
int im_Lab2LCh( VipsImage *in, VipsImage *out );
|
||||
int im_Lab2LabQ( VipsImage *in, VipsImage *out );
|
||||
int im_Lab2LabS( VipsImage *in, VipsImage *out );
|
||||
int im_Lab2XYZ( VipsImage *in, VipsImage *out );
|
||||
int im_Lab2XYZ_temp( VipsImage *in, VipsImage *out,
|
||||
double X0, double Y0, double Z0 );
|
||||
int im_Lab2UCS( VipsImage *in, VipsImage *out );
|
||||
int im_LabQ2Lab( VipsImage *in, VipsImage *out );
|
||||
int im_LabQ2LabS( VipsImage *in, VipsImage *out );
|
||||
@ -206,4 +210,4 @@ int im_icc_ac2rc( VipsImage *in, VipsImage *out, const char *profile_filename );
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif /*IM_COLOUR_H*/
|
||||
#endif /*VIPS_COLOUR_H*/
|
||||
|
@ -80,6 +80,7 @@ int vips_check_8or16( const char *domain, VipsImage *im );
|
||||
int vips_check_u8or16orf( const char *domain, VipsImage *im );
|
||||
int vips_check_format_same( const char *domain, VipsImage *im1, VipsImage *im2 );
|
||||
int vips_check_size_same( const char *domain, VipsImage *im1, VipsImage *im2 );
|
||||
int vips_check_vector_length( const char *domain, int n, int len );
|
||||
int vips_check_vector( const char *domain, int n, VipsImage *im );
|
||||
int vips_check_hist( const char *domain, VipsImage *im );
|
||||
int vips_check_imask( const char *domain, INTMASK *mask );
|
||||
|
@ -40,6 +40,48 @@ extern "C" {
|
||||
/* Renamed types.
|
||||
*/
|
||||
|
||||
#define IM_D93_X0 VIPS_D93_X0
|
||||
#define IM_D93_Y0 VIPS_D93_Y0
|
||||
#define IM_D93_Z0 VIPS_D93_Z0
|
||||
|
||||
#define IM_D75_X0 VIPS_D75_X0
|
||||
#define IM_D75_Y0 VIPS_D75_Y0
|
||||
#define IM_D75_Z0 VIPS_D75_Z0
|
||||
|
||||
#define IM_D65_X0 VIPS_D65_X0
|
||||
#define IM_D65_Y0 VIPS_D65_Y0
|
||||
#define IM_D65_Z0 VIPS_D65_Z0
|
||||
|
||||
#define IM_D55_X0 VIPS_D55_X0
|
||||
#define IM_D55_Y0 VIPS_D55_Y0
|
||||
#define IM_D55_Z0 VIPS_D55_Z0
|
||||
|
||||
#define IM_D50_X0 VIPS_D50_X0
|
||||
#define IM_D50_Y0 VIPS_D50_Y0
|
||||
#define IM_D50_Z0 VIPS_D50_Z0
|
||||
|
||||
#define IM_A_X0 VIPS_A_X0
|
||||
#define IM_A_Y0 VIPS_A_Y0
|
||||
#define IM_A_Z0 VIPS_A_Z0
|
||||
|
||||
#define IM_B_X0 VIPS_B_X0
|
||||
#define IM_B_Y0 VIPS_B_Y0
|
||||
#define IM_B_Z0 VIPS_B_Z0
|
||||
|
||||
#define IM_C_X0 VIPS_C_X0
|
||||
#define IM_C_Y0 VIPS_C_Y0
|
||||
#define IM_C_Z0 VIPS_C_Z0
|
||||
|
||||
#define IM_E_X0 VIPS_E_X0
|
||||
#define IM_E_Y0 VIPS_E_Y0
|
||||
#define IM_E_Z0 VIPS_E_Z0
|
||||
|
||||
#define IM_D3250_X0 VIPS_D3250_X0
|
||||
#define IM_D3250_Y0 VIPS_D3250_Y0
|
||||
#define IM_D3250_Z0 VIPS_D3250_Z0
|
||||
|
||||
#define im_col_Lab2XYZ vips_col_Lab2XYZ
|
||||
|
||||
#define PEL VipsPel
|
||||
|
||||
#define IM_BANDFMT_NOTSET VIPS_FORMAT_NOTSET
|
||||
@ -652,6 +694,9 @@ int im_argb2rgba( VipsImage *in, VipsImage *out );
|
||||
|
||||
int im_shrink( VipsImage *in, VipsImage *out, double xshrink, double yshrink );
|
||||
|
||||
int im_Lab2XYZ_temp( IMAGE *in, IMAGE *out, double X0, double Y0, double Z0 );
|
||||
int im_Lab2XYZ( IMAGE *in, IMAGE *out );
|
||||
|
||||
/* ruby-vips uses this
|
||||
*/
|
||||
#define vips_class_map_concrete_all vips_class_map_all
|
||||
|
@ -1085,6 +1085,29 @@ vips_check_coding_same( const char *domain, VipsImage *im1, VipsImage *im2 )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_check_vector_length:
|
||||
* @domain: the originating domain for the error message
|
||||
* @n: number of elements in vector
|
||||
* @len: number of elements vector should have
|
||||
*
|
||||
* Check that @n == @len.
|
||||
*
|
||||
* See also: vips_error().
|
||||
*
|
||||
* Returns: 0 if OK, -1 otherwise.
|
||||
*/
|
||||
int
|
||||
vips_check_vector_length( const char *domain, int n, int len )
|
||||
{
|
||||
if( n != len ) {
|
||||
vips_error( domain, _( "vector must have %d elements" ), len );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_check_vector:
|
||||
* @domain: the originating domain for the error message
|
||||
|
@ -241,6 +241,7 @@ vips_init( const char *argv0 )
|
||||
vips_conversion_operation_init();
|
||||
vips_foreign_operation_init();
|
||||
vips_resample_operation_init();
|
||||
vips_colour_operation_init();
|
||||
|
||||
/* Load up any plugins in the vips libdir. We don't error on failure,
|
||||
* it's too annoying to have VIPS refuse to start because of a broken
|
||||
|
Loading…
Reference in New Issue
Block a user