From 6f22c00df442f54cb52be11d82c914a36c76cf75 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 30 Nov 2012 21:35:12 +0000 Subject: [PATCH 1/2] NN now rounds down rather than to nearest nearest-neighbour interpolation now strictly rounds down rather than rounding to nearest round to nearest caused strange half-pixels along top/left image edges during enlargement, and extra 1.5 sized pixels everywhere else instead we should fix the thing that round to nearest was supposed to fix by adding an extra pair of params to the affine transform which displace in input space (dx/dy displace in output space) --- ChangeLog | 2 ++ TODO | 5 +++++ libvips/resample/interpolate.c | 6 ++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25d74457..3254fce7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,8 @@ - vipsthumbnail -o allows absolute file names - much better exif handling for jpg images (thanks Gary) - preserve jpeg app13 (photoshop ipct) +- nearest neighbour goes back to round down ... round to nearest caused a + range of annoying problems, such as strange half-pixels along edges 14/11/12 started 7.30.6 - capture tiff warnings earlier diff --git a/TODO b/TODO index 665ed0c5..3eb9175a 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,8 @@ +- now we've removed round-to-nearest from NN, we need something extra in the + affine transform to displace the input cods + + dx/dy displace output + - check libtool version number, should be binary-compat with 7.30 - quadratic doesn't work for order 3 diff --git a/libvips/resample/interpolate.c b/libvips/resample/interpolate.c index c46f3271..7a1431cd 100644 --- a/libvips/resample/interpolate.c +++ b/libvips/resample/interpolate.c @@ -333,10 +333,8 @@ vips_interpolate_nearest_interpolate( VipsInterpolate *interpolate, { const int ps = IM_IMAGE_SIZEOF_PEL( in->im ); - /* We know x/y are always positive, so we can just (int) them. - */ - const int xi = (int) (x + 0.5); - const int yi = (int) (y + 0.5); + const int xi = (int) x; + const int yi = (int) y; const VipsPel *p = IM_REGION_ADDR( in, xi, yi ); VipsPel *q = (VipsPel *) out; From 1ceb85eb5b8d3292187daafb56c0d0c3c5102614 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 4 Dec 2012 10:23:42 +0000 Subject: [PATCH 2/2] move colour_dispatch to deprecated --- libvips/colour/Makefile.am | 1 - libvips/colour/colour.c | 189 ++++++++++++++++++ libvips/deprecated/Makefile.am | 1 + .../{colour => deprecated}/colour_dispatch.c | 186 ----------------- 4 files changed, 190 insertions(+), 187 deletions(-) rename libvips/{colour => deprecated}/colour_dispatch.c (82%) diff --git a/libvips/colour/Makefile.am b/libvips/colour/Makefile.am index 806f96ce..53141c97 100644 --- a/libvips/colour/Makefile.am +++ b/libvips/colour/Makefile.am @@ -4,7 +4,6 @@ libcolour_la_SOURCES = \ colour.c \ colour.h \ colourspace.c \ - colour_dispatch.c \ dE76.c \ dE00.c \ dECMC.c \ diff --git a/libvips/colour/colour.c b/libvips/colour/colour.c index ea2990e6..a324b21c 100644 --- a/libvips/colour/colour.c +++ b/libvips/colour/colour.c @@ -45,6 +45,195 @@ #include "colour.h" +/** + * SECTION: colour + * @short_description: colour operators + * @stability: Stable + * @see_also: arithmetic + * @include: vips/vips.h + * + * These operators let you transform coordinates and images between colour + * spaces, calculate colour differences, and move + * to and from device spaces. + * + * Radiance images have four 8-bits bands and store 8 bits of R, G and B and + * another 8 bits of exponent, common to all channels. They are widely used in + * the HDR imaging community. + * + * + * The colour functions can be divided into three main groups. First, + * functions to transform images between the different colour spaces supported + * by VIPS: RGB, sRGB, + * XYZ, Yxy, + * Lab, LabQ, + * LabS, LCh and + * CMC). Use vips_colourspace() to move an image to a + * target colourspace using the best sequence of colour transform operations. + * 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. + * + * This figure shows how the VIPS colour spaces interconvert: + * + * + * + * The colour spaces supported by VIPS are: + * + * + * + * + * LabQ + * + * This is the principal VIPS colorimetric storage format. + * LabQ images have four 8-bit bands and store 10 bits of L and 11 bits + * of a and b. + * + * You cannot perform calculations on LabQ images (they are + * tagged with %VIPS_CODING_LABQ), though a few operations such as + * vips_extract_area() will work directly with them. + * + * + * + * + * LabS + * + * This format represents coordinates in CIELAB space as a + * three-band #VIPS_FORMAT_SHORT image, scaled to fit the full range of + * bits. It is the best format for computation, being relatively + * compact, quick, and accurate. Colour values expressed in this way + * are hard to visualise. + * + * + * + * + * Lab + * + * Lab colourspace represents CIELAB colour values with a three-band + * #VIPS_FORMAT_FLOAT image. This is the simplest format for general + * work: adding the constant 50 to the L channel, for example, has the + * expected result. + * + * VIPS uses D65 LAB, but you can use other colour temperatures with a + * little effort, see vips_XYZ2Lab(). + * + * + * + * + * XYZ + * + * CIE XYZ colour space represented as a three-band #VIPS_FORMAT_FLOAT + * image. + * + * + * + * + * Yxy + * + * CIE Yxy colour space represented as a three-band #VIPS_FORMAT_FLOAT + * image. + * + * + * + * + * RGB / sRGB + * + * VIPS converts XYZ to and from sRGB using the usual formula: + * + * http://en.wikipedia.org/wiki/SRGB + * + * You can also use vips_icc_transform() and friends to go to and from + * device space with a generic profile. + * + * + * + * + * LCh + * + * Like Lab, but rectangular ab coordinates + * are replaced with + * polar Ch (Chroma and hue) coordinates. + * Hue angles are expressed in degrees. + * + * + * + * + * CMC + * + * 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. + * + * You can calculate metrics like CMC(2:1) by scaling the spaces before + * finding differences. + * + * + * + */ + +/* Areas under curves for Dxx. 2 degree observer. + */ + +/** + * VIPS_D93_X0: + * + * Areas under curves for D93, 2 degree observer. + */ + +/** + * VIPS_D75_X0: + * + * Areas under curves for D75, 2 degree observer. + */ + +/** + * VIPS_D65_X0: + * + * Areas under curves for D65, 2 degree observer. + */ + +/** + * VIPS_D55_X0: + * + * Areas under curves for D55, 2 degree observer. + */ + +/** + * VIPS_D50_X0: + * + * Areas under curves for D50, 2 degree observer. + */ + +/** + * VIPS_A_X0: + * + * Areas under curves for illuminant A (2856K), 2 degree observer. + */ + +/** + * VIPS_B_X0: + * + * Areas under curves for illuminant B (4874K), 2 degree observer. + */ + +/** + * VIPS_C_X0: + * + * Areas under curves for illuminant C (6774K), 2 degree observer. + */ + +/** + * VIPS_E_X0: + * + * Areas under curves for equal energy illuminant E. + */ + +/** + * VIPS_D3250_X0: + * + * Areas under curves for black body at 3250K, 2 degree observer. + */ + G_DEFINE_ABSTRACT_TYPE( VipsColour, vips_colour, VIPS_TYPE_OPERATION ); /* Maximum number of input images -- why not? diff --git a/libvips/deprecated/Makefile.am b/libvips/deprecated/Makefile.am index be37ac80..38a766e8 100644 --- a/libvips/deprecated/Makefile.am +++ b/libvips/deprecated/Makefile.am @@ -4,6 +4,7 @@ libdeprecated_la_SOURCES = \ im_openslide2vips.c \ im_lab_morph.c \ deprecated_dispatch.c \ + colour_dispatch.c \ wrapvips7.c \ lazy.c \ im_dif_std.c \ diff --git a/libvips/colour/colour_dispatch.c b/libvips/deprecated/colour_dispatch.c similarity index 82% rename from libvips/colour/colour_dispatch.c rename to libvips/deprecated/colour_dispatch.c index 7265810b..dc280a28 100644 --- a/libvips/colour/colour_dispatch.c +++ b/libvips/deprecated/colour_dispatch.c @@ -38,192 +38,6 @@ #include -/** - * SECTION: colour - * @short_description: colour operators - * @stability: Stable - * @see_also: arithmetic - * @include: vips/vips.h - * - * These operators let you transform coordinates and images between colour - * spaces, calculate colour differences, and move - * to and from device spaces. - * - * Radiance images have four 8-bits bands and store 8 bits of R, G and B and - * another 8 bits of exponent, common to all channels. They are widely used in - * the HDR imaging community. - * - * - * The colour functions can be divided into three main groups. First, - * functions to transform images between the different colour spaces supported - * by VIPS: RGB (also referred to as - * disp), sRGB, - * XYZ, Yxy, - * Lab, LabQ, - * LabS, LCh and - * CMC). 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. - * - * This figure shows how the VIPS colour spaces interconvert: - * - * - * - * The colour spaces supported by VIPS are: - * - * - * - * - * LabQ - * - * This is the principal VIPS colorimetric storage format. - * LabQ images have four 8-bit bands and store 10 bits of L and 11 bits - * of a and b. - * - * You cannot perform calculations on LabQ images (they are - * tagged with %IM_CODING_LABQ), though a few operations such as - * im_extract_area() will work directly with them. - * - * - * - * - * LabS - * - * This format represents coordinates in CIELAB space as a - * three-band #IM_BANDFMT_SHORT image, scaled to fit the full range of - * bits. It is the best format for computation, being relatively - * compact, quick, and accurate. Colour values expressed in this way - * are hard to visualise. - * - * - * - * - * Lab - * - * Lab colourspace represents CIELAB colour values with a three-band - * #IM_BANDFMT_FLOAT image. This is the simplest format for general - * work: adding the constant 50 to the L channel, for example, has the - * expected result. - * - * VIPS uses D65 LAB, but you can use other colour temperatures with a - * little effort, see im_XYZ2Lab_temp(). - * - * - * - * - * XYZ - * - * CIE XYZ colour space represented as a three-band %IM_BANDFMT_FLOAT - * image. - * - * - * - * - * Yxy - * - * CIE Yxy colour space represented as a three-band %IM_BANDFMT_FLOAT - * image. - * - * - * - * - * RGB - * - * (also refered to as disp+) This is a generic 8-bit RGB - * image. VIPS has a system for going to and from RGB with a simple - * display structure, but it's mostly deprecated. See - * disp. - * - * Use im_icc_export() and friends as a modern replacement. - * - * - * - * - * LCh - * - * Like Lab, but rectangular ab coordinates - * are replaced with - * polar Ch (Chroma and hue) coordinates. - * Hue angles are expressed in degrees. - * - * - * - * - * CMC - * - * 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 - * CMC are extremely slow. - * - * - * - */ - -/* Areas under curves for Dxx. 2 degree observer. - */ - -/** - * IM_D93_X0: - * - * Areas under curves for D93, 2 degree observer. - */ - -/** - * IM_D75_X0: - * - * Areas under curves for D75, 2 degree observer. - */ - -/** - * IM_D65_X0: - * - * Areas under curves for D65, 2 degree observer. - */ - -/** - * IM_D55_X0: - * - * Areas under curves for D55, 2 degree observer. - */ - -/** - * IM_D50_X0: - * - * Areas under curves for D50, 2 degree observer. - */ - -/** - * IM_A_X0: - * - * Areas under curves for illuminant A (2856K), 2 degree observer. - */ - -/** - * IM_B_X0: - * - * Areas under curves for illuminant B (4874K), 2 degree observer. - */ - -/** - * IM_C_X0: - * - * Areas under curves for illuminant C (6774K), 2 degree observer. - */ - -/** - * IM_E_X0: - * - * Areas under curves for equal energy illuminant E. - */ - -/** - * IM_D3250_X0: - * - * Areas under curves for black body at 3250K, 2 degree observer. - */ - /* One image in, one out. */ static im_arg_desc one_in_one_out[] = {