diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am index c9b312db..9e512be0 100644 --- a/doc/reference/Makefile.am +++ b/doc/reference/Makefile.am @@ -59,7 +59,7 @@ EXTRA_HFILES= # Header files to ignore when scanning. Use base file name, no paths # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h -IGNORE_HFILES=merge.h debug.h internal.h intl.h CImg.h im_video_v4l1.h global_balance.h dbh.h base64.h templates.h mosaic.h deprecated.h thread.h private.h internal.h almostdeprecated.h fmask.h inlines.h r_access.h struct.h +IGNORE_HFILES=merge.h debug.h internal.h intl.h CImg.h im_video_v4l1.h global_balance.h dbh.h base64.h templates.h mosaic.h deprecated.h thread.h private.h internal.h almostdeprecated.h fmask.h inlines.h struct.h disp.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png diff --git a/libvips/colour/colour.c b/libvips/colour/colour.c index 64aac347..8d47de8f 100644 --- a/libvips/colour/colour.c +++ b/libvips/colour/colour.c @@ -23,6 +23,8 @@ * - tiny cleanup for make_hI() prevents cond jump on ui in valgrind * 14/3/08 * - more tiny cond jump valgrind fixes + * 23/10/09 + * - gtkdoc comments */ /* @@ -67,6 +69,19 @@ #include #endif /*WITH_DMALLOC*/ +/** + * SECTION: colour + * @short_description: colour operators + * @stability: Stable + * @see_also: arithmetic + * @include: vips/vips.h + * + * These operators let you transform images between colour spaces, and move + * images to and from device spaces. + * + * + */ + /* Values for IM_TYPE_sRGB. */ static struct im_col_display srgb_profile = { diff --git a/libvips/include/vips/Makefile.am b/libvips/include/vips/Makefile.am index a5d79d8a..ab20c8d7 100644 --- a/libvips/include/vips/Makefile.am +++ b/libvips/include/vips/Makefile.am @@ -23,6 +23,7 @@ pkginclude_HEADERS = \ generate.h \ memory.h \ struct.h \ + disp.h \ private.h \ semaphore.h \ transform.h \ diff --git a/libvips/include/vips/colour.h b/libvips/include/vips/colour.h index 22aa38f2..ba491602 100644 --- a/libvips/include/vips/colour.h +++ b/libvips/include/vips/colour.h @@ -50,11 +50,6 @@ typedef struct { double X0, Y0, Z0; } im_colour_temperature; -/* Convert degrees->rads and vice-versa. - */ -#define IM_RAD( r ) (((r) / 360.0) * 2.0 * IM_PI) -#define IM_DEG( a ) (((a) / (2.0 * IM_PI)) * 360.0) - /* Areas under curves for Dxx. 2 degree observer. */ #define IM_D93_X0 (89.7400) @@ -105,57 +100,6 @@ typedef struct { #define IM_D3250_Y0 (100.0) #define IM_D3250_Z0 (45.8501) -/* Two kinds of display. A DISP_BARCO does gamma correction etc etc for us and - * needs only a colour space transform, a DISP_DUMB is an ordinary display and - * needs a full range of corrections. - */ -enum im_col_disp_type { - DISP_BARCO = 0, - DISP_DUMB -}; - -/* Structure for holding information about a display device. See the BARCO - * papers for details on the fields. - */ -struct im_col_display { - char *d_name; /* Display name */ - enum im_col_disp_type d_type; /* Display type */ - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCW; /* Luminosity of reference white */ - float d_xCW; /* x, y for reference white */ - float d_yCW; - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - int d_Vrwr; /* Pixel values for ref. white */ - int d_Vrwg; - int d_Vrwb; - float d_Y0R; /* Residual light for black pixel */ - float d_Y0G; - float d_Y0B; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; - float d_B; /* 'Background' (like brightness) */ - float d_P; /* 'Picture' (like contrast) */ -}; - -/* Structure for holding the lookup tables for XYZ<=>rgb conversion. - * Also holds the luminance to XYZ matrix and the inverse one. - */ -struct im_col_tab_disp { - float t_Yr2r[1501]; /* Conversion of Yr to r */ - float t_Yg2g[1501]; /* Conversion of Yg to g */ - float t_Yb2b[1501]; /* Conversion of Yb to b */ - float t_r2Yr[1501]; /* Conversion of r to Yr */ - float t_g2Yg[1501]; /* Conversion of g to Yg */ - float t_b2Yb[1501]; /* Conversion of b to Yb */ - float mat_XYZ2lum[3][3]; /* XYZ to Yr, Yg, Yb matrix */ - float mat_lum2XYZ[3][3]; /* Yr, Yg, Yb to XYZ matrix */ - float rstep, gstep, bstep; - float ristep, gistep, bistep; -}; - /* Colour loading and conversion functions. */ void im_col_ab2Ch( float a, float b, float *C, float *h ); @@ -164,18 +108,6 @@ 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 ); -struct im_col_tab_disp *im_col_make_tables_RGB( - IMAGE *im, - struct im_col_display *d ); -int im_col_rgb2XYZ( struct im_col_display *d, - struct im_col_tab_disp *table, - int r, int g, int b, - float *X, float *Y, float *Z ); -int im_col_XYZ2rgb( - struct im_col_display *d, struct im_col_tab_disp *table, - float X, float Y, float Z, - int *r_ret, int *g_ret, int *b_ret, - int *or_ret ); float im_col_L2Lucs( float L ); float im_col_Lucs2L( float Lucs ); @@ -185,32 +117,57 @@ float im_col_Ch2hucs( float C, float h ); float im_col_Chucs2h( float C, float hucs ); double im_col_ab2h( double a, double b ); -int im_ICC2display( char *filename, struct im_col_display *dpy ); -int im_XYZ2disp( IMAGE *, IMAGE *, struct im_col_display * ); -int im_Lab2disp( IMAGE *, IMAGE *, struct im_col_display * ); -int im_LabQ2disp( IMAGE *, IMAGE *, struct im_col_display * ); -int im_disp2XYZ( IMAGE *, IMAGE *, struct im_col_display * ); -int im_disp2Lab( IMAGE *, IMAGE *, struct im_col_display * ); +float im_col_dECMC( float, float, float, float, float, float ); +float im_col_dE00( float, float, float, float, float, float ); -void *im_LabQ2disp_build_table( IMAGE *out, struct im_col_display *d ); -int im_LabQ2disp_table( IMAGE *in, IMAGE *out, void *table ); +int im_Lab2LCh( IMAGE *, IMAGE * ); +int im_LCh2Lab( IMAGE *, IMAGE * ); +int im_LabQ2XYZ( IMAGE *, IMAGE * ); +int im_rad2float( IMAGE *, IMAGE * ); +int im_float2rad( IMAGE *, IMAGE * ); +int im_LCh2UCS( IMAGE *, IMAGE * ); +int im_Lab2LCh( IMAGE *, IMAGE * ); +int im_Lab2LabQ( IMAGE *, IMAGE * ); +int im_Lab2LabS( IMAGE *, IMAGE * ); +int im_Lab2XYZ( IMAGE *, IMAGE * ); +int im_Lab2XYZ_temp( IMAGE *, IMAGE *, double X0, double Y0, double Z0 ); +int im_Lab2UCS( IMAGE *, IMAGE * ); +int im_LabQ2Lab( IMAGE *, IMAGE * ); +int im_LabQ2LabS( IMAGE *, IMAGE * ); +int im_LabS2LabQ( IMAGE *, IMAGE * ); +int im_LabS2Lab( IMAGE *, IMAGE * ); +int im_UCS2XYZ( IMAGE *, IMAGE * ); +int im_UCS2LCh( IMAGE *, IMAGE * ); +int im_UCS2Lab( IMAGE *, IMAGE * ); +int im_XYZ2Lab( IMAGE *, IMAGE * ); +int im_XYZ2Lab_temp( IMAGE *, IMAGE *, double X0, double Y0, double Z0 ); +int im_XYZ2UCS( IMAGE *, IMAGE * ); +int im_sRGB2XYZ( IMAGE *, IMAGE * ); +int im_XYZ2sRGB( IMAGE *, IMAGE * ); +int im_Yxy2XYZ( IMAGE *, IMAGE * ); +int im_XYZ2Yxy( IMAGE *, IMAGE * ); -int im_dE_fromdisp( IMAGE *, IMAGE *, IMAGE *, struct im_col_display * ); -int im_dECMC_fromdisp( IMAGE *, IMAGE *, IMAGE *, struct im_col_display * ); +int im_dECMC_fromLab( IMAGE *, IMAGE *, IMAGE * ); int im_dE00_fromLab( IMAGE *, IMAGE *, IMAGE * ); +int im_dE_fromXYZ( IMAGE *, IMAGE *, IMAGE * ); +int im_dE_fromLab( IMAGE *, IMAGE *, IMAGE * ); -/* Colour display values and arrays - &im_col_screen_white, index 0 - &im_col_SPARC_white, index 1 - &im_col_D65_white, index 2 - &im_col_barco_white, index 3 - &im_col_mitsubishi, index 4 - &im_col_relative, index 5 - &ultra2, index 6 - &srgb_profile, index 7 - */ -struct im_col_display *im_col_displays( int ); -struct im_col_display *im_col_display_name( const char * ); +void imb_Lab2LCh( float *, float *, int ); +void imb_LCh2Lab( float *, float *, int ); +void imb_XYZ2Lab_tables( void ); +void imb_XYZ2Lab( float *, float *, int, im_colour_temperature * ); +void imb_Lab2XYZ( float *, float *, int, im_colour_temperature * ); +void imb_LabQ2Lab( PEL *, float *, int ); +void imb_Lab2LabQ( float *, PEL *, int ); +void imb_LabS2Lab( signed short *, float *, int ); +void imb_Lab2LabS( float *, signed short *, int n ); + +void im_col_make_tables_UCS( void ); + +int im_lab_morph( IMAGE *in, IMAGE *out, + DOUBLEMASK *mask, + double L_offset, double L_scale, + double a_scale, double b_scale ); /* Render intents for icc wrappers. */ diff --git a/libvips/include/vips/disp.h b/libvips/include/vips/disp.h new file mode 100644 index 00000000..225d67d4 --- /dev/null +++ b/libvips/include/vips/disp.h @@ -0,0 +1,135 @@ +/* VIPS display conversions. + * + * 23/10/09 + * - from colour.h + */ + +/* + + 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 + + */ + +#ifndef IM_DISP_H +#define IM_DISP_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +/* Two kinds of display. A DISP_BARCO does gamma correction etc etc for us and + * needs only a colour space transform, a DISP_DUMB is an ordinary display and + * needs a full range of corrections. + */ +enum im_col_disp_type { + DISP_BARCO = 0, + DISP_DUMB +}; + +/* Structure for holding information about a display device. See the BARCO + * papers for details on the fields. + */ +struct im_col_display { + /*< private >*/ + char *d_name; /* Display name */ + enum im_col_disp_type d_type; /* Display type */ + float d_mat[3][3]; /* XYZ -> luminance matrix */ + float d_YCW; /* Luminosity of reference white */ + float d_xCW; /* x, y for reference white */ + float d_yCW; + float d_YCR; /* Light o/p for reference white */ + float d_YCG; + float d_YCB; + int d_Vrwr; /* Pixel values for ref. white */ + int d_Vrwg; + int d_Vrwb; + float d_Y0R; /* Residual light for black pixel */ + float d_Y0G; + float d_Y0B; + float d_gammaR; /* Gamma values for the three guns */ + float d_gammaG; + float d_gammaB; + float d_B; /* 'Background' (like brightness) */ + float d_P; /* 'Picture' (like contrast) */ +}; + +/* Structure for holding the lookup tables for XYZ<=>rgb conversion. + * Also holds the luminance to XYZ matrix and the inverse one. + */ +struct im_col_tab_disp { + /*< private >*/ + float t_Yr2r[1501]; /* Conversion of Yr to r */ + float t_Yg2g[1501]; /* Conversion of Yg to g */ + float t_Yb2b[1501]; /* Conversion of Yb to b */ + float t_r2Yr[1501]; /* Conversion of r to Yr */ + float t_g2Yg[1501]; /* Conversion of g to Yg */ + float t_b2Yb[1501]; /* Conversion of b to Yb */ + float mat_XYZ2lum[3][3]; /* XYZ to Yr, Yg, Yb matrix */ + float mat_lum2XYZ[3][3]; /* Yr, Yg, Yb to XYZ matrix */ + float rstep, gstep, bstep; + float ristep, gistep, bistep; +}; + +struct im_col_tab_disp *im_col_make_tables_RGB( + IMAGE *im, + struct im_col_display *d ); +int im_col_rgb2XYZ( struct im_col_display *d, + struct im_col_tab_disp *table, + int r, int g, int b, + float *X, float *Y, float *Z ); +int im_col_XYZ2rgb( + struct im_col_display *d, struct im_col_tab_disp *table, + float X, float Y, float Z, + int *r_ret, int *g_ret, int *b_ret, + int *or_ret ); + +int im_XYZ2disp( IMAGE *, IMAGE *, struct im_col_display * ); +int im_Lab2disp( IMAGE *, IMAGE *, struct im_col_display * ); +int im_LabQ2disp( IMAGE *, IMAGE *, struct im_col_display * ); +int im_disp2XYZ( IMAGE *, IMAGE *, struct im_col_display * ); +int im_disp2Lab( IMAGE *, IMAGE *, struct im_col_display * ); + +/* Colour display values and arrays + &im_col_screen_white, index 0 + &im_col_SPARC_white, index 1 + &im_col_D65_white, index 2 + &im_col_barco_white, index 3 + &im_col_mitsubishi, index 4 + &im_col_relative, index 5 + &ultra2, index 6 + &srgb_profile, index 7 + */ +struct im_col_display *im_col_displays( int ); +struct im_col_display *im_col_display_name( const char * ); + +void *im_LabQ2disp_build_table( IMAGE *out, struct im_col_display *d ); +int im_LabQ2disp_table( IMAGE *in, IMAGE *out, void *table ); + +int im_dE_fromdisp( IMAGE *, IMAGE *, IMAGE *, struct im_col_display * ); +int im_dECMC_fromdisp( IMAGE *, IMAGE *, IMAGE *, struct im_col_display * ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*IM_DISP_H*/ diff --git a/libvips/include/vips/proto.h b/libvips/include/vips/proto.h index cbc94569..b9a7ebbe 100644 --- a/libvips/include/vips/proto.h +++ b/libvips/include/vips/proto.h @@ -300,59 +300,6 @@ int im_msb_band ( IMAGE * in, IMAGE * out, int band ); int im_wrap( IMAGE *in, IMAGE *out, int x, int y ); int im_vips2raw( IMAGE *in, int fd ); -/* colour - */ -int im_Lab2LCh( IMAGE *, IMAGE * ); -int im_LCh2Lab( IMAGE *, IMAGE * ); -int im_LabQ2XYZ( IMAGE *, IMAGE * ); -int im_rad2float( IMAGE *, IMAGE * ); -int im_float2rad( IMAGE *, IMAGE * ); -int im_LCh2UCS( IMAGE *, IMAGE * ); -int im_Lab2LCh( IMAGE *, IMAGE * ); -int im_Lab2LabQ( IMAGE *, IMAGE * ); -int im_Lab2LabS( IMAGE *, IMAGE * ); -int im_Lab2XYZ( IMAGE *, IMAGE * ); -int im_Lab2XYZ_temp( IMAGE *, IMAGE *, double X0, double Y0, double Z0 ); -int im_Lab2UCS( IMAGE *, IMAGE * ); -int im_LabQ2Lab( IMAGE *, IMAGE * ); -int im_LabQ2LabS( IMAGE *, IMAGE * ); -int im_LabS2LabQ( IMAGE *, IMAGE * ); -int im_LabS2Lab( IMAGE *, IMAGE * ); -int im_UCS2XYZ( IMAGE *, IMAGE * ); -int im_UCS2LCh( IMAGE *, IMAGE * ); -int im_UCS2Lab( IMAGE *, IMAGE * ); -int im_XYZ2Lab( IMAGE *, IMAGE * ); -int im_XYZ2Lab_temp( IMAGE *, IMAGE *, double X0, double Y0, double Z0 ); -int im_XYZ2UCS( IMAGE *, IMAGE * ); -int im_sRGB2XYZ( IMAGE *, IMAGE * ); -int im_XYZ2sRGB( IMAGE *, IMAGE * ); -int im_Yxy2XYZ( IMAGE *, IMAGE * ); -int im_XYZ2Yxy( IMAGE *, IMAGE * ); - -int im_dECMC_fromLab( IMAGE *, IMAGE *, IMAGE * ); -int im_dE_fromXYZ( IMAGE *, IMAGE *, IMAGE * ); -int im_dE_fromLab( IMAGE *, IMAGE *, IMAGE * ); - -void imb_Lab2LCh( float *, float *, int ); -void imb_LCh2Lab( float *, float *, int ); -void imb_XYZ2Lab_tables( void ); -void imb_XYZ2Lab( float *, float *, int, im_colour_temperature * ); -void imb_Lab2XYZ( float *, float *, int, im_colour_temperature * ); -void imb_LabQ2Lab( PEL *, float *, int ); -void imb_Lab2LabQ( float *, PEL *, int ); -void imb_LabS2Lab( signed short *, float *, int ); -void imb_Lab2LabS( float *, signed short *, int n ); - -void im_col_make_tables_UCS( void ); - -float im_col_dECMC( float, float, float, float, float, float ); -float im_col_dE00( float, float, float, float, float, float ); - -int im_lab_morph( IMAGE *in, IMAGE *out, - DOUBLEMASK *mask, - double L_offset, double L_scale, - double a_scale, double b_scale ); - /* other */ int im_feye( IMAGE *image, diff --git a/libvips/include/vips/util.h b/libvips/include/vips/util.h index 9d495847..1909b776 100644 --- a/libvips/include/vips/util.h +++ b/libvips/include/vips/util.h @@ -44,6 +44,11 @@ extern "C" { */ #define IM_PI (3.14159265358979323846) +/* Convert degrees->rads and vice-versa. + */ +#define IM_RAD( r ) (((r) / 360.0) * 2.0 * IM_PI) +#define IM_DEG( a ) (((a) / (2.0 * IM_PI)) * 360.0) + #define IM_MAX(A,B) ((A)>(B)?(A):(B)) #define IM_MIN(A,B) ((A)<(B)?(A):(B)) #define IM_ABS(x) (((x) >= 0) ? (x) : -(x)) diff --git a/libvips/include/vips/vips.h b/libvips/include/vips/vips.h index ee103051..ac561ff4 100644 --- a/libvips/include/vips/vips.h +++ b/libvips/include/vips/vips.h @@ -129,7 +129,7 @@ typedef struct im__DOUBLEMASK { #include #include #include -/* #include */ +#include #include #include #include