redo im_Yxy2XYZ() and im_XYZ2Yxy() as classes
This commit is contained in:
parent
e688bf29b6
commit
7b665c24df
@ -1,6 +1,6 @@
|
||||
31/8/12 started 7.31.0
|
||||
- redone im_Lab2XYZ(), im_XYZ2Lab(), im_Lab2LCh(), im_LCh2Lab(), im_UCS2LCh,
|
||||
im_LCh2UCS() as classes
|
||||
im_LCh2UCS(), im_XYZ2Yxy(), im_Yxy2XYZ() as classes
|
||||
|
||||
13/9/12 started 7.30.3
|
||||
- linecache sized itself too large
|
||||
|
@ -12,6 +12,8 @@ libcolour_la_SOURCES = \
|
||||
LCh2UCS.c \
|
||||
UCS2LCh.c \
|
||||
XYZ2Lab.c \
|
||||
XYZ2Yxy.c \
|
||||
Yxy2XYZ.c \
|
||||
im_icc_transform.c \
|
||||
im_Lab2LabQ.c \
|
||||
im_Lab2LabS.c \
|
||||
@ -21,9 +23,7 @@ libcolour_la_SOURCES = \
|
||||
im_LabS2LabQ.c \
|
||||
im_LabS2Lab.c \
|
||||
im_lab_morph.c \
|
||||
im_XYZ2Yxy.c \
|
||||
im_float2rad.c \
|
||||
im_Yxy2XYZ.c \
|
||||
im_XYZ2disp.c \
|
||||
im_dE00_fromLab.c \
|
||||
im_dECMC_fromLab.c \
|
||||
|
@ -43,16 +43,23 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
|
||||
/* Process a buffer of data.
|
||||
*/
|
||||
void
|
||||
imb_XYZ2Yxy( float *p, float *q, int n )
|
||||
#include "colour.h"
|
||||
|
||||
typedef VipsColorimetric VipsXYZ2Yxy;
|
||||
typedef VipsColorimetricClass VipsXYZ2YxyClass;
|
||||
|
||||
G_DEFINE_TYPE( VipsXYZ2Yxy, vips_XYZ2Yxy, VIPS_TYPE_COLORIMETRIC );
|
||||
|
||||
static void
|
||||
vips_XYZ2Yxy_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
|
||||
{
|
||||
float *p = (float *) in[0];
|
||||
float *q = (float *) out;
|
||||
|
||||
int i;
|
||||
|
||||
for( i = 0; i < n; i++ ) {
|
||||
for( i = 0; i < width; i++ ) {
|
||||
float X = p[0];
|
||||
float Y = p[1];
|
||||
float Z = p[2];
|
||||
@ -72,19 +79,42 @@ imb_XYZ2Yxy( float *p, float *q, int n )
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
vips_XYZ2Yxy_class_init( VipsXYZ2YxyClass *class )
|
||||
{
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsColourClass *colour_class = VIPS_COLOUR_CLASS( class );
|
||||
|
||||
object_class->nickname = "XYZ2Yxy";
|
||||
object_class->description = _( "transform XYZ to Yxy" );
|
||||
|
||||
colour_class->process_line = vips_XYZ2Yxy_line;
|
||||
colour_class->interpretation = VIPS_INTERPRETATION_YXY;
|
||||
}
|
||||
|
||||
static void
|
||||
vips_XYZ2Yxy_init( VipsXYZ2Yxy *XYZ2Yxy )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* im_XYZ2Yxy:
|
||||
* vips_XYZ2Yxy:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
*
|
||||
* Turn XYZ to Yxy.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int
|
||||
im_XYZ2Yxy( IMAGE *in, IMAGE *out )
|
||||
{
|
||||
return( im__colour_unary( "im_XYZ2Yxy", in, out, IM_TYPE_YXY,
|
||||
(im_wrapone_fn) imb_XYZ2Yxy, NULL, NULL ) );
|
||||
}
|
||||
int
|
||||
vips_XYZ2Yxy( VipsImage *in, VipsImage **out, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "XYZ2Yxy", ap, in, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
@ -43,16 +43,23 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
|
||||
/* Process a buffer of data.
|
||||
*/
|
||||
#include "colour.h"
|
||||
|
||||
typedef VipsColorimetric VipsYxy2XYZ;
|
||||
typedef VipsColorimetricClass VipsYxy2XYZClass;
|
||||
|
||||
G_DEFINE_TYPE( VipsYxy2XYZ, vips_Yxy2XYZ, VIPS_TYPE_COLORIMETRIC );
|
||||
|
||||
void
|
||||
imb_Yxy2XYZ( float *p, float *q, int n )
|
||||
vips_Yxy2XYZ_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width )
|
||||
{
|
||||
float *p = (float *) in[0];
|
||||
float *q = (float *) out;
|
||||
|
||||
int i;
|
||||
|
||||
for( i = 0; i < n; i++ ) {
|
||||
for( i = 0; i < width; i++ ) {
|
||||
float Y = p[0];
|
||||
float x = p[1];
|
||||
float y = p[2];
|
||||
@ -73,19 +80,43 @@ imb_Yxy2XYZ( float *p, float *q, int n )
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
vips_Yxy2XYZ_class_init( VipsYxy2XYZClass *class )
|
||||
{
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
VipsColourClass *colour_class = VIPS_COLOUR_CLASS( class );
|
||||
|
||||
object_class->nickname = "Yxy2XYZ";
|
||||
object_class->description = _( "transform Yxy to XYZ" );
|
||||
|
||||
colour_class->process_line = vips_Yxy2XYZ_line;
|
||||
colour_class->interpretation = VIPS_INTERPRETATION_XYZ;
|
||||
}
|
||||
|
||||
static void
|
||||
vips_Yxy2XYZ_init( VipsYxy2XYZ *Yxy2XYZ )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* im_Yxy2XYZ:
|
||||
* vips_Yxy2XYZ:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
*
|
||||
* Turn Yxy to XYZ.
|
||||
* Turn XYZ to Yxy.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int
|
||||
im_Yxy2XYZ( IMAGE *in, IMAGE *out )
|
||||
int
|
||||
vips_Yxy2XYZ( VipsImage *in, VipsImage **out, ... )
|
||||
{
|
||||
return( im__colour_unary( "im_Yxy2XYZ", in, out, IM_TYPE_XYZ,
|
||||
(im_wrapone_fn) imb_Yxy2XYZ, NULL, NULL ) );
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, out );
|
||||
result = vips_call_split( "Yxy2XYZ", ap, in, out );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
@ -244,14 +244,20 @@ void
|
||||
vips_colour_operation_init( void )
|
||||
{
|
||||
extern GType vips_Lab2XYZ_get_type( 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_Yxy2XYZ_get_type( void );
|
||||
extern GType vips_XYZ2Yxy_get_type( void );
|
||||
|
||||
vips_Lab2XYZ_get_type();
|
||||
vips_XYZ2Lab_get_type();
|
||||
vips_Lab2LCh_get_type();
|
||||
vips_LCh2Lab_get_type();
|
||||
vips_LCh2UCS_get_type();
|
||||
vips_UCS2LCh_get_type();
|
||||
vips_XYZ2Yxy_get_type();
|
||||
vips_Yxy2XYZ_get_type();
|
||||
}
|
||||
|
@ -2291,3 +2291,35 @@ im_UCS2LCh( IMAGE *in, IMAGE *out )
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
im_XYZ2Yxy( IMAGE *in, IMAGE *out )
|
||||
{
|
||||
VipsImage *x;
|
||||
|
||||
if( vips_XYZ2Yxy( in, &x, NULL ) )
|
||||
return( -1 );
|
||||
if( im_copy( x, out ) ) {
|
||||
g_object_unref( x );
|
||||
return( -1 );
|
||||
}
|
||||
g_object_unref( x );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
im_Yxy2XYZ( IMAGE *in, IMAGE *out )
|
||||
{
|
||||
VipsImage *x;
|
||||
|
||||
if( vips_Yxy2XYZ( in, &x, NULL ) )
|
||||
return( -1 );
|
||||
if( im_copy( x, out ) ) {
|
||||
g_object_unref( x );
|
||||
return( -1 );
|
||||
}
|
||||
g_object_unref( x );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -126,6 +126,10 @@ int vips_LCh2UCS( VipsImage *in, VipsImage **out, ... )
|
||||
__attribute__((sentinel));
|
||||
int vips_UCS2LCh( VipsImage *in, VipsImage **out, ... )
|
||||
__attribute__((sentinel));
|
||||
int vips_XYZ2Yxy( VipsImage *in, VipsImage **out, ... )
|
||||
__attribute__((sentinel));
|
||||
int vips_Yxy2XYZ( VipsImage *in, VipsImage **out, ... )
|
||||
__attribute__((sentinel));
|
||||
|
||||
void vips_col_Lab2XYZ( float L, float a, float b,
|
||||
float *X, float *Y, float *Z );
|
||||
@ -174,8 +178,6 @@ int im_Lab2UCS( VipsImage *in, VipsImage *out );
|
||||
int im_XYZ2UCS( VipsImage *in, VipsImage *out );
|
||||
int im_sRGB2XYZ( VipsImage *in, VipsImage *out );
|
||||
int im_XYZ2sRGB( VipsImage *in, VipsImage *out );
|
||||
int im_Yxy2XYZ( VipsImage *in, VipsImage *out );
|
||||
int im_XYZ2Yxy( VipsImage *in, VipsImage *out );
|
||||
|
||||
int im_dECMC_fromLab( VipsImage *in1, VipsImage *in2, VipsImage *out );
|
||||
int im_dE00_fromLab( VipsImage *in1, VipsImage *in2, VipsImage *out );
|
||||
|
@ -716,6 +716,8 @@ int im_Lab2LCh( VipsImage *in, VipsImage *out );
|
||||
int im_LCh2Lab( VipsImage *in, VipsImage *out );
|
||||
int im_LCh2UCS( VipsImage *in, VipsImage *out );
|
||||
int im_UCS2LCh( VipsImage *in, VipsImage *out );
|
||||
int im_XYZ2Yxy( VipsImage *in, VipsImage *out );
|
||||
int im_Yxy2XYZ( VipsImage *in, VipsImage *out );
|
||||
|
||||
/* ruby-vips uses this
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user