start vips_conv()
This commit is contained in:
parent
461d619cde
commit
45a9e417f4
@ -23,6 +23,7 @@
|
||||
- dzsave basename param now called filename, so you can use .dz as a
|
||||
destination (basename is still there but deprecated)
|
||||
- new _UNBUFFERED sequential mode saves memory in some important cases
|
||||
- start vips_conv() as a simple wrapper over the old convolution functions
|
||||
|
||||
3/7/13 started 7.34.2
|
||||
- lower priority for Matlab load to reduce segvs from Mat_Open(), thanks
|
||||
|
4
TODO
4
TODO
@ -1,3 +1,7 @@
|
||||
- why is memuse so high?
|
||||
|
||||
$ vips shrink wtc.png x.v 230 230
|
||||
memory: high-water mark 322.13 MB
|
||||
|
||||
- finish hist_ismonotonic()
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* recomb.c ... pass an image though a matrix
|
||||
*
|
||||
/* recomb.c ... pass an image though a matrix *
|
||||
* 21/6/95 JC
|
||||
* - mildly modernised
|
||||
* 14/3/96 JC
|
||||
|
@ -1,6 +1,9 @@
|
||||
noinst_LTLIBRARIES = libconvolution.la
|
||||
|
||||
libconvolution_la_SOURCES = \
|
||||
convolution.c \
|
||||
pconvolution.h \
|
||||
conv.c \
|
||||
convol_dispatch.c \
|
||||
im_addgnoise.c \
|
||||
im_compass.c \
|
||||
|
125
libvips/convolution/conv.c
Normal file
125
libvips/convolution/conv.c
Normal file
@ -0,0 +1,125 @@
|
||||
/* histogram cumulativisation
|
||||
*
|
||||
* Author: N. Dessipris
|
||||
* Written on: 02/08/1990
|
||||
* 24/5/95 JC
|
||||
* - tidied up and ANSIfied
|
||||
* 20/7/95 JC
|
||||
* - smartened up again
|
||||
* - now works for hists >256 elements
|
||||
* 3/3/01 JC
|
||||
* - broken into cum and norm ... helps im_histspec()
|
||||
* - better behaviour for >8 bit hists
|
||||
* 31/10/05 JC
|
||||
* - was broken for vertical histograms, gah
|
||||
* - neater im_histnorm()
|
||||
* 23/7/07
|
||||
* - eek, off by 1 for more than 1 band hists
|
||||
* 12/5/08
|
||||
* - histcum works for signed hists now as well
|
||||
* 24/3/10
|
||||
* - gtkdoc
|
||||
* - small cleanups
|
||||
* 12/8/13
|
||||
* - redone im_histcum() as a class, vips_conv()
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
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
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
#include "pconvolution.h"
|
||||
|
||||
typedef struct {
|
||||
VipsConvolution parent_instance;
|
||||
|
||||
VipsPrecision precision;
|
||||
} VipsConv;
|
||||
|
||||
typedef VipsConvolutionClass VipsConvClass;
|
||||
|
||||
G_DEFINE_TYPE( VipsConv, vips_conv, VIPS_TYPE_CONVOLUTION );
|
||||
|
||||
static void
|
||||
vips_conv_class_init( VipsConvClass *class )
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
|
||||
VipsObjectClass *object_class = (VipsObjectClass *) class;
|
||||
|
||||
gobject_class->set_property = vips_object_set_property;
|
||||
gobject_class->get_property = vips_object_get_property;
|
||||
|
||||
object_class->nickname = "conv";
|
||||
object_class->description = _( "convolution operation" );
|
||||
|
||||
VIPS_ARG_ENUM( class, "precision", 103,
|
||||
_( "Precision" ),
|
||||
_( "Convolve with this precision" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsConv, precision ),
|
||||
VIPS_TYPE_PRECISION, VIPS_PRECISION_INTEGER );
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
vips_conv_init( VipsConv *conv )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_conv:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
* @mask: convolve with this mask
|
||||
* @...: %NULL-terminated list of optional named arguments
|
||||
*
|
||||
* Convolution.
|
||||
*
|
||||
* See also: vips_hist_norm().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int
|
||||
vips_conv( VipsImage *in, VipsImage **out, VipsImage *mask, ... )
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start( ap, mask );
|
||||
result = vips_call_split( "conv", ap, in, out, mask );
|
||||
va_end( ap );
|
||||
|
||||
return( result );
|
||||
}
|
@ -39,17 +39,6 @@
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
/**
|
||||
* SECTION: convolution
|
||||
* @short_description: convolve and correlate images
|
||||
* @stability: Stable
|
||||
* @include: vips/vips.h
|
||||
*
|
||||
* These operations convolve an image in some way, or are operations based on
|
||||
* simple convolution, or are useful with convolution.
|
||||
*
|
||||
*/
|
||||
|
||||
/* One image in, one out.
|
||||
*/
|
||||
static im_arg_desc one_in_one_out[] = {
|
||||
|
152
libvips/convolution/convolution.c
Normal file
152
libvips/convolution/convolution.c
Normal file
@ -0,0 +1,152 @@
|
||||
/* base class for all convolution operations
|
||||
*
|
||||
* properties:
|
||||
* - one input image
|
||||
* - one output image
|
||||
* - one input mask
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Copyright (C) 1991-2005 The National Gallery
|
||||
|
||||
This library 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.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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 library; 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 DEBUG
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
|
||||
#include "pconvolution.h"
|
||||
|
||||
/**
|
||||
* SECTION: convolution
|
||||
* @short_description: convolve and correlate images
|
||||
* @stability: Stable
|
||||
* @include: vips/vips.h
|
||||
*
|
||||
* These operations convolve an image in some way, or are operations based on
|
||||
* simple convolution, or are useful with convolution.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* VipsPrecision:
|
||||
* @VIPS_PRECISION_INTEGER: int everywhere
|
||||
* @VIPS_PRECISION_FLOAT: float everywhere
|
||||
* @VIPS_PRECISION_APPROXIMATE: approximate integer output
|
||||
*
|
||||
* How accurate an operation should be.
|
||||
*
|
||||
*/
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE( VipsConvolution, vips_convolution,
|
||||
VIPS_TYPE_OPERATION );
|
||||
|
||||
static int
|
||||
vips_convolution_build( VipsObject *object )
|
||||
{
|
||||
VipsConvolution *convolution = VIPS_CONVOLUTION( object );
|
||||
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( object );
|
||||
VipsImage **t = (VipsImage **) vips_object_local_array( object, 2 );
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "vips_convolution_build: " );
|
||||
vips_object_print_name( object );
|
||||
printf( "\n" );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
if( VIPS_OBJECT_CLASS( vips_convolution_parent_class )->
|
||||
build( object ) )
|
||||
return( -1 );
|
||||
|
||||
if( vips_check_matrix( class->nickname, convolution->mask, &t[0] ) )
|
||||
return( -1 );
|
||||
convolution->M = t[0];
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_convolution_class_init( VipsConvolutionClass *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 = "convolution";
|
||||
vobject_class->description = _( "convolution operations" );
|
||||
vobject_class->build = vips_convolution_build;
|
||||
|
||||
/* Inputs set by subclassess.
|
||||
*/
|
||||
|
||||
VIPS_ARG_IMAGE( class, "in", 0,
|
||||
_( "Input" ),
|
||||
_( "Input image argument" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsConvolution, in ) );
|
||||
|
||||
VIPS_ARG_IMAGE( class, "out", 10,
|
||||
_( "Output" ),
|
||||
_( "Output image" ),
|
||||
VIPS_ARGUMENT_REQUIRED_OUTPUT,
|
||||
G_STRUCT_OFFSET( VipsConvolution, out ) );
|
||||
|
||||
VIPS_ARG_IMAGE( class, "mask", 102,
|
||||
_( "Mask" ),
|
||||
_( "Input matrix image" ),
|
||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||
G_STRUCT_OFFSET( VipsConvolution, mask ) );
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
vips_convolution_init( VipsConvolution *convolution )
|
||||
{
|
||||
}
|
||||
|
||||
/* Called from iofuncs to init all operations in this dir. Use a plugin system
|
||||
* instead?
|
||||
*/
|
||||
void
|
||||
vips_convolution_operation_init( void )
|
||||
{
|
||||
extern int vips_conv_get_type( void );
|
||||
|
||||
vips_conv_get_type();
|
||||
}
|
82
libvips/convolution/pconvolution.h
Normal file
82
libvips/convolution/pconvolution.h
Normal file
@ -0,0 +1,82 @@
|
||||
/* base class for all convolution operations
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Copyright (C) 1991-2005 The National Gallery
|
||||
|
||||
This library 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.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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 library; 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
|
||||
|
||||
*/
|
||||
|
||||
#ifndef VIPS_PCONVOLUTION_H
|
||||
#define VIPS_PCONVOLUTION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#include <vips/vector.h>
|
||||
|
||||
#define VIPS_TYPE_CONVOLUTION (vips_convolution_get_type())
|
||||
#define VIPS_CONVOLUTION( obj ) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST( (obj), \
|
||||
VIPS_TYPE_CONVOLUTION, VipsConvolution ))
|
||||
#define VIPS_CONVOLUTION_CLASS( klass ) \
|
||||
(G_TYPE_CHECK_CLASS_CAST( (klass), \
|
||||
VIPS_TYPE_CONVOLUTION, VipsConvolutionClass))
|
||||
#define VIPS_IS_CONVOLUTION( obj ) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE( (obj), VIPS_TYPE_CONVOLUTION ))
|
||||
#define VIPS_IS_CONVOLUTION_CLASS( klass ) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE( (klass), VIPS_TYPE_CONVOLUTION ))
|
||||
#define VIPS_CONVOLUTION_GET_CLASS( obj ) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS( (obj), \
|
||||
VIPS_TYPE_CONVOLUTION, VipsConvolutionClass ))
|
||||
|
||||
typedef struct _VipsConvolution VipsConvolution;
|
||||
|
||||
struct _VipsConvolution {
|
||||
VipsOperation parent_instance;
|
||||
|
||||
VipsImage *in;
|
||||
VipsImage *out;
|
||||
VipsImage *mask;
|
||||
|
||||
/* @mask cast ready for processing.
|
||||
*/
|
||||
VipsImage *M;
|
||||
};
|
||||
|
||||
typedef struct _VipsConvolutionClass {
|
||||
VipsOperationClass parent_class;
|
||||
|
||||
} VipsConvolutionClass;
|
||||
|
||||
GType vips_convolution_get_type( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif /*VIPS_PCONVOLUTION_H*/
|
||||
|
||||
|
@ -1,8 +1,4 @@
|
||||
/* base class for all histogram operations
|
||||
*
|
||||
* properties:
|
||||
* - one input image
|
||||
* - one output image
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -64,6 +64,7 @@ vips_scan_headers = \
|
||||
${top_srcdir}/libvips/include/vips/image.h \
|
||||
${top_srcdir}/libvips/include/vips/colour.h \
|
||||
${top_srcdir}/libvips/include/vips/operation.h \
|
||||
${top_srcdir}/libvips/include/vips/convolution.h \
|
||||
${top_srcdir}/libvips/include/vips/object.h
|
||||
|
||||
enumtypes.h: $(vips_scan_headers) Makefile
|
||||
|
@ -38,6 +38,21 @@
|
||||
extern "C" {
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
typedef enum {
|
||||
VIPS_PRECISION_INTEGER,
|
||||
VIPS_PRECISION_FLOAT,
|
||||
VIPS_PRECISION_APPROXIMATE
|
||||
} VipsPrecision;
|
||||
|
||||
int vips_conv( VipsImage *in, VipsImage **out, VipsImage *mask, ... )
|
||||
__attribute__((sentinel));
|
||||
|
||||
void vips_convolution_operation_init( void );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int im_aconvsep( VipsImage *in, VipsImage *out,
|
||||
DOUBLEMASK *mask, int n_layers );
|
||||
int im_aconv( VipsImage *in, VipsImage *out,
|
||||
|
@ -69,6 +69,9 @@ GType vips_intent_get_type (void) G_GNUC_CONST;
|
||||
/* enumerations from "../../../libvips/include/vips/operation.h" */
|
||||
GType vips_operation_flags_get_type (void) G_GNUC_CONST;
|
||||
#define VIPS_TYPE_OPERATION_FLAGS (vips_operation_flags_get_type())
|
||||
/* enumerations from "../../../libvips/include/vips/convolution.h" */
|
||||
GType vips_precision_get_type (void) G_GNUC_CONST;
|
||||
#define VIPS_TYPE_PRECISION (vips_precision_get_type())
|
||||
/* enumerations from "../../../libvips/include/vips/object.h" */
|
||||
GType vips_argument_flags_get_type (void) G_GNUC_CONST;
|
||||
#define VIPS_TYPE_ARGUMENT_FLAGS (vips_argument_flags_get_type())
|
||||
|
@ -47,8 +47,9 @@ vips_scan_headers = \
|
||||
${top_srcdir}/libvips/include/vips/arithmetic.h \
|
||||
${top_srcdir}/libvips/include/vips/util.h \
|
||||
${top_srcdir}/libvips/include/vips/image.h \
|
||||
${top_srcdir}/libvips/include/vips/operation.h \
|
||||
${top_srcdir}/libvips/include/vips/colour.h \
|
||||
${top_srcdir}/libvips/include/vips/operation.h \
|
||||
${top_srcdir}/libvips/include/vips/convolution.h \
|
||||
${top_srcdir}/libvips/include/vips/object.h
|
||||
|
||||
enumtypes.c: $(vips_scan_headers) Makefile
|
||||
|
@ -550,6 +550,26 @@ vips_access_get_type( void )
|
||||
|
||||
return( etype );
|
||||
}
|
||||
/* enumerations from "../../libvips/include/vips/colour.h" */
|
||||
GType
|
||||
vips_intent_get_type( void )
|
||||
{
|
||||
static GType etype = 0;
|
||||
|
||||
if( etype == 0 ) {
|
||||
static const GEnumValue values[] = {
|
||||
{VIPS_INTENT_PERCEPTUAL, "VIPS_INTENT_PERCEPTUAL", "perceptual"},
|
||||
{VIPS_INTENT_RELATIVE, "VIPS_INTENT_RELATIVE", "relative"},
|
||||
{VIPS_INTENT_SATURATION, "VIPS_INTENT_SATURATION", "saturation"},
|
||||
{VIPS_INTENT_ABSOLUTE, "VIPS_INTENT_ABSOLUTE", "absolute"},
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
etype = g_enum_register_static( "VipsIntent", values );
|
||||
}
|
||||
|
||||
return( etype );
|
||||
}
|
||||
/* enumerations from "../../libvips/include/vips/operation.h" */
|
||||
GType
|
||||
vips_operation_flags_get_type( void )
|
||||
@ -570,22 +590,21 @@ vips_operation_flags_get_type( void )
|
||||
|
||||
return( etype );
|
||||
}
|
||||
/* enumerations from "../../libvips/include/vips/colour.h" */
|
||||
/* enumerations from "../../libvips/include/vips/convolution.h" */
|
||||
GType
|
||||
vips_intent_get_type( void )
|
||||
vips_precision_get_type( void )
|
||||
{
|
||||
static GType etype = 0;
|
||||
|
||||
if( etype == 0 ) {
|
||||
static const GEnumValue values[] = {
|
||||
{VIPS_INTENT_PERCEPTUAL, "VIPS_INTENT_PERCEPTUAL", "perceptual"},
|
||||
{VIPS_INTENT_RELATIVE, "VIPS_INTENT_RELATIVE", "relative"},
|
||||
{VIPS_INTENT_SATURATION, "VIPS_INTENT_SATURATION", "saturation"},
|
||||
{VIPS_INTENT_ABSOLUTE, "VIPS_INTENT_ABSOLUTE", "absolute"},
|
||||
{VIPS_PRECISION_INTEGER, "VIPS_PRECISION_INTEGER", "integer"},
|
||||
{VIPS_PRECISION_FLOAT, "VIPS_PRECISION_FLOAT", "float"},
|
||||
{VIPS_PRECISION_APPROXIMATE, "VIPS_PRECISION_APPROXIMATE", "approximate"},
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
etype = g_enum_register_static( "VipsIntent", values );
|
||||
etype = g_enum_register_static( "VipsPrecision", values );
|
||||
}
|
||||
|
||||
return( etype );
|
||||
|
@ -255,6 +255,7 @@ vips_init( const char *argv0 )
|
||||
vips_resample_operation_init();
|
||||
vips_colour_operation_init();
|
||||
vips_histogram_operation_init();
|
||||
vips_convolution_operation_init();
|
||||
|
||||
/* Load up any plugins in the vips libdir. We don't error on failure,
|
||||
* it's too annoying to have VIPS refuse to start because of a broken
|
||||
|
Loading…
Reference in New Issue
Block a user