added im_gauss_dmask_sep()

This commit is contained in:
John Cupitt 2011-05-26 13:20:15 +01:00
parent 47a3bd6689
commit 10aecae374
4 changed files with 71 additions and 0 deletions

View File

@ -61,6 +61,7 @@
- vips7 binops all do sizealike too, also gbandjoin and ifthenelse
- new API is now functional
- vips.c generates GOption flags for vips8 operations
- added im_gauss_dmask_sep()
30/11/10 started 7.24.0
- bump for new stable

View File

@ -82,6 +82,8 @@ INTMASK *im_gauss_imask_sep( const char *filename,
double sigma, double min_ampl );
DOUBLEMASK *im_gauss_dmask( const char *filename,
double sigma, double min_ampl );
DOUBLEMASK *im_gauss_dmask_sep( const char *filename,
double sigma, double min_ampl );
INTMASK *im_dup_imask( INTMASK *in, const char *filename );
DOUBLEMASK *im_dup_dmask( DOUBLEMASK *in, const char *filename );

View File

@ -171,6 +171,46 @@ im_gauss_dmask( const char *filename, double sigma, double min_ampl )
return( m );
}
/**
* im_gauss_dmask_sep:
* @filename: the returned mask has this set as the filename
* @sigma: standard deviation of mask
* @min_ampl: minimum amplitude
*
* im_gauss_dmask_sep() works exactly as im_gauss_dmask(), but returns only
* the central line of the mask. This is useful with im_convsepf().
*
* See also: im_gauss_dmask(), im_convsepf().
*
* Returns: the calculated mask on success, or NULL on error.
*/
DOUBLEMASK *
im_gauss_dmask_sep( const char *filename, double sigma, double min_ampl )
{
DOUBLEMASK *im;
DOUBLEMASK *im2;
int i;
double sum;
if( !(im = im_gauss_dmask( filename, sigma, min_ampl )) )
return( NULL );
if( !(im2 = im_create_dmask( filename, im->xsize, 1 )) ) {
im_free_dmask( im );
return( NULL );
}
sum = 0;
for( i = 0; i < im->xsize; i++ ) {
im2->coeff[i] = im->coeff[i + im->xsize * (im->ysize / 2)];
sum += im2->coeff[i];
}
im2->scale = sum;
im_free_dmask( im );
return( im2 );
}
/**
* im_gauss_imask:
* @filename: the returned mask has this set as the filename

View File

@ -229,6 +229,33 @@ static im_function gauss_dmask_desc = {
gauss_dmask_args /* Arg list */
};
/* Call im_gauss_dmask_sep via arg vector.
*/
static int
gauss_dmask_sep_vec( im_object *argv )
{
im_mask_object *mo = argv[0];
double sigma = *((double *) argv[1]);
double min_amp = *((double *) argv[2]);
if( !(mo->mask =
im_gauss_dmask_sep( mo->name, sigma, min_amp )) )
return( -1 );
return( 0 );
}
/* Description of im_gauss_dmask_sep.
*/
static im_function gauss_dmask_sep_desc = {
"im_gauss_dmask_sep", /* Name */
"generate separable gaussian DOUBLEMASK",
0, /* Flags */
gauss_dmask_sep_vec, /* Dispatch function */
IM_NUMBER( gauss_dmask_args ), /* Size of arg list */
gauss_dmask_args /* Arg list */
};
/* Args for im_gauss_imask.
*/
static im_arg_desc gauss_imask_args[] = {
@ -549,6 +576,7 @@ static im_function dmask_ysize_desc = {
*/
static im_function *mask_list[] = {
&gauss_dmask_desc,
&gauss_dmask_sep_desc,
&log_dmask_desc,
&log_imask_desc,
&gauss_imask_desc,