From 5983833caa4f96c6b7257a9970209f607e8353ef Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 17 Jan 2014 18:03:46 +0000 Subject: [PATCH] deprecate im_zerox(), not very useful morph now done --- ChangeLog | 1 + libvips/convolution/Makefile.am | 1 - libvips/convolution/convolution.c | 2 - libvips/deprecated/Makefile.am | 2 + libvips/{morphology => deprecated}/im_zerox.c | 0 .../morph_dispatch.c | 0 libvips/include/vips/convolution.h | 20 ------- libvips/include/vips/enumtypes.h | 1 + libvips/include/vips/morphology.h | 16 ++++-- libvips/include/vips/vips7compat.h | 1 + libvips/iofuncs/enumtypes.c | 1 + libvips/morphology/Makefile.am | 5 +- libvips/{convolution => morphology}/morph.c | 53 +++++++++++++++---- libvips/morphology/morphology.c | 6 ++- 14 files changed, 66 insertions(+), 43 deletions(-) rename libvips/{morphology => deprecated}/im_zerox.c (100%) rename libvips/{morphology => deprecated}/morph_dispatch.c (100%) rename libvips/{convolution => morphology}/morph.c (78%) diff --git a/ChangeLog b/ChangeLog index e30ee507..cee2ce55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,7 @@ - added vips_thread_shutdown(), thanks Lovell - vips_linear() has a uchar output mode - redone im_cntlines(), im_rank() as classes +- move im_zerox() to deprecated, it wasm't very useful 9/1/14 started 7.36.6 - fix some clang compiler warnings diff --git a/libvips/convolution/Makefile.am b/libvips/convolution/Makefile.am index a0d5063f..32f6eec1 100644 --- a/libvips/convolution/Makefile.am +++ b/libvips/convolution/Makefile.am @@ -8,7 +8,6 @@ libconvolution_la_SOURCES = \ conv.c \ convsep.c \ compass.c \ - morph.c \ fastcor.c \ spcor.c \ sharpen.c \ diff --git a/libvips/convolution/convolution.c b/libvips/convolution/convolution.c index e05dfcdc..108f9eaf 100644 --- a/libvips/convolution/convolution.c +++ b/libvips/convolution/convolution.c @@ -150,7 +150,6 @@ void vips_convolution_operation_init( void ) { extern int vips_conv_get_type( void ); - extern int vips_morph_get_type( void ); extern int vips_compass_get_type( void ); extern int vips_convsep_get_type( void ); extern int vips_fastcor_get_type( void ); @@ -159,7 +158,6 @@ vips_convolution_operation_init( void ) extern int vips_gaussblur_get_type( void ); vips_conv_get_type(); - vips_morph_get_type(); vips_compass_get_type(); vips_convsep_get_type(); vips_fastcor_get_type(); diff --git a/libvips/deprecated/Makefile.am b/libvips/deprecated/Makefile.am index b77e9e69..88a1dadf 100644 --- a/libvips/deprecated/Makefile.am +++ b/libvips/deprecated/Makefile.am @@ -9,8 +9,10 @@ libdeprecated_la_SOURCES = \ im_openslide2vips.c \ im_lab_morph.c \ deprecated_dispatch.c \ + morph_dispatch.c \ colour_dispatch.c \ convol_dispatch.c \ + im_zerox.c \ arith_dispatch.c \ hist_dispatch.c \ im_maxpos_avg.c \ diff --git a/libvips/morphology/im_zerox.c b/libvips/deprecated/im_zerox.c similarity index 100% rename from libvips/morphology/im_zerox.c rename to libvips/deprecated/im_zerox.c diff --git a/libvips/morphology/morph_dispatch.c b/libvips/deprecated/morph_dispatch.c similarity index 100% rename from libvips/morphology/morph_dispatch.c rename to libvips/deprecated/morph_dispatch.c diff --git a/libvips/include/vips/convolution.h b/libvips/include/vips/convolution.h index 5153e88d..ce7e41e9 100644 --- a/libvips/include/vips/convolution.h +++ b/libvips/include/vips/convolution.h @@ -51,22 +51,6 @@ typedef enum { VIPS_COMBINE_LAST } VipsCombine; -/** - * VipsOperationMorphology: - * @VIPS_OPERATION_MORPHOLOGY_ERODE: true if all set - * @VIPS_OPERATION_MORPHOLOGY_DILATE: true if one set - * - * More like hit-miss, really. - * - * See also: vips_morph(). - */ - -typedef enum { - VIPS_OPERATION_MORPHOLOGY_ERODE, - VIPS_OPERATION_MORPHOLOGY_DILATE, - VIPS_OPERATION_MORPHOLOGY_LAST -} VipsOperationMorphology; - int vips_conv( VipsImage *in, VipsImage **out, VipsImage *mask, ... ) __attribute__((sentinel)); int vips_compass( VipsImage *in, VipsImage **out, VipsImage *mask, ... ) @@ -74,10 +58,6 @@ int vips_compass( VipsImage *in, VipsImage **out, VipsImage *mask, ... ) int vips_convsep( VipsImage *in, VipsImage **out, VipsImage *mask, ... ) __attribute__((sentinel)); -int vips_morph( VipsImage *in, VipsImage **out, VipsImage *mask, - VipsOperationMorphology morph, ... ) - __attribute__((sentinel)); - int vips_sharpen( VipsImage *in, VipsImage **out, ... ) __attribute__((sentinel)); int vips_gaussblur( VipsImage *in, VipsImage **out, int radius, ... ) diff --git a/libvips/include/vips/enumtypes.h b/libvips/include/vips/enumtypes.h index 311a452c..6fff1c4d 100644 --- a/libvips/include/vips/enumtypes.h +++ b/libvips/include/vips/enumtypes.h @@ -78,6 +78,7 @@ GType vips_precision_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_PRECISION (vips_precision_get_type()) GType vips_combine_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_COMBINE (vips_combine_get_type()) +/* enumerations from "../../../libvips/include/vips/morphology.h" */ GType vips_operation_morphology_get_type (void) G_GNUC_CONST; #define VIPS_TYPE_OPERATION_MORPHOLOGY (vips_operation_morphology_get_type()) /* enumerations from "../../../libvips/include/vips/object.h" */ diff --git a/libvips/include/vips/morphology.h b/libvips/include/vips/morphology.h index 8ff62451..89d17aec 100644 --- a/libvips/include/vips/morphology.h +++ b/libvips/include/vips/morphology.h @@ -38,20 +38,26 @@ extern "C" { #endif /*__cplusplus*/ -int vips_countlines( VipsImage *in, double *nolines, - VipsDirection direction, ... ) - __attribute__((sentinel)); +typedef enum { + VIPS_OPERATION_MORPHOLOGY_ERODE, + VIPS_OPERATION_MORPHOLOGY_DILATE, + VIPS_OPERATION_MORPHOLOGY_LAST +} VipsOperationMorphology; +int vips_morph( VipsImage *in, VipsImage **out, VipsImage *mask, + VipsOperationMorphology morph, ... ) + __attribute__((sentinel)); int vips_rank( VipsImage *in, VipsImage **out, int width, int height, int index, ... ) __attribute__((sentinel)); +int vips_countlines( VipsImage *in, double *nolines, + VipsDirection direction, ... ) + __attribute__((sentinel)); int vips_median( VipsImage *in, VipsImage **out, int size, ... ) __attribute__((sentinel)); - -int im_zerox( VipsImage *in, VipsImage *out, int sign ); int im_label_regions( VipsImage *test, VipsImage *mask, int *segments ); #ifdef __cplusplus diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 29d4f27f..9cfbf64b 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -977,6 +977,7 @@ int im_phasecor_fft( VipsImage *in1, VipsImage *in2, VipsImage *out ); int im_cntlines( VipsImage *im, double *nolines, int flag ); int im_rank( VipsImage *in, VipsImage *out, int width, int height, int index ); +int im_zerox( VipsImage *in, VipsImage *out, int sign ); #ifdef __cplusplus } diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 3802017b..7ab61739 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -670,6 +670,7 @@ vips_combine_get_type( void ) return( etype ); } +/* enumerations from "../../libvips/include/vips/morphology.h" */ GType vips_operation_morphology_get_type( void ) { diff --git a/libvips/morphology/Makefile.am b/libvips/morphology/Makefile.am index eb252ca3..f28da4fb 100644 --- a/libvips/morphology/Makefile.am +++ b/libvips/morphology/Makefile.am @@ -4,9 +4,8 @@ libmorphology_la_SOURCES = \ morphology.c \ countlines.c \ rank.c \ - hitmiss.c\ - im_zerox.c \ - morph_dispatch.c \ + hitmiss.c \ + morph.c \ im_label_regions.c AM_CPPFLAGS = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@ diff --git a/libvips/convolution/morph.c b/libvips/morphology/morph.c similarity index 78% rename from libvips/convolution/morph.c rename to libvips/morphology/morph.c index 6b699ff0..5270a581 100644 --- a/libvips/convolution/morph.c +++ b/libvips/morphology/morph.c @@ -45,25 +45,42 @@ #include -#include "pconvolution.h" +#include "pmorphology.h" + +/** + * VipsOperationMorphology: + * @VIPS_OPERATION_MORPHOLOGY_ERODE: true if all set + * @VIPS_OPERATION_MORPHOLOGY_DILATE: true if one set + * + * More like hit-miss, really. + * + * See also: vips_morph(). + */ typedef struct { - VipsConvolution parent_instance; + VipsMorphology parent_instance; + VipsImage *out; + VipsImage *mask; VipsOperationMorphology morph; + /* @mask cast ready for processing. + */ + VipsImage *M; + } VipsMorph; -typedef VipsConvolutionClass VipsMorphClass; +typedef VipsMorphologyClass VipsMorphClass; -G_DEFINE_TYPE( VipsMorph, vips_morph, VIPS_TYPE_CONVOLUTION ); +G_DEFINE_TYPE( VipsMorph, vips_morph, VIPS_TYPE_MORPHOLOGY ); static int vips_morph_build( VipsObject *object ) { VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object ); - VipsConvolution *convolution = (VipsConvolution *) object; + VipsMorphology *morphology = (VipsMorphology *) object; VipsMorph *morph = (VipsMorph *) object; + VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 ); INTMASK *imsk; @@ -72,18 +89,22 @@ vips_morph_build( VipsObject *object ) if( VIPS_OBJECT_CLASS( vips_morph_parent_class )->build( object ) ) return( -1 ); - if( !(imsk = im_vips2imask( convolution->M, class->nickname )) || - !im_local_imask( convolution->out, imsk ) ) + if( vips_check_matrix( class->nickname, morph->mask, &t[0] ) ) + return( -1 ); + morph->M = t[0]; + + if( !(imsk = im_vips2imask( morph->M, class->nickname )) || + !im_local_imask( morph->out, imsk ) ) return( -1 ); switch( morph->morph ) { case VIPS_OPERATION_MORPHOLOGY_DILATE: - if( im_dilate( convolution->in, convolution->out, imsk ) ) + if( im_dilate( morphology->in, morph->out, imsk ) ) return( -1 ); break; case VIPS_OPERATION_MORPHOLOGY_ERODE: - if( im_erode( convolution->in, convolution->out, imsk ) ) + if( im_erode( morphology->in, morph->out, imsk ) ) return( -1 ); break; @@ -104,9 +125,21 @@ vips_morph_class_init( VipsMorphClass *class ) gobject_class->get_property = vips_object_get_property; object_class->nickname = "morph"; - object_class->description = _( "convolution operation" ); + object_class->description = _( "morphology operation" ); object_class->build = vips_morph_build; + VIPS_ARG_IMAGE( class, "out", 10, + _( "Output" ), + _( "Output image" ), + VIPS_ARGUMENT_REQUIRED_OUTPUT, + G_STRUCT_OFFSET( VipsMorph, out ) ); + + VIPS_ARG_IMAGE( class, "mask", 20, + _( "Mask" ), + _( "Input matrix image" ), + VIPS_ARGUMENT_REQUIRED_INPUT, + G_STRUCT_OFFSET( VipsMorph, mask ) ); + VIPS_ARG_ENUM( class, "morph", 103, _( "Morphology" ), _( "Morphological operation to perform" ), diff --git a/libvips/morphology/morphology.c b/libvips/morphology/morphology.c index 095e4ec3..795d60eb 100644 --- a/libvips/morphology/morphology.c +++ b/libvips/morphology/morphology.c @@ -131,9 +131,11 @@ vips_morphology_init( VipsMorphology *morphology ) void vips_morphology_operation_init( void ) { - extern int vips_countlines_get_type( void ); + extern int vips_morph_get_type( void ); extern int vips_rank_get_type( void ); + extern int vips_countlines_get_type( void ); - vips_countlines_get_type(); + vips_morph_get_type(); vips_rank_get_type(); + vips_countlines_get_type(); }