From 7ef4573f1893e943374ff3f7a7962ed5c49b6c69 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 20 Oct 2013 16:10:22 +0100 Subject: [PATCH] redo im_log_*mask() as classes --- ChangeLog | 2 +- libvips/create/Makefile.am | 3 +- libvips/create/create.c | 6 +- libvips/create/{gauss.c => gaussmat.c} | 56 +++-- libvips/create/logmat.c | 273 +++++++++++++++++++++++++ libvips/deprecated/Makefile.am | 1 - libvips/deprecated/im_logmasks.c | 238 --------------------- libvips/deprecated/vips7compat.c | 45 +++- libvips/include/vips/create.h | 4 +- 9 files changed, 351 insertions(+), 277 deletions(-) rename libvips/create/{gauss.c => gaussmat.c} (81%) create mode 100644 libvips/create/logmat.c delete mode 100644 libvips/deprecated/im_logmasks.c diff --git a/ChangeLog b/ChangeLog index d575da57..1aba8933 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 19/10/13 started 7.37.0 -- redone im_rotate_*mask45(), im_gauss_*mask*() as classes +- redone im_rotate_*mask45(), im_gauss_*mask*(), im_log_*mask*() as classes 18/10/13 started 7.36.3 - fix compiler warnings in ubuntu 13.10 diff --git a/libvips/create/Makefile.am b/libvips/create/Makefile.am index 44752d97..59c2cf1b 100644 --- a/libvips/create/Makefile.am +++ b/libvips/create/Makefile.am @@ -3,7 +3,8 @@ noinst_LTLIBRARIES = libcreate.la libcreate_la_SOURCES = \ create.c \ pcreate.h \ - gauss.c \ + gaussmat.c \ + logmat.c \ buildlut.c \ invertlut.c \ tonelut.c \ diff --git a/libvips/create/create.c b/libvips/create/create.c index 4f75dea1..5130e92a 100644 --- a/libvips/create/create.c +++ b/libvips/create/create.c @@ -111,7 +111,8 @@ void vips_create_operation_init( void ) { extern GType vips_black_get_type( void ); - extern GType vips_gauss_get_type( void ); + extern GType vips_gaussmat_get_type( void ); + extern GType vips_logmat_get_type( void ); extern GType vips_gaussnoise_get_type( void ); #ifdef HAVE_PANGOFT2 extern GType vips_text_get_type( void ); @@ -127,7 +128,8 @@ vips_create_operation_init( void ) extern GType vips_identity_get_type( void ); vips_black_get_type(); - vips_gauss_get_type(); + vips_gaussmat_get_type(); + vips_logmat_get_type(); vips_gaussnoise_get_type(); #ifdef HAVE_PANGOFT2 vips_text_get_type(); diff --git a/libvips/create/gauss.c b/libvips/create/gaussmat.c similarity index 81% rename from libvips/create/gauss.c rename to libvips/create/gaussmat.c index 47a64cca..e7ec4705 100644 --- a/libvips/create/gauss.c +++ b/libvips/create/gaussmat.c @@ -13,7 +13,7 @@ * - set scale in _sep variant, why not * 21/10/10 * - gtkdoc - * 20/10/10 + * 20/10/13 * - redone as a class */ @@ -62,7 +62,7 @@ #include "pcreate.h" -typedef struct _VipsGauss { +typedef struct _VipsGaussmat { VipsCreate parent_instance; double sigma; @@ -71,40 +71,38 @@ typedef struct _VipsGauss { gboolean separable; gboolean integer; -} VipsGauss; +} VipsGaussmat; -typedef struct _VipsGaussClass { +typedef struct _VipsGaussmatClass { VipsCreateClass parent_class; -} VipsGaussClass; +} VipsGaussmatClass; -G_DEFINE_TYPE( VipsGauss, vips_gauss, VIPS_TYPE_CREATE ); +G_DEFINE_TYPE( VipsGaussmat, vips_gaussmat, VIPS_TYPE_CREATE ); static int -vips_gauss_build( VipsObject *object ) +vips_gaussmat_build( VipsObject *object ) { VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); VipsCreate *create = VIPS_CREATE( object ); - VipsGauss *gauss = (VipsGauss *) object; + VipsGaussmat *gaussmat = (VipsGaussmat *) object; + double sig2 = 2. * gaussmat->sigma * gaussmat->sigma; + int max_x = 8 * gaussmat->sigma > 5000 ? 5000 : 8 * gaussmat->sigma ; int x, y; - int max_x; int width, height; - double sig2; /* sig2 = 2. * sigma * sigma */ double sum; - if( VIPS_OBJECT_CLASS( vips_gauss_parent_class )->build( object ) ) + if( VIPS_OBJECT_CLASS( vips_gaussmat_parent_class )->build( object ) ) return( -1 ); /* Find the size of the mask. Limit the mask size to 10k x 10k for * sanity. */ - sig2 = 2. * gauss->sigma * gauss->sigma; - max_x = 8 * gauss->sigma > 5000 ? 5000 : 8 * gauss->sigma ; for( x = 0; x < max_x; x++ ) { double v = exp( - ((double)(x * x)) / sig2 ); - if( v < gauss->min_ampl ) + if( v < gaussmat->min_ampl ) break; } if( x == max_x ) { @@ -112,7 +110,7 @@ vips_gauss_build( VipsObject *object ) return( -1 ); } width = x * 2 + 1; - height = gauss->separable ? 1 : width; + height = gaussmat->separable ? 1 : width; vips_image_init_fields( create->out, width, height, 1, @@ -131,7 +129,7 @@ vips_gauss_build( VipsObject *object ) double distance = xo * xo + yo * yo; double v = exp( -distance / sig2 ); - if( gauss->integer ) + if( gaussmat->integer ) v = VIPS_RINT( 20 * v ); *VIPS_MATRIX( create->out, x, y ) = v; @@ -146,7 +144,7 @@ vips_gauss_build( VipsObject *object ) } static void -vips_gauss_class_init( VipsGaussClass *class ) +vips_gaussmat_class_init( VipsGaussmatClass *class ) { GObjectClass *gobject_class = G_OBJECT_CLASS( class ); VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class ); @@ -154,49 +152,49 @@ vips_gauss_class_init( VipsGaussClass *class ) gobject_class->set_property = vips_object_set_property; gobject_class->get_property = vips_object_get_property; - vobject_class->nickname = "gauss"; + vobject_class->nickname = "gaussmat"; vobject_class->description = _( "make a gaussian image" ); - vobject_class->build = vips_gauss_build; + vobject_class->build = vips_gaussmat_build; VIPS_ARG_DOUBLE( class, "sigma", 2, _( "Radius" ), _( "Radius of Gaussian" ), VIPS_ARGUMENT_REQUIRED_INPUT, - G_STRUCT_OFFSET( VipsGauss, sigma ), + G_STRUCT_OFFSET( VipsGaussmat, sigma ), 0.000001, 10000.0, 1.0 ); VIPS_ARG_DOUBLE( class, "min_ampl", 3, _( "Width" ), _( "Minimum amplitude of Gaussian" ), VIPS_ARGUMENT_REQUIRED_INPUT, - G_STRUCT_OFFSET( VipsGauss, min_ampl ), + G_STRUCT_OFFSET( VipsGaussmat, min_ampl ), 0.000001, 10000.0, 0.1 ); VIPS_ARG_BOOL( class, "separable", 4, _( "Separable" ), _( "Generate separable Gaussian" ), VIPS_ARGUMENT_OPTIONAL_INPUT, - G_STRUCT_OFFSET( VipsGauss, separable ), + G_STRUCT_OFFSET( VipsGaussmat, separable ), FALSE ); VIPS_ARG_BOOL( class, "integer", 5, _( "Integer" ), _( "Generate integer Gaussian" ), VIPS_ARGUMENT_OPTIONAL_INPUT, - G_STRUCT_OFFSET( VipsGauss, integer ), + G_STRUCT_OFFSET( VipsGaussmat, integer ), FALSE ); } static void -vips_gauss_init( VipsGauss *gauss ) +vips_gaussmat_init( VipsGaussmat *gaussmat ) { - gauss->sigma = 1; - gauss->min_ampl = 0.1; + gaussmat->sigma = 1; + gaussmat->min_ampl = 0.1; } /** - * vips_gauss: + * vips_gaussmat: * @sigma: standard deviation of mask * @min_ampl: minimum amplitude * @...: %NULL-terminated list of optional named arguments @@ -231,13 +229,13 @@ vips_gauss_init( VipsGauss *gauss ) * Returns: 0 on success, -1 on error */ int -vips_gauss( VipsImage **out, double sigma, double min_ampl, ... ) +vips_gaussmat( VipsImage **out, double sigma, double min_ampl, ... ) { va_list ap; int result; va_start( ap, min_ampl ); - result = vips_call_split( "gauss", ap, out, sigma, min_ampl ); + result = vips_call_split( "gaussmat", ap, out, sigma, min_ampl ); va_end( ap ); return( result ); diff --git a/libvips/create/logmat.c b/libvips/create/logmat.c new file mode 100644 index 00000000..e5af0ee4 --- /dev/null +++ b/libvips/create/logmat.c @@ -0,0 +1,273 @@ +/* laplacian of logmatian + * + * Written on: 30/11/1989 + * Updated on: 6/12/1991 + * 7/8/96 JC + * - ansified, mem leaks plugged + * 20/11/98 JC + * - mask too large check added + * 26/3/02 JC + * - ahem, was broken since '96, thanks matt + * 16/7/03 JC + * - makes mask out to zero, not out to minimum, thanks again matt + * 22/10/10 + * - gtkdoc + * 20/10/13 + * - redone as a class from logmat.c + */ + +/* + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +/* +#define VIPS_DEBUG + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include +#include +#include +#include + +#include + +#include "pcreate.h" + +typedef struct _VipsLogmat { + VipsCreate parent_instance; + + double sigma; + double min_ampl; + + gboolean separable; + gboolean integer; + +} VipsLogmat; + +typedef struct _VipsLogmatClass { + VipsCreateClass parent_class; + +} VipsLogmatClass; + +G_DEFINE_TYPE( VipsLogmat, vips_logmat, VIPS_TYPE_CREATE ); + +static int +vips_logmat_build( VipsObject *object ) +{ + VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); + VipsCreate *create = VIPS_CREATE( object ); + VipsLogmat *logmat = (VipsLogmat *) object; + double sig2 = logmat->sigma * logmat->sigma; + + double last; + int x, y; + int width, height; + double sum; + + if( VIPS_OBJECT_CLASS( vips_logmat_parent_class )->build( object ) ) + return( -1 ); + + /* Find the size of the mask. We want to eval the mask out to the + * flat zero part, ie. beyond the minimum and to the point where it + * comes back up towards zero. + */ + last = 0.0; + for( x = 0; x < 5000; x++ ) { + const double distance = x * x; + double val; + + /* Handbook of Pattern Recognition and image processing + * by Young and Fu AP 1986 pp 220-221 + * temp = (1.0 / (2.0 * IM_PI * sig4)) * + (2.0 - (distance / sig2)) * + exp( (-1.0) * distance / (2.0 * sig2) ) + + .. use 0.5 to normalise + */ + val = 0.5 * + (2.0 - (distance / sig2)) * + exp( -distance / (2.0 * sig2) ); + + /* Stop when change in value (ie. difference from the last + * point) is positive (ie. we are going up) and absolute value + * is less than the min. + */ + if( val - last >= 0 && + fabs( val ) < logmat->min_ampl ) + break; + + last = val; + } + if( x == 5000 ) { + vips_error( class->nickname, "%s", _( "mask too large" ) ); + return( -1 ); + } + + width = x * 2 + 1; + height = logmat->separable ? 1 : width; + + vips_image_init_fields( create->out, + width, height, 1, + VIPS_FORMAT_DOUBLE, VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W, + 1.0, 1.0 ); + vips_demand_hint( create->out, + VIPS_DEMAND_STYLE_ANY, NULL ); + if( vips_image_write_prepare( create->out ) ) + return( -1 ); + + sum = 0.0; + for( y = 0; y < height; y++ ) { + for( x = 0; x < width; x++ ) { + int xo = x - width / 2; + int yo = y - height / 2; + double distance = xo * xo + yo * yo; + double v = 0.5 * + (2.0 - (distance / sig2)) * + exp( -distance / (2.0 * sig2) ); + + if( logmat->integer ) + v = VIPS_RINT( 20 * v ); + + *VIPS_MATRIX( create->out, x, y ) = v; + sum += v; + } + } + + vips_image_set_double( create->out, "scale", sum ); + vips_image_set_double( create->out, "offset", 0.0 ); + + return( 0 ); +} + +static void +vips_logmat_class_init( VipsLogmatClass *class ) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS( class ); + VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class ); + + gobject_class->set_property = vips_object_set_property; + gobject_class->get_property = vips_object_get_property; + + vobject_class->nickname = "logmat"; + vobject_class->description = _( "make a laplacian of gaussian image" ); + vobject_class->build = vips_logmat_build; + + VIPS_ARG_DOUBLE( class, "sigma", 2, + _( "Radius" ), + _( "Radius of Logmatian" ), + VIPS_ARGUMENT_REQUIRED_INPUT, + G_STRUCT_OFFSET( VipsLogmat, sigma ), + 0.000001, 10000.0, 1.0 ); + + VIPS_ARG_DOUBLE( class, "min_ampl", 3, + _( "Width" ), + _( "Minimum amplitude of Logmatian" ), + VIPS_ARGUMENT_REQUIRED_INPUT, + G_STRUCT_OFFSET( VipsLogmat, min_ampl ), + 0.000001, 10000.0, 0.1 ); + + VIPS_ARG_BOOL( class, "separable", 4, + _( "Separable" ), + _( "Generate separable Logmatian" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsLogmat, separable ), + FALSE ); + + VIPS_ARG_BOOL( class, "integer", 5, + _( "Integer" ), + _( "Generate integer Logmatian" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsLogmat, integer ), + FALSE ); + +} + +static void +vips_logmat_init( VipsLogmat *logmat ) +{ + logmat->sigma = 1; + logmat->min_ampl = 0.1; +} + +/** + * vips_logmat: + * @sigma: standard deviation of mask + * @min_ampl: minimum amplitude + * @...: %NULL-terminated list of optional named arguments + * + * Optional arguments: + * + * @separable: generate a separable logmatian + * @integer: generate an integer logmatian + * + * Creates a circularly symmetric Laplacian of Gaussian mask + * of radius + * @sigma. The size of the mask is determined by the variable @min_ampl; + * if for instance the value .1 is entered this means that the produced mask + * is clipped at values within 10 persent of zero, and where the change + * between mask elements is less than 10%. + * + * The program uses the following equation: (from Handbook of Pattern + * Recognition and image processing by Young and Fu, AP 1986 pages 220-221): + * + * H(r) = (1 / (2 * M_PI * s4)) * + * (2 - (r2 / s2)) * + * exp(-r2 / (2 * s2)) + * + * where s2 = @sigma * @sigma, s4 = s2 * s2, r2 = r * r. + * + * The generated mask has odd size and its maximum value is normalised to + * 1.0, unless @integer is set. + * + * If @separable is set, only the centre horizontal is generated. This is + * useful for separable convolutions. + * + * If @integer is set, an integer logmatian is generated. This is useful for + * integer convolutions. + * + * "scale" is set to the sum of all the mask elements. + * + * See also: vips_gauss(), vips_conv(). + * + * Returns: 0 on success, -1 on error + */ +int +vips_logmat( VipsImage **out, double sigma, double min_ampl, ... ) +{ + va_list ap; + int result; + + va_start( ap, min_ampl ); + result = vips_call_split( "logmat", ap, out, sigma, min_ampl ); + va_end( ap ); + + return( result ); +} diff --git a/libvips/deprecated/Makefile.am b/libvips/deprecated/Makefile.am index cbd17ab9..d0110ab6 100644 --- a/libvips/deprecated/Makefile.am +++ b/libvips/deprecated/Makefile.am @@ -45,7 +45,6 @@ libdeprecated_la_SOURCES = \ im_mask2vips.c \ im_vips2mask.c \ rotmask.c \ - im_logmasks.c \ rw_mask.c \ im_matcat.c \ im_matinv.c \ diff --git a/libvips/deprecated/im_logmasks.c b/libvips/deprecated/im_logmasks.c deleted file mode 100644 index a044d43c..00000000 --- a/libvips/deprecated/im_logmasks.c +++ /dev/null @@ -1,238 +0,0 @@ -/* laplacian of gaussian - * - * Written on: 30/11/1989 - * Updated on: 6/12/1991 - * 7/8/96 JC - * - ansified, mem leaks plugged - * 20/11/98 JC - * - mask too large check added - * 26/3/02 JC - * - ahem, was broken since '96, thanks matt - * 16/7/03 JC - * - makes mask out to zero, not out to minimum, thanks again matt - * 22/10/10 - * - gtkdoc - */ - -/* - - 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA - - */ - -/* - - These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk - - */ - -/* -#define PIM_RINT 1 - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /*HAVE_CONFIG_H*/ -#include - -#include -#include - -#include -#include - -#define IM_MAXMASK 256 - -/** - * im_log_dmask: - * @filename: the returned mask has this set as the filename - * @sigma: standard deviation of mask - * @min_ampl: minimum amplitude - * - * im_log_dmask() creates a circularly symmetric Laplacian of Gaussian mask - * of radius - * @sigma. The size of the mask is determined by the variable @min_ampl; - * if for instance the value .1 is entered this means that the produced mask - * is clipped at values within 10 persent of zero, and where the change - * between mask elements is less than 10%. - * - * The program uses the following equation: (from Handbook of Pattern - * Recognition and image processing by Young and Fu, AP 1986 pages 220-221): - * - * H(r) = (1 / (2 * M_PI * s4)) * - * (2 - (r2 / s2)) * - * exp(-r2 / (2 * s2)) - * - * where s2 = sigma * sigma, s4 = s2 * s2, r2 = r * r. - * - * The generated mask has odd size and its maximum value is normalised to 1.0. - * - * See also: im_log_imask(), im_gauss_dmask(), im_conv(). - * - * Returns: the calculated mask on success, or NULL on error. - */ -DOUBLEMASK * -im_log_dmask( const char *filename, double sigma, double min_ampl ) -{ - const double sig2 = sigma * sigma; - - double last; - int x, y, k; - - double *pt1, *pt2, *pt3, *pt4; - int xm, ym; - int xm2, ym2; /* xm2 = xm/2 */ - int offset; - double *cf, *cfs, *mc; - DOUBLEMASK *m; - double sum; - - /* Find the size of the mask depending on the entered data. We want to - * eval the mask out to the flat zero part, ie. beyond the minimum and - * to the point where it comes back up towards zero. - */ - last = 0.0; - for( x = 0; x < IM_MAXMASK; x++ ) { - const double distance = x * x; - double val; - - /* Handbook of Pattern Recognition and image processing - * by Young and Fu AP 1986 pp 220-221 - * temp = (1.0 / (2.0 * IM_PI * sig4)) * - (2.0 - (distance / sig2)) * - exp( (-1.0) * distance / (2.0 * sig2) ) - - .. use 0.5 to normalise - */ - val = 0.5 * - (2.0 - (distance / sig2)) * - exp( -distance / (2.0 * sig2) ); - - /* Stop when change in value (ie. difference from the last - * point) is positive (ie. we are going up) and absolute value - * is less than the min. - */ - if( val - last >= 0 && - fabs( val ) < min_ampl ) - break; - - last = val; - } - if( x == IM_MAXMASK ) { - im_error( "im_log_dmask", "%s", _( "mask too large" ) ); - return( NULL ); - } - - xm2 = x; - ym2 = x; - xm = xm2 * 2 + 1; - ym = ym2 * 2 + 1; - - if( !(cfs = IM_ARRAY( NULL, (xm2 + 1) * (ym2 + 1), double )) ) - return( NULL ); - - /* Make 1/4 of the mask. - */ - for( k = 0, y = 0; y <= ym2; y++ ) - for( x = 0; x <= xm2; x++, k++ ) { - const double distance = x * x + y * y; - - cfs[k] = 0.5 * - (2.0 - (distance / sig2)) * - exp( -distance / (2.0 * sig2) ); - } - -#ifdef PIM_RINT - for( k = 0, y = 0; y <= ym2; y++ ) { - for( x = 0; x <= xm2; x++, k++ ) - fprintf( stderr, "%3.2f ", cfs[k] ); - fprintf( stderr, "\n" ); - } -#endif - - if( !(m = im_create_dmask( filename, xm, ym )) ) { - im_free( cfs ); - return( NULL ); - } - - /* Copy the 1/4 cfs into the m - */ - cf = cfs; - offset = xm2 * (xm + 1); - mc = m->coeff + offset; - for( y = 0; y <= ym2; y++ ) { - for( x = 0; x <= xm2; x++ ) { - pt1 = mc + (y * xm) + x; - pt2 = mc - (y * xm) + x; - pt3 = mc + (y * xm) - x; - pt4 = mc - (y * xm) - x; - - *pt1 = cf[x]; - *pt2 = cf[x]; - *pt3 = cf[x]; - *pt4 = cf[x]; - } - - cf += (xm2 + 1); - } - im_free( cfs ); - - sum = 0.0; - for( k = 0, y = 0; y < m->ysize; y++ ) - for( x = 0; x < m->xsize; x++, k++ ) - sum += m->coeff[k]; - m->scale = sum; - m->offset = 0.0; - -#ifdef PIM_RINT - im_print_dmask( m ); -#endif - - return( m ); -} - -/** - * im_log_imask: - * @filename: the returned mask has this set as the filename - * @sigma: standard deviation of mask - * @min_ampl: minimum amplitude - * - * im_log_imask() works exactly as im_log_dmask(), but the returned mask - * is scaled so that it's maximum value it set to 100. - * - * See also: im_log_dmask(), im_gauss_imask(), im_conv(). - * - * Returns: the calculated mask on success, or NULL on error. - */ -INTMASK * -im_log_imask( const char *filename, double sigma, double min_ampl ) -{ - DOUBLEMASK *dm; - INTMASK *im; - - if( !(dm = im_log_dmask( filename, sigma, min_ampl )) ) - return( NULL ); - - if( !(im = im_scale_dmask( dm, dm->filename )) ) { - im_free_dmask( dm ); - return( NULL ); - } - im_free_dmask( dm ); - - return( im ) ; -} diff --git a/libvips/deprecated/vips7compat.c b/libvips/deprecated/vips7compat.c index 783554c5..3f46f2a6 100644 --- a/libvips/deprecated/vips7compat.c +++ b/libvips/deprecated/vips7compat.c @@ -1900,7 +1900,7 @@ im_gauss_dmask( const char *filename, double sigma, double min_ampl ) VipsImage *t; DOUBLEMASK *msk; - if( vips_gauss( &t, sigma, min_ampl, + if( vips_gaussmat( &t, sigma, min_ampl, NULL ) ) return( NULL ); if( !(msk = im_vips2mask( t, filename )) ) { @@ -1918,7 +1918,7 @@ im_gauss_dmask_sep( const char *filename, double sigma, double min_ampl ) VipsImage *t; DOUBLEMASK *msk; - if( vips_gauss( &t, sigma, min_ampl, + if( vips_gaussmat( &t, sigma, min_ampl, "seperable", TRUE, NULL ) ) return( NULL ); @@ -1937,7 +1937,7 @@ im_gauss_imask( const char *filename, double sigma, double min_ampl ) VipsImage *t; INTMASK *msk; - if( vips_gauss( &t, sigma, min_ampl, + if( vips_gaussmat( &t, sigma, min_ampl, "integer", TRUE, NULL ) ) return( NULL ); @@ -1956,7 +1956,7 @@ im_gauss_imask_sep( const char *filename, double sigma, double min_ampl ) VipsImage *t; INTMASK *msk; - if( vips_gauss( &t, sigma, min_ampl, + if( vips_gaussmat( &t, sigma, min_ampl, "integer", TRUE, "seperable", TRUE, NULL ) ) @@ -1970,6 +1970,43 @@ im_gauss_imask_sep( const char *filename, double sigma, double min_ampl ) return( msk ); } +INTMASK * +im_log_imask( const char *filename, double sigma, double min_ampl ) +{ + VipsImage *t; + INTMASK *msk; + + if( vips_logmat( &t, sigma, min_ampl, + "integer", TRUE, + NULL ) ) + return( NULL ); + if( !(msk = im_vips2imask( t, filename )) ) { + g_object_unref( t ); + return( NULL ); + } + g_object_unref( t ); + + return( msk ); +} + +DOUBLEMASK * +im_log_dmask( const char *filename, double sigma, double min_ampl ) +{ + VipsImage *t; + DOUBLEMASK *msk; + + if( vips_logmat( &t, sigma, min_ampl, + NULL ) ) + return( NULL ); + if( !(msk = im_vips2mask( t, filename )) ) { + g_object_unref( t ); + return( NULL ); + } + g_object_unref( t ); + + return( msk ); +} + int im_recomb( IMAGE *in, IMAGE *out, DOUBLEMASK *recomb ) { diff --git a/libvips/include/vips/create.h b/libvips/include/vips/create.h index 4c68abe8..ddcf9c66 100644 --- a/libvips/include/vips/create.h +++ b/libvips/include/vips/create.h @@ -47,7 +47,9 @@ int vips_xyz( VipsImage **out, int width, int height, ... ) __attribute__((sentinel)); int vips_grey( VipsImage **out, int width, int height, ... ) __attribute__((sentinel)); -int vips_gauss( VipsImage **out, double sigma, double min_ampl, ... ) +int vips_gaussmat( VipsImage **out, double sigma, double min_ampl, ... ) + __attribute__((sentinel)); +int vips_logmat( VipsImage **out, double sigma, double min_ampl, ... ) __attribute__((sentinel)); int vips_text( VipsImage **out, const char *text, ... )