rename aconv as aconvsep

This commit is contained in:
John Cupitt 2011-06-04 17:44:54 +01:00
parent 70dc170d97
commit 710294f889
5 changed files with 38 additions and 34 deletions

8
TODO
View File

@ -5,6 +5,14 @@
no error msg
- revisit orc conv
use an 8.8 accumulator ... build the scale into the 8.8 coeffs ... no div at
the end, just a shift
need 8.8 x 8.8 -> 8.8 for each coeff though
- also VipsFormat ... could this replace vips_image_new_from_string()? or
could we call this from vips_image_new_from_string()?

View File

@ -4,7 +4,7 @@ libconvolution_la_SOURCES = \
convol_dispatch.c \
im_addgnoise.c \
im_compass.c \
im_aconv.c \
im_aconvsep.c \
im_conv.c \
im_conv_f.c \
im_contrast_surface.c \

View File

@ -426,41 +426,41 @@ static im_function spcor_desc = {
two_in_one_out /* Arg list */
};
/* Args for im_aconv().
/* Args for im_aconvsep().
*/
static im_arg_desc aconv_args[] = {
static im_arg_desc aconvsep_args[] = {
IM_INPUT_IMAGE( "in" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_DMASK( "matrix" ),
IM_INPUT_INT( "n_layers" )
};
/* Call im_aconv via arg vector.
/* Call im_aconvsep via arg vector.
*/
static int
aconv_vec( im_object *argv )
aconvsep_vec( im_object *argv )
{
im_mask_object *mo = argv[2];
int n_layers = *((int *) argv[3]);
return( im_aconv( argv[0], argv[1], mo->mask, n_layers ) );
return( im_aconvsep( argv[0], argv[1], mo->mask, n_layers ) );
}
/* Description of im_aconv.
/* Description of im_aconvsep.
*/
static im_function aconv_desc = {
"im_aconv", /* Name */
static im_function aconvsep_desc = {
"im_aconvsep", /* Name */
"approximate convolution",
IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */
aconv_vec, /* Dispatch function */
IM_NUMBER( aconv_args ), /* Size of arg list */
aconv_args /* Arg list */
aconvsep_vec, /* Dispatch function */
IM_NUMBER( aconvsep_args ), /* Size of arg list */
aconvsep_args /* Arg list */
};
/* Package up all these functions.
*/
static im_function *convol_list[] = {
&aconv_desc,
&aconvsep_desc,
&addgnoise_desc,
&compass_desc,
&contrast_surface_desc,

View File

@ -1,4 +1,4 @@
/* im_aconv ... approximate convolution
/* im_aconvsep ... separable approximate convolution
*
* This operation does an approximate, seperable convolution.
*
@ -131,7 +131,7 @@ line_end( Lines *lines, int x )
lines->end[lines->n_lines] = x;
if( lines->n_lines >= MAX_LINES - 1 ) {
vips_error( "im_aconv", "%s", _( "mask too complex" ) );
vips_error( "im_aconvsep", "%s", _( "mask too complex" ) );
return( -1 );
}
lines->n_lines += 1;
@ -158,8 +158,8 @@ lines_new( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
/* Check parameters.
*/
if( im_piocheck( in, out ) ||
im_check_uncoded( "im_aconv", in ) ||
vips_check_dmask_1d( "im_aconv", mask ) )
im_check_uncoded( "im_aconvsep", in ) ||
vips_check_dmask_1d( "im_aconvsep", mask ) )
return( NULL );
if( !(lines = VIPS_NEW( out, Lines )) )
@ -587,13 +587,13 @@ lines_generate_vertical( REGION *or, void *vseq, void *a, void *b )
}
static int
aconv_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
aconvsep_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
{
Lines *lines;
im_generate_fn generate;
#ifdef DEBUG
printf( "aconv_raw: starting with matrix:\n" );
printf( "aconvsep_raw: starting with matrix:\n" );
im_print_dmask( mask );
#endif /*DEBUG*/
@ -608,7 +608,7 @@ aconv_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
out->Xsize -= mask->xsize - 1;
out->Ysize -= mask->ysize - 1;
if( out->Xsize <= 0 || out->Ysize <= 0 ) {
im_error( "im_aconv", "%s", _( "image too small for mask" ) );
im_error( "im_aconvsep", "%s", _( "image too small for mask" ) );
return( -1 );
}
@ -617,10 +617,6 @@ aconv_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
else
generate = lines_generate_horizontal;
/* Set demand hints. FATSTRIP is good for us, as THINSTRIP will cause
* too many recalculations on overlaps.
*/
//if( im_demand_hint( out, IM_FATSTRIP, in, NULL ) ||
if( im_demand_hint( out, IM_SMALLTILE, in, NULL ) ||
im_generate( out,
lines_start, generate, lines_stop, in, lines ) )
@ -633,14 +629,13 @@ aconv_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
}
/**
* im_aconv:
* im_aconvsep:
* @in: input image
* @out: output image
* @mask: convolution mask
* @n_layers: number of layers for approximation
*
* Perform a separable convolution of @in with @mask using approximate
* convolution.
* Perform an approximate separable convolution of @in with @mask.
*
* The mask must be 1xn or nx1 elements.
* The output image
@ -652,7 +647,7 @@ aconv_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
* Larger values for @n_layers give more accurate
* results, but are slower. As @n_layers approaches the mask radius, the
* accuracy will become close to exact convolution and the speed will drop to
* match. For many large masks, such as Gaussian, @n_layers can be only 10% of
* match. For many large masks, such as Gaussian, @n_layers need be only 10% of
* this value and accuracy will still be good.
*
* See also: im_convsep_f(), im_create_dmaskv().
@ -660,13 +655,13 @@ aconv_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
* Returns: 0 on success, -1 on error
*/
int
im_aconv( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
im_aconvsep( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
{
IMAGE *t[2];
const int n_mask = mask->xsize * mask->ysize;
DOUBLEMASK *rmask;
if( im_open_local_array( out, t, 2, "im_aconv", "p" ) ||
if( im_open_local_array( out, t, 2, "im_aconvsep", "p" ) ||
!(rmask = (DOUBLEMASK *) im_local( out,
(im_construct_fn) im_dup_dmask,
(im_callback_fn) im_free_dmask, mask, mask->filename, NULL )) )
@ -679,12 +674,12 @@ im_aconv( IMAGE *in, IMAGE *out, DOUBLEMASK *mask, int n_layers )
*/
if( im_embed( in, t[0], 1, n_mask / 2, n_mask / 2,
in->Xsize + n_mask - 1, in->Ysize + n_mask - 1 ) ||
aconv_raw( t[0], t[1], mask, n_layers ) ||
aconv_raw( t[1], out, rmask, n_layers ) )
aconvsep_raw( t[0], t[1], mask, n_layers ) ||
aconvsep_raw( t[1], out, rmask, n_layers ) )
return( -1 );
/* For testing .. just try one direction.
if( aconv_raw( in, out, mask, n_layers ) )
if( aconvsep_raw( in, out, mask, n_layers ) )
return( -1 );
*/

View File

@ -37,7 +37,8 @@
extern "C" {
#endif /*__cplusplus*/
int im_aconv( VipsImage *in, VipsImage *out, DOUBLEMASK *mask, int n_layers );
int im_aconvsep( VipsImage *in, VipsImage *out,
DOUBLEMASK *mask, int n_layers );
int im_conv( VipsImage *in, VipsImage *out, INTMASK *mask );
int im_conv_f( VipsImage *in, VipsImage *out, DOUBLEMASK *mask );
int im_convsep( VipsImage *in, VipsImage *out, INTMASK *mask );