rename UCS as CMC

This commit is contained in:
John Cupitt 2012-11-01 10:21:55 +00:00
parent 63a06e5f81
commit f5790be152
13 changed files with 147 additions and 195 deletions

View File

@ -8,6 +8,7 @@
as classes
- added vips_colour_convert(), replaces all derived conversions
- faster and more accurate sRGB <-> XYZ conversion
- rename UCS colourspace as CMC
- dzsave can write zoomify and google maps layout as well
- tilecache supports threaded access
- openslide2vips gets underlying tile size from openslide

2
TODO
View File

@ -3,8 +3,6 @@
- add mono as a colourspace? also rad?
- rename INTERPRETATION_UCS to _CMC
- something to test if an image is in a supported colourspace?
at the moment we only look at interpretation, but for things like labq

View File

@ -1,4 +1,4 @@
/* im_LCh2UCS
/* im_LCh2CMC
*
* Modified:
* 2/11/09
@ -45,67 +45,67 @@
#include "colour.h"
typedef VipsColourSpace VipsLCh2UCS;
typedef VipsColourSpaceClass VipsLCh2UCSClass;
typedef VipsColourSpace VipsLCh2CMC;
typedef VipsColourSpaceClass VipsLCh2CMCClass;
G_DEFINE_TYPE( VipsLCh2UCS, vips_LCh2UCS, VIPS_TYPE_COLOUR_SPACE );
G_DEFINE_TYPE( VipsLCh2CMC, vips_LCh2CMC, VIPS_TYPE_COLOUR_SPACE );
/**
* vips_col_L2Lucs:
* vips_col_L2Lcmc:
* @L: CIE L*
*
* Calculate Lucs from L.
* Calculate Lcmc from L.
*
* Returns: Lucs
* Returns: Lcmc
*/
float
vips_col_L2Lucs( float L )
vips_col_L2Lcmc( float L )
{
float Lucs;
float Lcmc;
if( L >= 16.0 )
Lucs = (21.75 * log( L ) + 0.3838 * L - 38.54);
Lcmc = (21.75 * log( L ) + 0.3838 * L - 38.54);
else
Lucs = 1.744 * L;
Lcmc = 1.744 * L;
return( Lucs );
return( Lcmc );
}
/**
* vips_col_C2Cucs:
* vips_col_C2Ccmc:
* @C: Chroma
*
* Calculate Cucs from C.
* Calculate Ccmc from C.
*
* Returns: Cucs.
* Returns: Ccmc.
*/
float
vips_col_C2Cucs( float C )
vips_col_C2Ccmc( float C )
{
float Cucs;
float Ccmc;
Cucs = 0.162 * C + 10.92 * log( 0.638 + 0.07216 * C ) + 4.907;
if( Cucs < 0 )
Cucs = 0;
Ccmc = 0.162 * C + 10.92 * log( 0.638 + 0.07216 * C ) + 4.907;
if( Ccmc < 0 )
Ccmc = 0;
return( Cucs );
return( Ccmc );
}
/**
* vips_col_Ch2hucs:
* vips_col_Ch2hcmc:
* @C: Chroma
* @h: Hue (degrees)
*
* Calculate hucs from C and h.
* Calculate hcmc from C and h.
*
* Returns: hucs.
* Returns: hcmc.
*/
float
vips_col_Ch2hucs( float C, float h )
vips_col_Ch2hcmc( float C, float h )
{
float P, D, f, g;
float k4, k5, k6, k7, k8;
float hucs;
float hcmc;
if( h < 49.1 ) {
k4 = 133.87;
@ -140,13 +140,13 @@ vips_col_Ch2hucs( float C, float h )
D = k4 + k5 * P * pow( fabs( P ), k6 );
g = C * C * C * C;
f = sqrt( g / (g + 1900.0) );
hucs = h + D * f;
hcmc = h + D * f;
return( hucs );
return( hcmc );
}
static void
vips_LCh2UCS_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
vips_LCh2CMC_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
{
float *p = (float *) in[0];
float *q = (float *) out;
@ -160,51 +160,51 @@ vips_LCh2UCS_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
p += 3;
q[0] = vips_col_L2Lucs( L );
q[1] = vips_col_C2Cucs( C );
q[2] = vips_col_Ch2hucs( C, h );
q[0] = vips_col_L2Lcmc( L );
q[1] = vips_col_C2Ccmc( C );
q[2] = vips_col_Ch2hcmc( C, h );
q += 3;
}
}
static void
vips_LCh2UCS_class_init( VipsLCh2UCSClass *class )
vips_LCh2CMC_class_init( VipsLCh2CMCClass *class )
{
VipsObjectClass *object_class = (VipsObjectClass *) class;
VipsColourClass *colour_class = VIPS_COLOUR_CLASS( class );
object_class->nickname = "LCh2UCS";
object_class->description = _( "transform LCh to UCS" );
object_class->nickname = "LCh2CMC";
object_class->description = _( "transform LCh to CMC" );
colour_class->process_line = vips_LCh2UCS_line;
colour_class->process_line = vips_LCh2CMC_line;
}
static void
vips_LCh2UCS_init( VipsLCh2UCS *LCh2UCS )
vips_LCh2CMC_init( VipsLCh2CMC *LCh2CMC )
{
VipsColour *colour = VIPS_COLOUR( LCh2UCS );
VipsColour *colour = VIPS_COLOUR( LCh2CMC );
colour->interpretation = VIPS_INTERPRETATION_UCS;
colour->interpretation = VIPS_INTERPRETATION_CMC;
}
/**
* vips_LCh2UCS:
* vips_LCh2CMC:
* @in: input image
* @out: output image
*
* Turn LCh to UCS.
* Turn LCh to CMC.
*
* Returns: 0 on success, -1 on error
*/
int
vips_LCh2UCS( VipsImage *in, VipsImage **out, ... )
vips_LCh2CMC( VipsImage *in, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_call_split( "LCh2UCS", ap, in, out );
result = vips_call_split( "LCh2CMC", ap, in, out );
va_end( ap );
return( result );

View File

@ -1,4 +1,4 @@
/* Turn UCS to LCh
/* Turn CMC to LCh
*
* 15/11/94 JC
* - error messages added
@ -8,7 +8,7 @@
* 2/11/09
* - gtkdoc
* 30/11/09
* - argh, im_col_make_tables_UCS(); missing, thanks Peter
* - argh, im_col_make_tables_CMC(); missing, thanks Peter
* 19/9/12
* - redone as a class
*/
@ -57,10 +57,10 @@ static float LI[1001];
static float CI[3001];
static float hI[101][361];
typedef VipsColourSpace VipsUCS2LCh;
typedef VipsColourSpaceClass VipsUCS2LChClass;
typedef VipsColourSpace VipsCMC2LCh;
typedef VipsColourSpaceClass VipsCMC2LChClass;
G_DEFINE_TYPE( VipsUCS2LCh, vips_UCS2LCh, VIPS_TYPE_COLOUR_SPACE );
G_DEFINE_TYPE( VipsCMC2LCh, vips_CMC2LCh, VIPS_TYPE_COLOUR_SPACE );
/* Generate LI (inverse) tables.
*/
@ -71,7 +71,7 @@ make_LI( void )
float Ll[1001];
for( i = 0; i < 1001; i++ )
Ll[i] = vips_col_L2Lucs( i / 10.0 );
Ll[i] = vips_col_L2Lcmc( i / 10.0 );
for( i = 0; i < 1001; i++ ) {
int j;
@ -84,7 +84,7 @@ make_LI( void )
}
}
/* Generate Cucs table.
/* Generate Ccmc table.
*/
static void
make_CI( void )
@ -93,7 +93,7 @@ make_CI( void )
float Cl[3001];
for( i = 0; i < 3001; i++ )
Cl[i] = vips_col_C2Cucs( i / 10.0 );
Cl[i] = vips_col_C2Ccmc( i / 10.0 );
for( i = 0; i < 3001; i++ ) {
int j;
@ -105,7 +105,7 @@ make_CI( void )
}
}
/* The difficult one: hucs.
/* The difficult one: hcmc.
*/
static void
make_hI( void )
@ -115,7 +115,7 @@ make_hI( void )
for( i = 0; i < 361; i++ )
for( j = 0; j < 101; j++ )
hl[j][i] = vips_col_Ch2hucs( j * 2.0, i );
hl[j][i] = vips_col_Ch2hcmc( j * 2.0, i );
for( j = 0; j < 101; j++ ) {
for( i = 0; i < 361; i++ ) {
@ -130,61 +130,61 @@ make_hI( void )
}
/**
* vips_col_Lucs2L:
* @Lucs: L ucs
* vips_col_Lcmc2L:
* @Lcmc: L cmc
*
* Calculate L from Lucs using a table. Call vips_col_make_tables_UCS() at
* Calculate L from Lcmc using a table. Call vips_col_make_tables_CMC() at
* least once before using this function.
*
* Returns: L*
*/
float
vips_col_Lucs2L( float Lucs )
vips_col_Lcmc2L( float Lcmc )
{
int known;
known = floor( Lucs * 10.0 );
known = floor( Lcmc * 10.0 );
known = VIPS_CLIP( 0, known, 1000 );
return( LI[known] +
(LI[known + 1] - LI[known]) * (Lucs * 10.0 - known) );
(LI[known + 1] - LI[known]) * (Lcmc * 10.0 - known) );
}
/**
* vips_col_Cucs2C:
* @Cucs: Cucs
* vips_col_Ccmc2C:
* @Ccmc: Ccmc
*
* Calculate C from Cucs using a table.
* Call vips_col_make_tables_UCS() at
* Calculate C from Ccmc using a table.
* Call vips_col_make_tables_CMC() at
* least once before using this function.
*
* Returns: C.
*/
float
vips_col_Cucs2C( float Cucs )
vips_col_Ccmc2C( float Ccmc )
{
int known;
known = floor( Cucs * 10.0 );
known = floor( Ccmc * 10.0 );
known = VIPS_CLIP( 0, known, 3000 );
return( CI[known] +
(CI[known + 1] - CI[known]) * (Cucs * 10.0 - known) );
(CI[known + 1] - CI[known]) * (Ccmc * 10.0 - known) );
}
/**
* vips_col_Chucs2h:
* vips_col_Chcmc2h:
* @C: Chroma
* @hucs: Hue ucs (degrees)
* @hcmc: Hue cmc (degrees)
*
* Calculate h from C and hucs, using a table.
* Call vips_col_make_tables_UCS() at
* Calculate h from C and hcmc, using a table.
* Call vips_col_make_tables_CMC() at
* least once before using this function.
*
* Returns: h.
*/
float
vips_col_Chucs2h( float C, float hucs )
vips_col_Chcmc2h( float C, float hcmc )
{
int r;
int known;
@ -194,11 +194,11 @@ vips_col_Chucs2h( float C, float hucs )
r = (int) ((C + 1.0) / 2.0);
r = VIPS_CLIP( 0, r, 100 );
known = floor( hucs );
known = floor( hcmc );
known = VIPS_CLIP( 0, known, 360 );
return( hI[r][known] +
(hI[r][(known + 1) % 360] - hI[r][known]) * (hucs - known) );
(hI[r][(known + 1) % 360] - hI[r][known]) * (hcmc - known) );
}
static void *
@ -212,12 +212,12 @@ tables_init( void *client )
}
/**
* vips_col_make_tables_UCS:
* vips_col_make_tables_CMC:
*
* Make the lookup tables for ucs.
* Make the lookup tables for cmc.
*/
void
vips_col_make_tables_UCS( void )
vips_col_make_tables_CMC( void )
{
static GOnce once = G_ONCE_INIT;
@ -227,7 +227,7 @@ vips_col_make_tables_UCS( void )
/* Process a buffer of data.
*/
void
vips_UCS2LCh_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
vips_CMC2LCh_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
{
float *p = (float *) in[0];
float *q = (float *) out;
@ -235,15 +235,15 @@ vips_UCS2LCh_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
int x;
for( x = 0; x < width; x++ ) {
float Lucs = p[0];
float Cucs = p[1];
float hucs = p[2];
float Lcmc = p[0];
float Ccmc = p[1];
float hcmc = p[2];
/* Turn from UCS.
/* Turn from CMC.
*/
float C = vips_col_Cucs2C( Cucs );
float h = vips_col_Chucs2h( C, hucs );
float L = vips_col_Lucs2L( Lucs );
float C = vips_col_Ccmc2C( Ccmc );
float h = vips_col_Chcmc2h( C, hcmc );
float L = vips_col_Lcmc2L( Lcmc );
p += 3;
@ -256,43 +256,43 @@ vips_UCS2LCh_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
}
static void
vips_UCS2LCh_class_init( VipsUCS2LChClass *class )
vips_CMC2LCh_class_init( VipsCMC2LChClass *class )
{
VipsObjectClass *object_class = (VipsObjectClass *) class;
VipsColourClass *colour_class = VIPS_COLOUR_CLASS( class );
object_class->nickname = "UCS2LCh";
object_class->description = _( "transform LCh to UCS" );
object_class->nickname = "CMC2LCh";
object_class->description = _( "transform LCh to CMC" );
colour_class->process_line = vips_UCS2LCh_line;
colour_class->process_line = vips_CMC2LCh_line;
}
static void
vips_UCS2LCh_init( VipsUCS2LCh *UCS2LCh )
vips_CMC2LCh_init( VipsCMC2LCh *CMC2LCh )
{
VipsColour *colour = VIPS_COLOUR( UCS2LCh );
VipsColour *colour = VIPS_COLOUR( CMC2LCh );
vips_col_make_tables_UCS();
vips_col_make_tables_CMC();
colour->interpretation = VIPS_INTERPRETATION_LCH;
}
/**
* vips_UCS2LCh:
* vips_CMC2LCh:
* @in: input image
* @out: output image
*
* Turn LCh to UCS.
* Turn LCh to CMC.
*
* Returns: 0 on success, -1 on error
*/
int
vips_UCS2LCh( VipsImage *in, VipsImage **out, ... )
vips_CMC2LCh( VipsImage *in, VipsImage **out, ... )
{
va_list ap;
int result;
va_start( ap, out );
result = vips_call_split( "UCS2LCh", ap, in, out );
result = vips_call_split( "CMC2LCh", ap, in, out );
va_end( ap );
return( result );

View File

@ -611,7 +611,7 @@ typedef struct _VipsColourRoute {
#define LAB VIPS_INTERPRETATION_LAB
#define LABQ VIPS_INTERPRETATION_LABQ
#define LCH VIPS_INTERPRETATION_LCH
#define UCS VIPS_INTERPRETATION_UCS
#define CMC VIPS_INTERPRETATION_CMC
#define LABS VIPS_INTERPRETATION_LABS
#define sRGB VIPS_INTERPRETATION_sRGB
#define YXY VIPS_INTERPRETATION_YXY
@ -622,7 +622,7 @@ static VipsColourRoute vips_colour_routes[] = {
{ XYZ, LAB, { vips_XYZ2Lab, NULL } },
{ XYZ, LABQ, { vips_XYZ2Lab, vips_Lab2LabQ, NULL } },
{ XYZ, LCH, { vips_XYZ2Lab, vips_Lab2LCh, NULL } },
{ XYZ, UCS, { vips_XYZ2Lab, vips_Lab2LCh, vips_LCh2UCS, NULL } },
{ XYZ, CMC, { vips_XYZ2Lab, vips_Lab2LCh, vips_LCh2CMC, NULL } },
{ XYZ, LABS, { vips_XYZ2Lab, vips_Lab2LabS, NULL } },
{ XYZ, sRGB, { vips_XYZ2sRGB, NULL } },
{ XYZ, YXY, { vips_XYZ2Yxy, NULL } },
@ -630,7 +630,7 @@ static VipsColourRoute vips_colour_routes[] = {
{ LAB, XYZ, { vips_Lab2XYZ, NULL } },
{ LAB, LABQ, { vips_Lab2LabQ, NULL } },
{ LAB, LCH, { vips_Lab2LCh, NULL } },
{ LAB, UCS, { vips_Lab2LCh, vips_LCh2UCS, NULL } },
{ LAB, CMC, { vips_Lab2LCh, vips_LCh2CMC, NULL } },
{ LAB, LABS, { vips_Lab2LabS, NULL } },
{ LAB, sRGB, { vips_Lab2XYZ, vips_XYZ2sRGB, NULL } },
{ LAB, YXY, { vips_Lab2XYZ, vips_XYZ2Yxy, NULL } },
@ -638,7 +638,7 @@ static VipsColourRoute vips_colour_routes[] = {
{ LABQ, XYZ, { vips_LabQ2Lab, vips_Lab2XYZ, NULL } },
{ LABQ, LAB, { vips_LabQ2Lab, NULL } },
{ LABQ, LCH, { vips_LabQ2Lab, vips_Lab2LCh, NULL } },
{ LABQ, UCS, { vips_LabQ2Lab, vips_Lab2LCh, vips_LCh2UCS, NULL } },
{ LABQ, CMC, { vips_LabQ2Lab, vips_Lab2LCh, vips_LCh2CMC, NULL } },
{ LABQ, LABS, { vips_LabQ2LabS, NULL } },
{ LABQ, sRGB, { vips_LabQ2sRGB, NULL } },
{ LABQ, YXY, { vips_LabQ2Lab, vips_Lab2XYZ, vips_XYZ2Yxy, NULL } },
@ -646,26 +646,26 @@ static VipsColourRoute vips_colour_routes[] = {
{ LCH, XYZ, { vips_LCh2Lab, vips_Lab2XYZ, NULL } },
{ LCH, LAB, { vips_LCh2Lab, NULL } },
{ LCH, LABQ, { vips_LCh2Lab, vips_Lab2LabQ, NULL } },
{ LCH, UCS, { vips_LCh2UCS, NULL } },
{ LCH, CMC, { vips_LCh2CMC, NULL } },
{ LCH, LABS, { vips_LCh2Lab, vips_Lab2LabS, NULL } },
{ LCH, sRGB, { vips_LCh2Lab, vips_Lab2XYZ, vips_XYZ2sRGB, NULL } },
{ LCH, YXY, { vips_LCh2Lab, vips_Lab2XYZ, vips_XYZ2Yxy, NULL } },
{ UCS, XYZ, { vips_UCS2LCh, vips_LCh2Lab, vips_Lab2XYZ, NULL } },
{ UCS, LAB, { vips_UCS2LCh, vips_LCh2Lab, NULL } },
{ UCS, LABQ, { vips_UCS2LCh, vips_LCh2Lab, vips_Lab2LabQ, NULL } },
{ UCS, LCH, { vips_UCS2LCh, NULL } },
{ UCS, LABS, { vips_UCS2LCh, vips_LCh2Lab, vips_Lab2LabS, NULL } },
{ UCS, sRGB, { vips_UCS2LCh, vips_LCh2Lab, vips_Lab2XYZ,
{ CMC, XYZ, { vips_CMC2LCh, vips_LCh2Lab, vips_Lab2XYZ, NULL } },
{ CMC, LAB, { vips_CMC2LCh, vips_LCh2Lab, NULL } },
{ CMC, LABQ, { vips_CMC2LCh, vips_LCh2Lab, vips_Lab2LabQ, NULL } },
{ CMC, LCH, { vips_CMC2LCh, NULL } },
{ CMC, LABS, { vips_CMC2LCh, vips_LCh2Lab, vips_Lab2LabS, NULL } },
{ CMC, sRGB, { vips_CMC2LCh, vips_LCh2Lab, vips_Lab2XYZ,
vips_XYZ2sRGB, NULL } },
{ UCS, YXY, { vips_UCS2LCh, vips_LCh2Lab, vips_Lab2XYZ,
{ CMC, YXY, { vips_CMC2LCh, vips_LCh2Lab, vips_Lab2XYZ,
vips_XYZ2Yxy, NULL } },
{ LABS, XYZ, { vips_LabS2Lab, vips_Lab2XYZ, NULL } },
{ LABS, LAB, { vips_LabS2Lab, NULL } },
{ LABS, LABQ, { vips_LabS2LabQ, NULL } },
{ LABS, LCH, { vips_LabS2Lab, vips_Lab2LCh, NULL } },
{ LABS, UCS, { vips_LabS2Lab, vips_Lab2LCh, vips_LCh2UCS, NULL } },
{ LABS, CMC, { vips_LabS2Lab, vips_Lab2LCh, vips_LCh2CMC, NULL } },
{ LABS, sRGB, { vips_LabS2Lab, vips_Lab2XYZ, vips_XYZ2sRGB, NULL } },
{ LABS, YXY, { vips_LabS2Lab, vips_Lab2XYZ, vips_XYZ2Yxy, NULL } },
@ -673,8 +673,8 @@ static VipsColourRoute vips_colour_routes[] = {
{ sRGB, LAB, { vips_sRGB2XYZ, vips_XYZ2Lab, NULL } },
{ sRGB, LABQ, { vips_sRGB2XYZ, vips_XYZ2Lab, vips_Lab2LabQ, NULL } },
{ sRGB, LCH, { vips_sRGB2XYZ, vips_XYZ2Lab, vips_Lab2LCh, NULL } },
{ sRGB, UCS, { vips_sRGB2XYZ, vips_XYZ2Lab, vips_Lab2LCh,
vips_LCh2UCS, NULL } },
{ sRGB, CMC, { vips_sRGB2XYZ, vips_XYZ2Lab, vips_Lab2LCh,
vips_LCh2CMC, NULL } },
{ sRGB, LABS, { vips_sRGB2XYZ, vips_XYZ2Lab, vips_Lab2LabS, NULL } },
{ sRGB, YXY, { vips_sRGB2XYZ, vips_XYZ2Yxy, NULL } },
@ -682,8 +682,8 @@ static VipsColourRoute vips_colour_routes[] = {
{ YXY, LAB, { vips_Yxy2XYZ, vips_XYZ2Lab, NULL } },
{ YXY, LABQ, { vips_Yxy2XYZ, vips_XYZ2Lab, vips_Lab2LabQ, NULL } },
{ YXY, LCH, { vips_Yxy2XYZ, vips_XYZ2Lab, vips_Lab2LCh, NULL } },
{ YXY, UCS, { vips_Yxy2XYZ, vips_XYZ2Lab, vips_Lab2LCh,
vips_LCh2UCS, NULL } },
{ YXY, CMC, { vips_Yxy2XYZ, vips_XYZ2Lab, vips_Lab2LCh,
vips_LCh2CMC, NULL } },
{ YXY, LABS, { vips_Yxy2XYZ, vips_XYZ2Lab, vips_Lab2LabS, NULL } },
{ YXY, sRGB, { vips_Yxy2XYZ, vips_XYZ2sRGB, NULL } },
};
@ -828,8 +828,8 @@ vips_colour_operation_init( void )
extern GType vips_XYZ2Lab_get_type( void );
extern GType vips_Lab2LCh_get_type( void );
extern GType vips_LCh2Lab_get_type( void );
extern GType vips_LCh2UCS_get_type( void );
extern GType vips_UCS2LCh_get_type( void );
extern GType vips_LCh2CMC_get_type( void );
extern GType vips_CMC2LCh_get_type( void );
extern GType vips_Yxy2XYZ_get_type( void );
extern GType vips_XYZ2Yxy_get_type( void );
extern GType vips_LabQ2Lab_get_type( void );
@ -857,8 +857,8 @@ vips_colour_operation_init( void )
vips_XYZ2Lab_get_type();
vips_Lab2LCh_get_type();
vips_LCh2Lab_get_type();
vips_LCh2UCS_get_type();
vips_UCS2LCh_get_type();
vips_LCh2CMC_get_type();
vips_CMC2LCh_get_type();
vips_XYZ2Yxy_get_type();
vips_Yxy2XYZ_get_type();
vips_LabQ2Lab_get_type();

View File

@ -61,7 +61,7 @@
* <emphasis>XYZ</emphasis>, <emphasis>Yxy</emphasis>,
* <emphasis>Lab</emphasis>, <emphasis>LabQ</emphasis>,
* <emphasis>LabS</emphasis>, <emphasis>LCh</emphasis> and
* <emphasis>UCS</emphasis>). Secondly, there are a set of operations for
* <emphasis>CMC</emphasis>). Secondly, there are a set of operations for
* calculating colour difference metrics. Finally, VIPS wraps LittleCMS and
* uses it to provide a set of operations for reading and writing images with
* ICC profiles.
@ -150,12 +150,12 @@
* </listitem>
* <listitem>
* <para>
* <emphasis><code>UCS</code></emphasis>
* <emphasis><code>CMC</code></emphasis>
*
* A colour space based on the CMC(1:1) colour difference measurement.
* This is a highly uniform colour space, much better than CIELAB for
* expressing small differences. Conversions to and from
* <code>UCS</code> are extremely slow.
* <code>CMC</code> are extremely slow.
* </para>
* </listitem>
* </itemizedlist>

View File

@ -66,7 +66,7 @@ G_DEFINE_TYPE( VipsdE76, vips_dE76, VIPS_TYPE_COLOUR_DIFFERENCE );
* @a2: Input coordinate 2
* @b2: Input coordinate 2
*
* Pythagorean distance between two points in colour space. Lab/XYZ/UCS etc.
* Pythagorean distance between two points in colour space. Lab/XYZ/CMC etc.
*/
float
vips_pythagoras( float L1, float a1, float b1, float L2, float a2, float b2 )

View File

@ -67,7 +67,7 @@ vips_dECMC_init( VipsdECMC *dECMC )
{
VipsColourDifference *difference = VIPS_COLOUR_DIFFERENCE( dECMC );
difference->interpretation = VIPS_INTERPRETATION_UCS;
difference->interpretation = VIPS_INTERPRETATION_CMC;
}
/**
@ -76,11 +76,11 @@ vips_dECMC_init( VipsdECMC *dECMC )
* @right: second input image
* @out: output image
*
* Calculate dE CMC. The input images are transformed to UCS colour space and
* Calculate dE CMC. The input images are transformed to CMC colour space and
* the euclidean distance between corresponding pixels calculated.
*
* To calculate a colour difference with values for (l:c) other than (1:1),
* transform the two source images to UCS yourself, scale the channels
* transform the two source images to CMC yourself, scale the channels
* appropriately, and call this function.
*
* See also: vips_colour_convert()

View File

@ -2265,7 +2265,7 @@ im_LCh2UCS( IMAGE *in, IMAGE *out )
{
VipsImage *x;
if( vips_LCh2UCS( in, &x, NULL ) )
if( vips_LCh2CMC( in, &x, NULL ) )
return( -1 );
if( im_copy( x, out ) ) {
g_object_unref( x );
@ -2281,7 +2281,7 @@ im_UCS2LCh( IMAGE *in, IMAGE *out )
{
VipsImage *x;
if( vips_UCS2LCh( in, &x, NULL ) )
if( vips_CMC2LCh( in, &x, NULL ) )
return( -1 );
if( im_copy( x, out ) ) {
g_object_unref( x );
@ -2661,15 +2661,6 @@ im_LabQ2XYZ( IMAGE *in, IMAGE *out )
return( 0 );
}
/**
* im_Lab2UCS:
* @in: input image
* @out: output image
*
* Convert an image from Lab to UCS.
*
* Returns: 0 on success, -1 on error.
*/
int
im_Lab2UCS( IMAGE *in, IMAGE *out )
{
@ -2683,15 +2674,6 @@ im_Lab2UCS( IMAGE *in, IMAGE *out )
return( 0 );
}
/**
* im_UCS2Lab:
* @in: input image
* @out: output image
*
* Convert an image from UCS to Lab.
*
* Returns: 0 on success, -1 on error.
*/
int
im_UCS2Lab( IMAGE *in, IMAGE *out )
{
@ -2705,15 +2687,6 @@ im_UCS2Lab( IMAGE *in, IMAGE *out )
return( 0 );
}
/**
* im_UCS2XYZ:
* @in: input image
* @out: output image
*
* Convert an image from UCS to XYZ.
*
* Returns: 0 on success, -1 on error.
*/
int
im_UCS2XYZ( IMAGE *in, IMAGE *out )
{
@ -2727,16 +2700,6 @@ im_UCS2XYZ( IMAGE *in, IMAGE *out )
return( 0 );
}
/**
* im_XY2UCS:
* @in: input image
* @out: output image
*
* Convert an image from XYZ to UCS.
*
* Returns: 0 on success, -1 on error.
*/
int
im_XYZ2UCS( IMAGE *in, IMAGE *out )
{
@ -2750,16 +2713,6 @@ im_XYZ2UCS( IMAGE *in, IMAGE *out )
return( 0 );
}
/**
* im_dE_fromXYZ:
* @in1: first input image
* @in2: second input image
* @out: output image
*
* Calculate CIELAB dE 1976 from a pair of XYZ images.
*
* Returns: 0 on success, -1 on error.
*/
int
im_dE_fromXYZ( IMAGE *in1, IMAGE *in2, IMAGE *out )
{

View File

@ -134,7 +134,7 @@ int vips_Lab2LCh( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_Yxy2Lab( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_UCS2XYZ( VipsImage *in, VipsImage **out, ... )
int vips_CMC2XYZ( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_Lab2XYZ( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
@ -144,9 +144,9 @@ int vips_XYZ2sRGB( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_sRGB2XYZ( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_LCh2UCS( VipsImage *in, VipsImage **out, ... )
int vips_LCh2CMC( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_UCS2LCh( VipsImage *in, VipsImage **out, ... )
int vips_CMC2LCh( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
int vips_XYZ2Yxy( VipsImage *in, VipsImage **out, ... )
__attribute__((sentinel));
@ -183,14 +183,14 @@ double vips_col_ab2h( double a, double b );
void vips_col_ab2Ch( float a, float b, float *C, float *h );
void vips_col_Ch2ab( float C, float h, float *a, float *b );
float vips_col_L2Lucs( float L );
float vips_col_C2Cucs( float C );
float vips_col_Ch2hucs( float C, float h );
float vips_col_L2Lcmc( float L );
float vips_col_C2Ccmc( float C );
float vips_col_Ch2hcmc( float C, float h );
void vips_col_make_tables_UCS( void );
float vips_col_Lucs2L( float Lucs );
float vips_col_Cucs2C( float Cucs );
float vips_col_Chucs2h( float C, float hucs );
void vips_col_make_tables_CMC( void );
float vips_col_Lcmc2L( float Lcmc );
float vips_col_Ccmc2C( float Ccmc );
float vips_col_Chcmc2h( float C, float hcmc );
int vips_col_XYZ2sRGB( float X, float Y, float Z,
int *r_ret, int *g_ret, int *b_ret,

View File

@ -118,7 +118,7 @@ typedef enum {
* @VIPS_INTERPRETATION_CMYK: the first four bands are in CMYK space
* @VIPS_INTERPRETATION_LABQ: implies #VIPS_CODING_LABQ
* @VIPS_INTERPRETATION_RGB: generic RGB space
* @VIPS_INTERPRETATION_UCS: a uniform colourspace based on CMC
* @VIPS_INTERPRETATION_CMC: a uniform colourspace based on CMC(1:1)
* @VIPS_INTERPRETATION_LCH: pixels are in CIE LCh space
* @VIPS_INTERPRETATION_LABS: CIE LAB coded as three signed 16-bit values
* @VIPS_INTERPRETATION_sRGB: pixels are sRGB
@ -148,7 +148,7 @@ typedef enum {
VIPS_INTERPRETATION_CMYK = 15,
VIPS_INTERPRETATION_LABQ = 16,
VIPS_INTERPRETATION_RGB = 17,
VIPS_INTERPRETATION_UCS = 18,
VIPS_INTERPRETATION_CMC = 18,
VIPS_INTERPRETATION_LCH = 19,
VIPS_INTERPRETATION_LABS = 21,
VIPS_INTERPRETATION_sRGB = 22,

View File

@ -86,15 +86,15 @@ extern "C" {
#define im_col_ab2Ch vips_col_ab2Ch
#define im_col_Ch2ab vips_col_Ch2ab
#define im_col_L2Lucs vips_col_L2Lucs
#define im_col_C2Cucs vips_col_C2Cucs
#define im_col_Ch2hucs vips_col_Ch2hucs
#define im_col_L2Lucs vips_col_L2Lcmc
#define im_col_C2Cucs vips_col_C2Ccmc
#define im_col_Ch2hucs vips_col_Ch2hcmc
#define im_col_pythagoras vips_pythagoras
#define im_col_make_tables_UCS vips_col_make_tables_UCS
#define im_col_Lucs2L vips_col_Lucs2L
#define im_col_Cucs2C vips_col_Cucs2C
#define im_col_Chucs2h vips_col_Chucs2h
#define im_col_make_tables_UCS vips_col_make_tables_CMC
#define im_col_Lucs2L vips_col_Lcmc2L
#define im_col_Cucs2C vips_col_Ccmc2C
#define im_col_Chucs2h vips_col_Chcmc2h
#define PEL VipsPel
@ -130,7 +130,7 @@ extern "C" {
#define IM_TYPE_CMYK VIPS_INTERPRETATION_CMYK
#define IM_TYPE_LABQ VIPS_INTERPRETATION_LABQ
#define IM_TYPE_RGB VIPS_INTERPRETATION_RGB
#define IM_TYPE_UCS VIPS_INTERPRETATION_UCS
#define IM_TYPE_UCS VIPS_INTERPRETATION_CMC
#define IM_TYPE_LCH VIPS_INTERPRETATION_LCH
#define IM_TYPE_LABS VIPS_INTERPRETATION_LABS
#define IM_TYPE_sRGB VIPS_INTERPRETATION_sRGB

View File

@ -448,7 +448,7 @@ vips_interpretation_get_type( void )
{VIPS_INTERPRETATION_CMYK, "VIPS_INTERPRETATION_CMYK", "cmyk"},
{VIPS_INTERPRETATION_LABQ, "VIPS_INTERPRETATION_LABQ", "labq"},
{VIPS_INTERPRETATION_RGB, "VIPS_INTERPRETATION_RGB", "rgb"},
{VIPS_INTERPRETATION_UCS, "VIPS_INTERPRETATION_UCS", "ucs"},
{VIPS_INTERPRETATION_CMC, "VIPS_INTERPRETATION_CMC", "cmc"},
{VIPS_INTERPRETATION_LCH, "VIPS_INTERPRETATION_LCH", "lch"},
{VIPS_INTERPRETATION_LABS, "VIPS_INTERPRETATION_LABS", "labs"},
{VIPS_INTERPRETATION_sRGB, "VIPS_INTERPRETATION_sRGB", "srgb"},