sort out sense of fourier filter masks

This commit is contained in:
John Cupitt 2014-07-15 09:05:00 +01:00
parent 1a76dad162
commit 235eb87aa5
5 changed files with 76 additions and 6 deletions

70
TODO
View File

@ -1,3 +1,73 @@
- butterworth highpass is wrong! actually makes a lowpass filter
$ ~/vips-7.26/bin/vips-7.26 vips im_create_fmask x2.v 32 32 2 42 0.5 0.5 0 0
is correct: a black circle on a white bg, with a white dot top left
2 because we have
vips7compat.h: IM_MASK_BUTTERWORTH_HIGHPASS = 2,
in vip8 this is
$ vips mask_butterworth x.v 32 32 42 0.5 0.5
generates a highpass filter, or
$ vips mask_butterworth x.v 32 32 42 0.5 0.5 --reject
for a lowpass filter
doesn't match ideal! there we have --reject to make a highpass filter
im_freq_mask has:
IM_MASK_IDEAL_HIGHPASS: 0
if( vips_mask_ideal(
IM_MASK_IDEAL_LOWPASS: 1
if( vips_mask_ideal( "reject", TRUE,
IM_MASK_BUTTERWORTH_HIGHPASS: 2
if( vips_mask_butterworth(
IM_MASK_BUTTERWORTH_LOWPASS: 3
if( vips_mask_butterworth( "reject", TRUE,
IM_MASK_GAUSS_HIGHPASS: 4
if( vips_mask_gaussian(
IM_MASK_GAUSS_LOWPASS: 5
if( vips_mask_gaussian( "reject", TRUE,
IM_MASK_IDEAL_RINGPASS: 6
if( vips_mask_ideal_ring(
IM_MASK_IDEAL_RINGREJECT: 7
if( vips_mask_ideal_ring( "reject", TRUE,
IM_MASK_BUTTERWORTH_RINGPASS: 8
if( vips_mask_butterworth_ring(
IM_MASK_BUTTERWORTH_RINGREJECT: 9
if( vips_mask_butterworth_ring( "reject", TRUE,
IM_MASK_GAUSS_RINGPASS: 10
if( vips_mask_gaussian_ring(
IM_MASK_GAUSS_RINGREJECT: 11
if( vips_mask_gaussian_ring( "reject", TRUE,
IM_MASK_IDEAL_BANDPASS: 12
if( vips_mask_ideal_ring(
IM_MASK_IDEAL_BANDREJECT: 13
if( vips_mask_ideal_ring( "reject", TRUE,
IM_MASK_BUTTERWORTH_BANDPASS: 14
if( vips_mask_butterworth_ring(
IM_MASK_BUTTERWORTH_BANDREJECT: 15
if( vips_mask_butterworth_ring( "reject", TRUE,
IM_MASK_GAUSS_BANDPASS: 16
if( vips_mask_gaussian_ring(
IM_MASK_GAUSS_BANDREJECT: 17
if( vips_mask_gaussian_ring( "reject", TRUE,
IM_MASK_FRACTAL_FLT: 18
// not implemented
- maxpos_avg seems to give variable results

View File

@ -64,7 +64,7 @@ vips_mask_gaussian_point( VipsMask *mask, double dx, double dy )
double fc2 = fc * fc;
double dist2 = (dx * dx + dy * dy) / fc2;
return( exp( cnst * dist2 ) );
return( 1.0 - exp( cnst * dist2 ) );
}
static void

View File

@ -62,7 +62,7 @@ vips_mask_ideal_point( VipsMask *mask, double dx, double dy )
double dist2 = dx * dx + dy * dy;
double fc2 = fc * fc;
return( dist2 <= fc2 ? 1.0 : 0.0 );
return( dist2 <= fc2 ? 0.0 : 1.0 );
}
static void

View File

@ -76,7 +76,7 @@ vips_mask_ideal_band_point( VipsMask *mask, double dx, double dy )
double d1 = (dx - fcx) * (dx - fcx) + (dy - fcy) * (dy - fcy);
double d2 = (dx + fcx) * (dx + fcx) + (dy + fcy) * (dy + fcy);
return( d1 < r2 || d2 < r2 ? 1.0 : 0.0 );
return( (d1 < r2 || d2 < r2) ? 1.0 : 0.0 );
}
static void

View File

@ -67,39 +67,39 @@ build_freq_mask( IMAGE *out, int xs, int ys, ImMaskType flag, va_list ap )
switch( flag ) {
case IM_MASK_IDEAL_HIGHPASS:
if( vips_mask_ideal( &t, xs, ys, p0,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_IDEAL_LOWPASS:
if( vips_mask_ideal( &t, xs, ys, p0,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_BUTTERWORTH_HIGHPASS:
if( vips_mask_butterworth( &t, xs, ys, p0, p1, p2,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_BUTTERWORTH_LOWPASS:
if( vips_mask_butterworth( &t, xs, ys, p0, p1, p2,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_GAUSS_HIGHPASS:
if( vips_mask_gaussian( &t, xs, ys, p0, p1,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_GAUSS_LOWPASS:
if( vips_mask_gaussian( &t, xs, ys, p0, p1,
"reject", TRUE,
NULL ) )
return( -1 );
break;