From 5b271d16edbcd44e75e0975dac7fef0898dda566 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 5 Dec 2012 21:44:41 +0000 Subject: [PATCH] deprecate im_maxpos_avg() and add wrappers for im_maxpos_vec() / im_minpos_vec() --- TODO | 4 +- libvips/arithmetic/Makefile.am | 1 - libvips/deprecated/Makefile.am | 1 + .../im_maxpos_avg.c | 0 libvips/deprecated/vips7compat.c | 61 +++++++++++++++++-- libvips/include/vips/arithmetic.h | 5 -- libvips/include/vips/vips7compat.h | 2 + 7 files changed, 62 insertions(+), 12 deletions(-) rename libvips/{arithmetic => deprecated}/im_maxpos_avg.c (100%) diff --git a/TODO b/TODO index cfd6f1e0..ec0a0488 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ -- im_maxpos_vec()/im_minpos_vec() wrappers need doing +- add vips_band()/vips_bor() + -- im_maxpos_avg() should be NaN-avoiding? - now we've removed round-to-nearest from NN, we need something extra in the affine transform to displace the input cods diff --git a/libvips/arithmetic/Makefile.am b/libvips/arithmetic/Makefile.am index 1579e337..b26a2ea6 100644 --- a/libvips/arithmetic/Makefile.am +++ b/libvips/arithmetic/Makefile.am @@ -7,7 +7,6 @@ libarithmetic_la_SOURCES = \ deviate.c \ divide.c \ im_linreg.c \ - im_maxpos_avg.c \ measure.c \ multiply.c \ im_point_bilinear.c \ diff --git a/libvips/deprecated/Makefile.am b/libvips/deprecated/Makefile.am index 6da31487..30539bad 100644 --- a/libvips/deprecated/Makefile.am +++ b/libvips/deprecated/Makefile.am @@ -6,6 +6,7 @@ libdeprecated_la_SOURCES = \ deprecated_dispatch.c \ colour_dispatch.c \ arith_dispatch.c \ + im_maxpos_avg.c \ wrapvips7.c \ lazy.c \ im_dif_std.c \ diff --git a/libvips/arithmetic/im_maxpos_avg.c b/libvips/deprecated/im_maxpos_avg.c similarity index 100% rename from libvips/arithmetic/im_maxpos_avg.c rename to libvips/deprecated/im_maxpos_avg.c diff --git a/libvips/deprecated/vips7compat.c b/libvips/deprecated/vips7compat.c index dfeac7d6..712d14af 100644 --- a/libvips/deprecated/vips7compat.c +++ b/libvips/deprecated/vips7compat.c @@ -2810,13 +2810,66 @@ im_quadratic( IMAGE *in, IMAGE *out, IMAGE *coeff ) int im_maxpos_vec( VipsImage *im, int *xpos, int *ypos, double *maxima, int n ) { - printf( "im_maxpos_vec: fixme\n" ); - return( -1 ); + double max; + VipsArrayDouble *out_array; + VipsArrayInt *x_array; + VipsArrayInt *y_array; + + if( vips_max( im, &max, + "size", n, + "out_array", &out_array, + "x_array", &x_array, + "y_array", &y_array, + NULL ) ) + return( -1 ); + + memcpy( xpos, + vips_area_get_data( x_array, NULL, NULL, NULL, NULL ), + n * sizeof( int ) ); + memcpy( ypos, + vips_area_get_data( y_array, NULL, NULL, NULL, NULL ), + n * sizeof( int ) ); + memcpy( maxima, + vips_area_get_data( out_array, NULL, NULL, NULL, NULL ), + n * sizeof( double ) ); + + vips_area_unref( (VipsArea *) out_array ); + vips_area_unref( (VipsArea *) x_array ); + vips_area_unref( (VipsArea *) y_array ); + + return( 0 ); } int im_minpos_vec( VipsImage *im, int *xpos, int *ypos, double *minima, int n ) { - printf( "im_minpos_vec: fixme\n" ); - return( -1 ); + double min; + VipsArrayDouble *out_array; + VipsArrayInt *x_array; + VipsArrayInt *y_array; + + if( vips_min( im, &min, + "size", n, + "out_array", &out_array, + "x_array", &x_array, + "y_array", &y_array, + NULL ) ) + return( -1 ); + + memcpy( xpos, + vips_area_get_data( x_array, NULL, NULL, NULL, NULL ), + n * sizeof( int ) ); + memcpy( ypos, + vips_area_get_data( y_array, NULL, NULL, NULL, NULL ), + n * sizeof( int ) ); + memcpy( minima, + vips_area_get_data( out_array, NULL, NULL, NULL, NULL ), + n * sizeof( double ) ); + + vips_area_unref( (VipsArea *) out_array ); + vips_area_unref( (VipsArea *) x_array ); + vips_area_unref( (VipsArea *) y_array ); + + return( 0 ); } + diff --git a/libvips/include/vips/arithmetic.h b/libvips/include/vips/arithmetic.h index 75bf9083..7d3404d3 100644 --- a/libvips/include/vips/arithmetic.h +++ b/libvips/include/vips/arithmetic.h @@ -360,11 +360,6 @@ int vips_stats( VipsImage *in, VipsImage **out, ... ) int vips_measure( VipsImage *in, VipsImage **out, int h, int v, ... ) __attribute__((sentinel)); - - - -int im_maxpos_avg( VipsImage *im, double *xpos, double *ypos, double *out ); - int im_linreg( VipsImage **ins, VipsImage *out, double *xs ); int im_point( VipsImage *im, VipsInterpolate *interpolate, double x, double y, int band, double *out ); diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 51abaddf..4009ec26 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -667,6 +667,8 @@ int im_moreeqconst( VipsImage *in, VipsImage *out, double c ); int im_maxpos_vec( VipsImage *im, int *xpos, int *ypos, double *maxima, int n ); int im_minpos_vec( VipsImage *im, int *xpos, int *ypos, double *minima, int n ); +int im_maxpos_avg( VipsImage *im, double *xpos, double *ypos, double *out ); + int im_copy( VipsImage *in, VipsImage *out ); int im_copy_set( VipsImage *in, VipsImage *out, VipsInterpretation interpretation,