From 487c112807f104ca15876ef19c8f9acb88638c76 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 2 Nov 2017 12:34:01 +0000 Subject: [PATCH] add VIPS_COMBINE_MIN combining mode for vips_compass() --- ChangeLog | 1 + libvips/convolution/compass.c | 10 ++++++++++ libvips/convolution/convolution.c | 3 ++- libvips/include/vips/convolution.h | 1 + libvips/iofuncs/enumtypes.c | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b38f75d1..f31061f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,7 @@ - "--size Nx" to vipsthumbnail was broken, thanks jrochkind - fix build with gcc 7 - add vips_fill_nearest() ... fill pixels with nearest colour +- add VIPS_COMBINE_MIN, a new combining mode for vips_compass() 29/8/17 started 8.5.9 - make --fail stop jpeg read on any libjpeg warning, thanks @mceachen diff --git a/libvips/convolution/compass.c b/libvips/convolution/compass.c index 7e25a3a2..7b686bdd 100644 --- a/libvips/convolution/compass.c +++ b/libvips/convolution/compass.c @@ -5,6 +5,8 @@ * 8/5/17 * - default to float ... int will often lose precision and should not be * the default + * 2/11/17 + * - add MIN mode */ /* @@ -116,6 +118,14 @@ vips_compass_build( VipsObject *object ) x = combine[0]; break; + case VIPS_COMBINE_MIN: + if( vips_bandrank( abs, &combine[0], compass->times, + "index", 0, + NULL ) ) + return( -1 ); + x = combine[0]; + break; + case VIPS_COMBINE_SUM: if( vips_sum( abs, &combine[0], compass->times, NULL ) ) return( -1 ); diff --git a/libvips/convolution/convolution.c b/libvips/convolution/convolution.c index 2650a40c..dc196be2 100644 --- a/libvips/convolution/convolution.c +++ b/libvips/convolution/convolution.c @@ -75,8 +75,9 @@ * VipsCombine: * @VIPS_COMBINE_MAX: take the maximum of the possible values * @VIPS_COMBINE_SUM: sum all the values + * @VIPS_COMBINE_MIN: take the minimum value * - * How to combine values. + * How to combine values. See vips_compass(), for example. */ G_DEFINE_ABSTRACT_TYPE( VipsConvolution, vips_convolution, diff --git a/libvips/include/vips/convolution.h b/libvips/include/vips/convolution.h index a79df95b..d3a2a0a5 100644 --- a/libvips/include/vips/convolution.h +++ b/libvips/include/vips/convolution.h @@ -41,6 +41,7 @@ extern "C" { typedef enum { VIPS_COMBINE_MAX, VIPS_COMBINE_SUM, + VIPS_COMBINE_MIN, VIPS_COMBINE_LAST } VipsCombine; diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index a10ddd90..805045ad 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -836,6 +836,7 @@ vips_combine_get_type( void ) static const GEnumValue values[] = { {VIPS_COMBINE_MAX, "VIPS_COMBINE_MAX", "max"}, {VIPS_COMBINE_SUM, "VIPS_COMBINE_SUM", "sum"}, + {VIPS_COMBINE_MIN, "VIPS_COMBINE_MIN", "min"}, {VIPS_COMBINE_LAST, "VIPS_COMBINE_LAST", "last"}, {0, NULL, NULL} };