parent
cd7fcf5cfe
commit
5983833caa
|
@ -38,6 +38,7 @@
|
||||||
- added vips_thread_shutdown(), thanks Lovell
|
- added vips_thread_shutdown(), thanks Lovell
|
||||||
- vips_linear() has a uchar output mode
|
- vips_linear() has a uchar output mode
|
||||||
- redone im_cntlines(), im_rank() as classes
|
- redone im_cntlines(), im_rank() as classes
|
||||||
|
- move im_zerox() to deprecated, it wasm't very useful
|
||||||
|
|
||||||
9/1/14 started 7.36.6
|
9/1/14 started 7.36.6
|
||||||
- fix some clang compiler warnings
|
- fix some clang compiler warnings
|
||||||
|
|
|
@ -8,7 +8,6 @@ libconvolution_la_SOURCES = \
|
||||||
conv.c \
|
conv.c \
|
||||||
convsep.c \
|
convsep.c \
|
||||||
compass.c \
|
compass.c \
|
||||||
morph.c \
|
|
||||||
fastcor.c \
|
fastcor.c \
|
||||||
spcor.c \
|
spcor.c \
|
||||||
sharpen.c \
|
sharpen.c \
|
||||||
|
|
|
@ -150,7 +150,6 @@ void
|
||||||
vips_convolution_operation_init( void )
|
vips_convolution_operation_init( void )
|
||||||
{
|
{
|
||||||
extern int vips_conv_get_type( 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_compass_get_type( void );
|
||||||
extern int vips_convsep_get_type( void );
|
extern int vips_convsep_get_type( void );
|
||||||
extern int vips_fastcor_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 );
|
extern int vips_gaussblur_get_type( void );
|
||||||
|
|
||||||
vips_conv_get_type();
|
vips_conv_get_type();
|
||||||
vips_morph_get_type();
|
|
||||||
vips_compass_get_type();
|
vips_compass_get_type();
|
||||||
vips_convsep_get_type();
|
vips_convsep_get_type();
|
||||||
vips_fastcor_get_type();
|
vips_fastcor_get_type();
|
||||||
|
|
|
@ -9,8 +9,10 @@ libdeprecated_la_SOURCES = \
|
||||||
im_openslide2vips.c \
|
im_openslide2vips.c \
|
||||||
im_lab_morph.c \
|
im_lab_morph.c \
|
||||||
deprecated_dispatch.c \
|
deprecated_dispatch.c \
|
||||||
|
morph_dispatch.c \
|
||||||
colour_dispatch.c \
|
colour_dispatch.c \
|
||||||
convol_dispatch.c \
|
convol_dispatch.c \
|
||||||
|
im_zerox.c \
|
||||||
arith_dispatch.c \
|
arith_dispatch.c \
|
||||||
hist_dispatch.c \
|
hist_dispatch.c \
|
||||||
im_maxpos_avg.c \
|
im_maxpos_avg.c \
|
||||||
|
|
|
@ -51,22 +51,6 @@ typedef enum {
|
||||||
VIPS_COMBINE_LAST
|
VIPS_COMBINE_LAST
|
||||||
} VipsCombine;
|
} 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, ... )
|
int vips_conv( VipsImage *in, VipsImage **out, VipsImage *mask, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_compass( VipsImage *in, VipsImage **out, VipsImage *mask, ... )
|
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, ... )
|
int vips_convsep( VipsImage *in, VipsImage **out, VipsImage *mask, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
|
|
||||||
int vips_morph( VipsImage *in, VipsImage **out, VipsImage *mask,
|
|
||||||
VipsOperationMorphology morph, ... )
|
|
||||||
__attribute__((sentinel));
|
|
||||||
|
|
||||||
int vips_sharpen( VipsImage *in, VipsImage **out, ... )
|
int vips_sharpen( VipsImage *in, VipsImage **out, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
int vips_gaussblur( VipsImage *in, VipsImage **out, int radius, ... )
|
int vips_gaussblur( VipsImage *in, VipsImage **out, int radius, ... )
|
||||||
|
|
|
@ -78,6 +78,7 @@ GType vips_precision_get_type (void) G_GNUC_CONST;
|
||||||
#define VIPS_TYPE_PRECISION (vips_precision_get_type())
|
#define VIPS_TYPE_PRECISION (vips_precision_get_type())
|
||||||
GType vips_combine_get_type (void) G_GNUC_CONST;
|
GType vips_combine_get_type (void) G_GNUC_CONST;
|
||||||
#define VIPS_TYPE_COMBINE (vips_combine_get_type())
|
#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;
|
GType vips_operation_morphology_get_type (void) G_GNUC_CONST;
|
||||||
#define VIPS_TYPE_OPERATION_MORPHOLOGY (vips_operation_morphology_get_type())
|
#define VIPS_TYPE_OPERATION_MORPHOLOGY (vips_operation_morphology_get_type())
|
||||||
/* enumerations from "../../../libvips/include/vips/object.h" */
|
/* enumerations from "../../../libvips/include/vips/object.h" */
|
||||||
|
|
|
@ -38,20 +38,26 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /*__cplusplus*/
|
#endif /*__cplusplus*/
|
||||||
|
|
||||||
int vips_countlines( VipsImage *in, double *nolines,
|
typedef enum {
|
||||||
VipsDirection direction, ... )
|
VIPS_OPERATION_MORPHOLOGY_ERODE,
|
||||||
__attribute__((sentinel));
|
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 vips_rank( VipsImage *in, VipsImage **out,
|
||||||
int width, int height, int index, ... )
|
int width, int height, int index, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
|
int vips_countlines( VipsImage *in, double *nolines,
|
||||||
|
VipsDirection direction, ... )
|
||||||
|
__attribute__((sentinel));
|
||||||
int vips_median( VipsImage *in, VipsImage **out, int size, ... )
|
int vips_median( VipsImage *in, VipsImage **out, int size, ... )
|
||||||
__attribute__((sentinel));
|
__attribute__((sentinel));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int im_zerox( VipsImage *in, VipsImage *out, int sign );
|
|
||||||
int im_label_regions( VipsImage *test, VipsImage *mask, int *segments );
|
int im_label_regions( VipsImage *test, VipsImage *mask, int *segments );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -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_cntlines( VipsImage *im, double *nolines, int flag );
|
||||||
int im_rank( VipsImage *in, VipsImage *out, int width, int height, int index );
|
int im_rank( VipsImage *in, VipsImage *out, int width, int height, int index );
|
||||||
|
int im_zerox( VipsImage *in, VipsImage *out, int sign );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -670,6 +670,7 @@ vips_combine_get_type( void )
|
||||||
|
|
||||||
return( etype );
|
return( etype );
|
||||||
}
|
}
|
||||||
|
/* enumerations from "../../libvips/include/vips/morphology.h" */
|
||||||
GType
|
GType
|
||||||
vips_operation_morphology_get_type( void )
|
vips_operation_morphology_get_type( void )
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,8 @@ libmorphology_la_SOURCES = \
|
||||||
morphology.c \
|
morphology.c \
|
||||||
countlines.c \
|
countlines.c \
|
||||||
rank.c \
|
rank.c \
|
||||||
hitmiss.c\
|
hitmiss.c \
|
||||||
im_zerox.c \
|
morph.c \
|
||||||
morph_dispatch.c \
|
|
||||||
im_label_regions.c
|
im_label_regions.c
|
||||||
|
|
||||||
AM_CPPFLAGS = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
AM_CPPFLAGS = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@
|
||||||
|
|
|
@ -45,25 +45,42 @@
|
||||||
|
|
||||||
#include <vips/vips.h>
|
#include <vips/vips.h>
|
||||||
|
|
||||||
#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 {
|
typedef struct {
|
||||||
VipsConvolution parent_instance;
|
VipsMorphology parent_instance;
|
||||||
|
|
||||||
|
VipsImage *out;
|
||||||
|
VipsImage *mask;
|
||||||
VipsOperationMorphology morph;
|
VipsOperationMorphology morph;
|
||||||
|
|
||||||
|
/* @mask cast ready for processing.
|
||||||
|
*/
|
||||||
|
VipsImage *M;
|
||||||
|
|
||||||
} VipsMorph;
|
} 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
|
static int
|
||||||
vips_morph_build( VipsObject *object )
|
vips_morph_build( VipsObject *object )
|
||||||
{
|
{
|
||||||
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
|
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
|
||||||
VipsConvolution *convolution = (VipsConvolution *) object;
|
VipsMorphology *morphology = (VipsMorphology *) object;
|
||||||
VipsMorph *morph = (VipsMorph *) object;
|
VipsMorph *morph = (VipsMorph *) object;
|
||||||
|
VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 );
|
||||||
|
|
||||||
INTMASK *imsk;
|
INTMASK *imsk;
|
||||||
|
|
||||||
|
@ -72,18 +89,22 @@ vips_morph_build( VipsObject *object )
|
||||||
if( VIPS_OBJECT_CLASS( vips_morph_parent_class )->build( object ) )
|
if( VIPS_OBJECT_CLASS( vips_morph_parent_class )->build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( !(imsk = im_vips2imask( convolution->M, class->nickname )) ||
|
if( vips_check_matrix( class->nickname, morph->mask, &t[0] ) )
|
||||||
!im_local_imask( convolution->out, imsk ) )
|
return( -1 );
|
||||||
|
morph->M = t[0];
|
||||||
|
|
||||||
|
if( !(imsk = im_vips2imask( morph->M, class->nickname )) ||
|
||||||
|
!im_local_imask( morph->out, imsk ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
switch( morph->morph ) {
|
switch( morph->morph ) {
|
||||||
case VIPS_OPERATION_MORPHOLOGY_DILATE:
|
case VIPS_OPERATION_MORPHOLOGY_DILATE:
|
||||||
if( im_dilate( convolution->in, convolution->out, imsk ) )
|
if( im_dilate( morphology->in, morph->out, imsk ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIPS_OPERATION_MORPHOLOGY_ERODE:
|
case VIPS_OPERATION_MORPHOLOGY_ERODE:
|
||||||
if( im_erode( convolution->in, convolution->out, imsk ) )
|
if( im_erode( morphology->in, morph->out, imsk ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -104,9 +125,21 @@ vips_morph_class_init( VipsMorphClass *class )
|
||||||
gobject_class->get_property = vips_object_get_property;
|
gobject_class->get_property = vips_object_get_property;
|
||||||
|
|
||||||
object_class->nickname = "morph";
|
object_class->nickname = "morph";
|
||||||
object_class->description = _( "convolution operation" );
|
object_class->description = _( "morphology operation" );
|
||||||
object_class->build = vips_morph_build;
|
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,
|
VIPS_ARG_ENUM( class, "morph", 103,
|
||||||
_( "Morphology" ),
|
_( "Morphology" ),
|
||||||
_( "Morphological operation to perform" ),
|
_( "Morphological operation to perform" ),
|
|
@ -131,9 +131,11 @@ vips_morphology_init( VipsMorphology *morphology )
|
||||||
void
|
void
|
||||||
vips_morphology_operation_init( 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_rank_get_type( void );
|
||||||
|
extern int vips_countlines_get_type( void );
|
||||||
|
|
||||||
vips_countlines_get_type();
|
vips_morph_get_type();
|
||||||
vips_rank_get_type();
|
vips_rank_get_type();
|
||||||
|
vips_countlines_get_type();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue