/0 probs with masks

This commit is contained in:
John Cupitt 2010-03-28 09:56:49 +00:00
parent 9e04103bc4
commit 3d0aba1a89
7 changed files with 21 additions and 4 deletions

View File

@ -8,6 +8,7 @@
- added im_local_imask(), im_local_dmask()
- added im_mpercent_hist()
- im_maplut() casts the index image to one of the uint types
- fixed a couple of /0 problems with scale == 0 masks
16/1/10 started 7.21.2
- "invalidate" is careful to keep images alive, so invalidate callbacks can do

2
TODO
View File

@ -4,8 +4,6 @@
- quite a few hist operations have no GUI ... lhisteq, for example? or
histspec?
- conv with scale == 0 gives /0 error
- added im_local_imask(), im_local_dmask(), needs docs?
is local_imask() in the best place? shouldn't it be in mask.h?

View File

@ -29,7 +29,7 @@
* - reworked and simplified, about 10% faster
* - slightly better range clipping
* 27/7/01 JC
* - rejects masks with scale == 0
* - reject masks with scale == 0
* 7/4/04
* - im_conv() now uses im_embed() with edge stretching on the input, not
* the output
@ -419,6 +419,10 @@ im_conv_raw( IMAGE *in, IMAGE *out, INTMASK *mask )
im_check_noncomplex( "im_conv", in ) ||
im_check_imask( "im_conv", mask ) )
return( -1 );
if( mask->scale == 0 ) {
im_error( "im_conv", "%s", "mask scale must be non-zero" );
return( -1 );
}
if( !(conv = conv_new( in, out, mask )) )
return( -1 );

View File

@ -316,6 +316,10 @@ im_conv_f_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
im_check_noncomplex( "im_conv", in ) ||
im_check_dmask( "im_conv", mask ) )
return( -1 );
if( mask->scale == 0 ) {
im_error( "im_conv_f", "%s", "mask scale must be non-zero" );
return( -1 );
}
if( !(conv = conv_new( in, out, mask )) )
return( -1 );

View File

@ -381,6 +381,10 @@ im_convsep_raw( IMAGE *in, IMAGE *out, INTMASK *mask )
"%s", _( "expect 1xN or Nx1 input mask" ) );
return( -1 );
}
if( mask->scale == 0 ) {
im_error( "im_convsep", "%s", "mask scale must be non-zero" );
return( -1 );
}
if( !(conv = conv_new( in, out, mask )) )
return( -1 );

View File

@ -285,6 +285,10 @@ im_convsep_f_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask )
"%s", _( "expect 1xN or Nx1 input mask" ) );
return( -1 );
}
if( mask->scale == 0 ) {
im_error( "im_convsep_f", "%s", "mask scale must be non-zero" );
return( -1 );
}
if( !(conv = conv_new( in, out, mask )) )
return( -1 );

View File

@ -476,6 +476,8 @@ im_scale_dmask( DOUBLEMASK *m, const char *name )
if( dsum == m->scale )
out->scale = isum;
else if( dsum == 0.0 )
out->scale = 1.0;
else
out->scale = IM_RINT( m->scale * isum / dsum );
@ -486,7 +488,7 @@ void
im_norm_dmask( DOUBLEMASK *mask )
{
const int n = mask->xsize * mask->ysize;
const double scale = 1.0 / mask->scale;
const double scale = (mask->scale == 0) ? 0 : (1.0 / mask->scale);
int i;