diff --git a/TODO b/TODO index a6410d1a..dc6ed5fd 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,10 @@ +- im_spcor a.value a.value fails, argh + + nip2: im_prepare.c:324: im_prepare_to: + Assertion `clipped.left == r->left' failed. + +- doing im_create_fmask() and friends + - how about im_invalidate_area()? we currently repaint the whole window on every paint action in nip2 :-( diff --git a/doc/reference/libvips-docs.sgml.in b/doc/reference/libvips-docs.sgml.in index 51203085..a48bbd2f 100644 --- a/doc/reference/libvips-docs.sgml.in +++ b/doc/reference/libvips-docs.sgml.in @@ -39,6 +39,7 @@ + @@ -46,7 +47,6 @@ - @@ -66,7 +66,6 @@ - diff --git a/libvips/conversion/im_copy.c b/libvips/conversion/im_copy.c index b7137dba..e585ef28 100644 --- a/libvips/conversion/im_copy.c +++ b/libvips/conversion/im_copy.c @@ -170,7 +170,7 @@ im_copy_set_all( IMAGE *in, IMAGE *out, * * See also: im_copy(), im_copy_set(), im_copy_morph(). * - * Returns: 0 on success, -1 on error + * Returns: 0 on success, -1 on error. */ int im_copy( IMAGE *in, IMAGE *out ) @@ -193,7 +193,7 @@ im_copy( IMAGE *in, IMAGE *out ) * * See also: im_copy(). * - * Returns: 0 on success, -1 on error + * Returns: 0 on success, -1 on error. */ int im_copy_set( IMAGE *in, IMAGE *out, @@ -221,7 +221,7 @@ im_copy_set( IMAGE *in, IMAGE *out, * * See also: im_copy(). * - * Returns: 0 on success, -1 on error + * Returns: 0 on success, -1 on error. */ int im_copy_morph( IMAGE *in, IMAGE *out, @@ -244,7 +244,7 @@ im_copy_morph( IMAGE *in, IMAGE *out, * * See also: im_copy(). * - * Returns: 0 on success, -1 on error + * Returns: 0 on success, -1 on error. */ int im_copy_set_meta( IMAGE *in, IMAGE *out, const char *field, GValue *value ) @@ -316,7 +316,7 @@ im_copy_swap8_gen( PEL *in, PEL *out, int width, IMAGE *im ) * * See also: im_copy(), im_amiMSBfirst(), im_isMSBfirst(). * - * Returns: 0 on success, -1 on error + * Returns: 0 on success, -1 on error. */ int im_copy_swap( IMAGE *in, IMAGE *out ) @@ -375,7 +375,7 @@ im_copy_swap( IMAGE *in, IMAGE *out ) * * See also: im_copy_swap(), im_amiMSBfirst(). * - * Returns: 0 on success, -1 on error + * Returns: 0 on success, -1 on error. */ int im_copy_native( IMAGE *in, IMAGE *out, gboolean is_msb_first ) diff --git a/libvips/freq_filt/fmask4th.c b/libvips/freq_filt/fmask4th.c index c9e77767..29100187 100644 --- a/libvips/freq_filt/fmask4th.c +++ b/libvips/freq_filt/fmask4th.c @@ -74,7 +74,6 @@ #include #include -#include #ifdef WITH_DMALLOC #include @@ -735,7 +734,7 @@ fractal_flt( IMAGE *out, int xs, int ys, double frdim ) */ float * -im__create_quarter( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) +im__create_quarter( IMAGE *out, int xs, int ys, VipsMaskType flag, va_list ap ) { /* May be fewer than 4 args ... but extract them all anyway. Should be * safe. @@ -748,47 +747,47 @@ im__create_quarter( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) switch( flag ) { /* High pass - low pass */ - case MASK_IDEAL_HIGHPASS: + case VIPS_MASK_IDEAL_HIGHPASS: return( ideal_hpf( out, xs, ys, p0 ) ); - case MASK_IDEAL_LOWPASS: + case VIPS_MASK_IDEAL_LOWPASS: return( ideal_lpf( out, xs, ys, p0 ) ); - case MASK_BUTTERWORTH_HIGHPASS: + case VIPS_MASK_BUTTERWORTH_HIGHPASS: return( butterworth_hpf( out, xs, ys, p0, p1, p2 ) ); - case MASK_BUTTERWORTH_LOWPASS: + case VIPS_MASK_BUTTERWORTH_LOWPASS: return( butterworth_lpf( out, xs, ys, p0, p1, p2 ) ); - case MASK_GAUSS_HIGHPASS: + case VIPS_MASK_GAUSS_HIGHPASS: return( gaussian_hpf( out, xs, ys, p0, p1 ) ); - case MASK_GAUSS_LOWPASS: + case VIPS_MASK_GAUSS_LOWPASS: return( gaussian_lpf( out, xs, ys, p0, p1 ) ); /* Ring pass - ring reject. */ - case MASK_IDEAL_RINGPASS: + case VIPS_MASK_IDEAL_RINGPASS: return( ideal_rpf( out, xs, ys, p0, p1 ) ); - case MASK_IDEAL_RINGREJECT: + case VIPS_MASK_IDEAL_RINGREJECT: return( ideal_rrf( out, xs, ys, p0, p1 ) ); - case MASK_BUTTERWORTH_RINGPASS: + case VIPS_MASK_BUTTERWORTH_RINGPASS: return( butterworth_rpf( out, xs, ys, p0, p1, p2, p3 ) ); - case MASK_BUTTERWORTH_RINGREJECT: + case VIPS_MASK_BUTTERWORTH_RINGREJECT: return( butterworth_rrf( out, xs, ys, p0, p1, p2, p3 ) ); - case MASK_GAUSS_RINGPASS: + case VIPS_MASK_GAUSS_RINGPASS: return( gaussian_rpf( out, xs, ys, p0, p1, p2 ) ); - case MASK_GAUSS_RINGREJECT: + case VIPS_MASK_GAUSS_RINGREJECT: return( gaussian_rrf( out, xs, ys, p0, p1, p2 ) ); - case MASK_FRACTAL_FLT: + case VIPS_MASK_FRACTAL_FLT: return( fractal_flt( out, xs, ys, p0 ) ); default: diff --git a/libvips/freq_filt/fmaskcir.c b/libvips/freq_filt/fmaskcir.c index 09b9fc48..a87cc402 100644 --- a/libvips/freq_filt/fmaskcir.c +++ b/libvips/freq_filt/fmaskcir.c @@ -65,7 +65,6 @@ #include #include -#include #ifdef WITH_DMALLOC #include @@ -623,7 +622,7 @@ gaussian_brf( IMAGE *out, double fcx, double fcy, double r, double ac ) * however all masks are written as floats with maximum value normalised to 1.0 */ int -im__fmaskcir( IMAGE *out, MaskType flag, va_list ap ) +im__fmaskcir( IMAGE *out, VipsMaskType flag, va_list ap ) { /* May be fewer than 5 args ... but extract them all anyway. Should be * safe. @@ -637,22 +636,22 @@ im__fmaskcir( IMAGE *out, MaskType flag, va_list ap ) switch( flag ) { /* Band pass - band reject. */ - case MASK_IDEAL_BANDPASS: + case VIPS_MASK_IDEAL_BANDPASS: return( ideal_bpf( out, p0, p1, p2 ) ); - case MASK_IDEAL_BANDREJECT: + case VIPS_MASK_IDEAL_BANDREJECT: return( ideal_brf( out, p0, p1, p2 ) ); - case MASK_BUTTERWORTH_BANDPASS: + case VIPS_MASK_BUTTERWORTH_BANDPASS: return( butterworth_bpf( out, p0, p1, p2, p3, p4 ) ); - case MASK_BUTTERWORTH_BANDREJECT: + case VIPS_MASK_BUTTERWORTH_BANDREJECT: return( butterworth_brf( out, p0, p1, p2, p3, p4 ) ); - case MASK_GAUSS_BANDPASS: + case VIPS_MASK_GAUSS_BANDPASS: return( gaussian_bpf( out, p0, p1, p2, p3 ) ); - case MASK_GAUSS_BANDREJECT: + case VIPS_MASK_GAUSS_BANDREJECT: return( gaussian_brf( out, p0, p1, p2, p3 ) ); default: diff --git a/libvips/freq_filt/freq_dispatch.c b/libvips/freq_filt/freq_dispatch.c index 950d78cd..96960111 100644 --- a/libvips/freq_filt/freq_dispatch.c +++ b/libvips/freq_filt/freq_dispatch.c @@ -40,7 +40,6 @@ #include #include -#include #ifdef WITH_DMALLOC #include diff --git a/libvips/freq_filt/im_disp_ps.c b/libvips/freq_filt/im_disp_ps.c index 7d111205..3bf5a4bc 100644 --- a/libvips/freq_filt/im_disp_ps.c +++ b/libvips/freq_filt/im_disp_ps.c @@ -1,16 +1,4 @@ -/* @(#) Makes a displayable uchar power spectrum of an input one band image - * @(#) Input should be float complex - * @(#) All images are kept in RAM; so only square arrays of powers of - * @(#) 2 as inputs. - * @(#) Functions im_fwfft, im_c2ps, im_scaleps and im_rotquad are used - * @(#) Image descriptors should have been set properly by the calling program - * @(#) - * @(#) int im_disp_ps(in, out) - * @(#) IMAGE *in, *out; - * @(#) int bandno; - * @(#) - * @(#) Returns 0 on sucess and -1 on error - * @(#) +/* im_disp_ps * * Copyright: 1991, N. Dessipris. * @@ -25,6 +13,9 @@ * - frees memory more quickly * 2/4/02 JC * - any number of bands + * 7/2/10 + * - gtkdoc + * - cleanups */ /* @@ -75,27 +66,40 @@ disp_ps( IMAGE *dummy, IMAGE *in, IMAGE *out ) if( im_open_local_array( out, t, 3, "im_disp_ps temp 1", "p" ) ) return( -1 ); - if( in->BandFmt == IM_BANDFMT_COMPLEX ) { - if( im_abs( in, t[1] ) ) - return( -1 ); - } - else { - if( im_fwfft( in, t[0] ) || im_abs( t[0], t[1] ) ) + if( in->BandFmt != IM_BANDFMT_COMPLEX ) { + if( im_fwfft( in, t[0] ) ) return( -1 ); + in = t[0]; } - if( im_scaleps( t[1], t[2] ) || im_rotquad( t[2], out ) ) + if( im_abs( in, t[1] ) || + im_scaleps( t[1], t[2] ) || + im_rotquad( t[2], out ) ) return( -1 ); return( 0 ); } +/** + * im_disp_ps: + * @in: input image + * @out: output image + * + * Make a displayable (ie. 8-bit unsigned int) power spectrum. + * + * If @in is non-complex, it is transformed to Fourier space. Then the + * absolute value is passed through im_scaleps(), and im_rotquad(). + * + * See also: im_scaleps(), im_rotquad(). + * + * Returns: 0 on success, -1 on error. + */ int im_disp_ps( IMAGE *in, IMAGE *out ) { - IMAGE *dummy = im_open( "memory:1", "p" ); + IMAGE *dummy; - if( !dummy ) + if( !(dummy = im_open( "memory:1", "p" )) ) return( -1 ); if( disp_ps( dummy, in, out ) ) { im_close( dummy ); diff --git a/libvips/freq_filt/im_fractsurf.c b/libvips/freq_filt/im_fractsurf.c index 3fe31a4d..7b73b086 100644 --- a/libvips/freq_filt/im_fractsurf.c +++ b/libvips/freq_filt/im_fractsurf.c @@ -1,14 +1,4 @@ -/* @(#) Creates a vasari fractal surface of a given dimension by - * @(#) filtering white gaussian noise (function im_gaussnoise(3X)) - * @(#) using the function im_fltimage_freq(3X) - * @(#) - * @(#) Usage: - * @(#) int im_fractsurf(im, frd, size) - * @(#) double frd; - * @(#) int size; - * @(#) - * @(#) Returns 0 on sucess and -1 on error - * @(#) +/* im_fractsurf * * Copyright: 1991, N. Dessipris. * @@ -17,6 +7,9 @@ * Modified on: * 20/9/95 JC * - modernised, a little + * 7/2/10 + * - cleanups + * - gtkdoc */ /* @@ -55,33 +48,38 @@ #include #include -#include /* for MASK_FRACTAL_FLT */ #ifdef WITH_DMALLOC #include #endif /*WITH_DMALLOC*/ +/** + * im_fractsurf: + * @out: output image + * @size: size of image to generate + * @frd: fractal dimension + * + * Generate an image of size @size and fractal dimension @frd. The dimension + * should be between 2 and 3. + * + * See also: im_gaussnoise(), im_flt_image_freq(). + * + * Returns: 0 on success, -1 on error. + */ int im_fractsurf( IMAGE *out, int size, double frd ) { - IMAGE *noise = im_open_local( out, "noise.v", "p" ); + IMAGE *noise; - if( !noise ) - return( -1 ); if( frd <= 2.0 || frd >= 3.0 ) { im_error( "im_fractsurf", "%s", _( "dimension shuld be in (2,3)" ) ); return( -1 ); } - if( im_gaussnoise( noise, size, size, 0.0, 1.0 ) ) - return( -1 ); - - /* create the fractal filter mask, and perform filtering on noise - * Note that the result is in im, stored as float since - * the original noise is in float. It needs scaling for display - */ - if( im_flt_image_freq( noise, out, MASK_FRACTAL_FLT, frd ) ) + if( !(noise = im_open_local( out, "im_fractsurf", "p" )) || + im_gaussnoise( noise, size, size, 0.0, 1.0 ) || + im_flt_image_freq( noise, out, VIPS_MASK_FRACTAL_FLT, frd ) ) return( -1 ); return( 0 ); diff --git a/libvips/freq_filt/im_freq_mask.c b/libvips/freq_filt/im_freq_mask.c index fb788fff..d07fd3c8 100644 --- a/libvips/freq_filt/im_freq_mask.c +++ b/libvips/freq_filt/im_freq_mask.c @@ -80,7 +80,7 @@ #include #include -#include +#include #ifdef WITH_DMALLOC #include @@ -134,11 +134,11 @@ copy_quarter( IMAGE *out, float *coeff_s ) /* Make a mask image. */ static int -build_freq_mask( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) +build_freq_mask( IMAGE *out, int xs, int ys, VipsMaskType flag, va_list ap ) { float *coeff; extern float *im__create_quarter( IMAGE *, - int, int, MaskType, va_list ); + int, int, VipsMaskType, va_list ); /* Check sizes and create one quarter of the final mask */ @@ -156,21 +156,21 @@ build_freq_mask( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) return( -1 ); switch( flag ) { - case MASK_IDEAL_HIGHPASS: - case MASK_IDEAL_LOWPASS: - case MASK_BUTTERWORTH_HIGHPASS: - case MASK_BUTTERWORTH_LOWPASS: - case MASK_GAUSS_HIGHPASS: - case MASK_GAUSS_LOWPASS: + case VIPS_MASK_IDEAL_HIGHPASS: + case VIPS_MASK_IDEAL_LOWPASS: + case VIPS_MASK_BUTTERWORTH_HIGHPASS: + case VIPS_MASK_BUTTERWORTH_LOWPASS: + case VIPS_MASK_GAUSS_HIGHPASS: + case VIPS_MASK_GAUSS_LOWPASS: - case MASK_IDEAL_RINGPASS: - case MASK_IDEAL_RINGREJECT: - case MASK_BUTTERWORTH_RINGPASS: - case MASK_BUTTERWORTH_RINGREJECT: - case MASK_GAUSS_RINGPASS: - case MASK_GAUSS_RINGREJECT: + case VIPS_MASK_IDEAL_RINGPASS: + case VIPS_MASK_IDEAL_RINGREJECT: + case VIPS_MASK_BUTTERWORTH_RINGPASS: + case VIPS_MASK_BUTTERWORTH_RINGREJECT: + case VIPS_MASK_GAUSS_RINGPASS: + case VIPS_MASK_GAUSS_RINGREJECT: - case MASK_FRACTAL_FLT: + case VIPS_MASK_FRACTAL_FLT: /* All these are created as a quarter and duplicated. */ if( !(coeff = im__create_quarter( out, xs, ys, flag, ap )) || @@ -178,12 +178,12 @@ build_freq_mask( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) return( -1 ); break; - case MASK_IDEAL_BANDPASS: - case MASK_IDEAL_BANDREJECT: - case MASK_BUTTERWORTH_BANDPASS: - case MASK_BUTTERWORTH_BANDREJECT: - case MASK_GAUSS_BANDPASS: - case MASK_GAUSS_BANDREJECT: + case VIPS_MASK_IDEAL_BANDPASS: + case VIPS_MASK_IDEAL_BANDREJECT: + case VIPS_MASK_BUTTERWORTH_BANDPASS: + case VIPS_MASK_BUTTERWORTH_BANDREJECT: + case VIPS_MASK_GAUSS_BANDPASS: + case VIPS_MASK_GAUSS_BANDREJECT: /* Created all in one go. */ if( im__fmaskcir( out, flag, ap ) ) @@ -201,7 +201,7 @@ build_freq_mask( IMAGE *out, int xs, int ys, MaskType flag, va_list ap ) /* Create a mask, and filter an image with it. */ int -im_flt_image_freq( IMAGE *in, IMAGE *out, MaskType flag, ... ) +im_flt_image_freq( IMAGE *in, IMAGE *out, VipsMaskType flag, ... ) { IMAGE *mask = im_open_local( out, "tempmask", "p" ); va_list ap; @@ -225,7 +225,7 @@ im_flt_image_freq( IMAGE *in, IMAGE *out, MaskType flag, ... ) /* Create a filter mask. */ int -im_create_fmask( IMAGE *out, int xsize, int ysize, MaskType flag, ... ) +im_create_fmask( IMAGE *out, int xsize, int ysize, VipsMaskType flag, ... ) { va_list ap; diff --git a/libvips/freq_filt/im_freqflt.c b/libvips/freq_filt/im_freqflt.c index 3fa1d38c..53c9b83e 100644 --- a/libvips/freq_filt/im_freqflt.c +++ b/libvips/freq_filt/im_freqflt.c @@ -71,6 +71,22 @@ #include #endif /*WITH_DMALLOC*/ +/** + * im_freqflt: + * @in: input image + * @mask: mask image + * @out: output image + * + * Filter an image in Fourier space. + * + * @in is transformed to Fourier space, multipled with the mask image, then + * transformed back to real space. If @in is already a complex image, just + * multiply then inverse transform. + * + * See also: im_invfftr(), im_create_fmask(). + * + * Returns: 0 on success, -1 on error. + */ int im_freqflt( IMAGE *in, IMAGE *mask, IMAGE *out ) { diff --git a/libvips/freq_filt/im_fwfft.c b/libvips/freq_filt/im_fwfft.c index 0d1e117e..8116773a 100644 --- a/libvips/freq_filt/im_fwfft.c +++ b/libvips/freq_filt/im_fwfft.c @@ -1,11 +1,4 @@ -/* @(#) Does a forward fft on an input image descriptor - * @(#) using the function fft_sp. (float fft) - * @(#) Input can be any complex or no-complex; output is complex (two floats) - * @(#) - * @(#) Usage: - * @(#) int im_fwfft(in, out) - * @(#) IMAGE *in, *out; - * @(#) +/* im_fwfft * * Copyright: 1990, N. Dessipris. * @@ -34,6 +27,9 @@ * non-square images, including odd widths and heights * 3/11/04 * - added fftw3 support + * 7/2/10 + * - cleanups + * - gtkdoc */ /* @@ -575,54 +571,52 @@ fwfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) int im__fftproc( IMAGE *dummy, IMAGE *in, IMAGE *out, im__fftproc_fn fn ) { - if( im_pincheck( in ) || im_outcheck( out ) ) - return( -1 ); - - if( in->Bands == 1 ) { - if( fn( dummy, in, out ) ) + IMAGE **bands; + IMAGE **fft; + int b; + + if( in->Bands == 1 ) + return( fn( dummy, in, out ) ); + + if( !(bands = IM_ARRAY( dummy, in->Bands, IMAGE * )) || + !(fft = IM_ARRAY( dummy, in->Bands, IMAGE * )) || + im_open_local_array( dummy, bands, in->Bands, "bands", "p" ) || + im_open_local_array( dummy, fft, in->Bands, "fft", "p" ) ) + return( -1 ); + + for( b = 0; b < in->Bands; b++ ) + if( im_extract_band( in, bands[b], b ) || + fn( dummy, bands[b], fft[b] ) ) return( -1 ); - } - else { - IMAGE *acc; - int b; - for( acc = NULL, b = 0; b < in->Bands; b++ ) { - IMAGE *t1 = im_open_local( dummy, - "fwfftn:1", "p" ); - IMAGE *t2 = im_open_local( dummy, - "fwfftn:2", "p" ); - - if( !t1 || !t2 || - im_extract_band( in, t1, b ) || - fn( dummy, t1, t2 ) ) - return( -1 ); - - if( !acc ) - acc = t2; - else { - IMAGE *t3 = im_open_local( dummy, - "fwfftn:3", "p" ); - - if( !t3 || im_bandjoin( acc, t2, t3 ) ) - return( -1 ); - - acc = t3; - } - } - - if( im_copy( acc, out ) ) - return( -1 ); - } + if( im_gbandjoin( fft, out, in->Bands ) ) + return( -1 ); return( 0 ); } +/** + * im_fwfft: + * @in: input image + * @out: output image + * + * Transform an image to Fourier space. + * + * VIPS uses the fftw3 or fftw2 Fourier transform libraries if possible. If + * they were not available when VIPS was built, it falls back to it's own + * FFT functions which are slow and only work for square images whose sides + * are a power of two. + * + * See also: im_invfft(), im_disp_ps(). + * + * Returns: 0 on success, -1 on error. + */ int im_fwfft( IMAGE *in, IMAGE *out ) { - IMAGE *dummy = im_open( "im_fwfft:1", "p" ); + IMAGE *dummy; - if( !dummy ) + if( !(dummy = im_open( "im_fwfft:1", "p" )) ) return( -1 ); if( im__fftproc( dummy, in, out, fwfft1 ) ) { im_close( dummy ); diff --git a/libvips/freq_filt/im_invfft.c b/libvips/freq_filt/im_invfft.c index 052c8eca..497e4324 100644 --- a/libvips/freq_filt/im_invfft.c +++ b/libvips/freq_filt/im_invfft.c @@ -1,11 +1,4 @@ -/* @(#) Does a inverse fft on an input image descriptor - * @(#) using the function fft_sp. - * @(#) Input complex (2 floats) output complex (2 floats) - * @(#) - * @(#) Usage: - * @(#) int im_invfft(in, out) - * @(#) IMAGE *in, *out; - * @(#) +/* im_invfft * * Copyright: 1990, N. Dessipris. * @@ -26,6 +19,8 @@ * - oops, fix for segv on wider than high fftw transforms * 3/11/04 * - added fftw3 support + * 7/2/10 + * - gtkdoc */ /* @@ -263,6 +258,24 @@ invfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) #endif /*HAVE_FFTW3*/ #endif /*HAVE_FFTW*/ + +/** + * im_invfft: + * @in: input image + * @out: output image + * + * Transform an image from Fourier space to real space. The result is complex. + * If you are OK with a real result, use im_invfftr() instead, it's quicker. + * + * VIPS uses the fftw3 or fftw2 Fourier transform libraries if possible. If + * they were not available when VIPS was built, it falls back to it's own + * FFT functions which are slow and only work for square images whose sides + * are a power of two. + * + * See also: im_invfftr(), im_fwfft(), im_disp_ps(). + * + * Returns: 0 on success, -1 on error. + */ int im_invfft( IMAGE *in, IMAGE *out ) { diff --git a/libvips/freq_filt/im_invfftr.c b/libvips/freq_filt/im_invfftr.c index a26be466..9ef8c33a 100644 --- a/libvips/freq_filt/im_invfftr.c +++ b/libvips/freq_filt/im_invfftr.c @@ -1,10 +1,4 @@ -/* @(#) Does a inverse fft on an input image descriptor - * @(#) Input complex (2 floats) output real - * @(#) - * @(#) Usage: - * @(#) int im_invfftr(in, out) - * @(#) IMAGE *in, *out; - * @(#) +/* im_invfftr * * Modified on : * 27/2/03 JC @@ -13,6 +7,8 @@ * - oops, fix for segv on wider than high fftw transforms * 3/11/04 * - added fftw3 support + * 7/2/10 + * - gtkdoc */ /* @@ -310,6 +306,23 @@ invfft1( IMAGE *dummy, IMAGE *in, IMAGE *out ) #endif /*HAVE_FFTW3*/ #endif /*HAVE_FFTW*/ +/** + * im_invfftr: + * @in: input image + * @out: output image + * + * Transform an image from Fourier space to real space, giving a real result. + * This is faster than im_invfft(), which gives a complex result. + * + * VIPS uses the fftw3 or fftw2 Fourier transform libraries if possible. If + * they were not available when VIPS was built, it falls back to it's own + * FFT functions which are slow and only work for square images whose sides + * are a power of two. + * + * See also: im_invfft(), im_fwfft(), im_disp_ps(). + * + * Returns: 0 on success, -1 on error. + */ int im_invfftr( IMAGE *in, IMAGE *out ) { diff --git a/libvips/freq_filt/im_phasecor_fft.c b/libvips/freq_filt/im_phasecor_fft.c index fd3a3b4b..286d2fb5 100644 --- a/libvips/freq_filt/im_phasecor_fft.c +++ b/libvips/freq_filt/im_phasecor_fft.c @@ -4,6 +4,9 @@ * * Author: Tom Vajzovic * Written on: 2008-01-16 + * 7/2/10 + * - cleanups + * - gtkdoc */ /* @@ -44,20 +47,14 @@ #endif /*WITH_DMALLOC*/ int im_phasecor_fft( IMAGE *in1, IMAGE *in2, IMAGE *out ){ -#define FUNCTION_NAME "im_fft_phasecor" - IMAGE *temp1= im_open_local( out, FUNCTION_NAME ": temp1", "t" ); - IMAGE *temp2= im_open_local( out, FUNCTION_NAME ": temp2", "t" ); - IMAGE *temp3= im_open_local( out, FUNCTION_NAME ": temp3", "t" ); + IMAGE *t[3]; - if( ! temp1 || ! temp2 || ! temp3 ) + if( im_open_local_array( out, t, 3, "im_phasecor_fft", "p" ) || + im_fwfft( in1, t[0] ) || + im_fwfft( in2, t[1] ) || + im_cross_phase( t[0], t[1], t[2] ) || + im_invfftr( t[2], out ) ) return -1; - return im_incheck( in1 ) - || im_incheck( in2 ) - || im_outcheck( out ) - || im_fwfft( in1, temp1 ) - || im_fwfft( in2, temp2 ) - || im_cross_phase( temp1, temp2, temp3 ) - || im_invfftr( temp3, out ); -#undef FUNCTION_NAME + return 0; } diff --git a/libvips/include/vips/Makefile.am b/libvips/include/vips/Makefile.am index 4275376c..51d1209f 100644 --- a/libvips/include/vips/Makefile.am +++ b/libvips/include/vips/Makefile.am @@ -13,7 +13,6 @@ pkginclude_HEADERS = \ dispatch.h \ disp.h \ error.h \ - fmask.h \ format.h \ inplace.h \ generate.h \ diff --git a/libvips/include/vips/deprecated.h b/libvips/include/vips/deprecated.h index 50e6d3a2..61a84d7f 100644 --- a/libvips/include/vips/deprecated.h +++ b/libvips/include/vips/deprecated.h @@ -280,6 +280,31 @@ typedef enum { gboolean im_isnative( im_arch_type arch ); int im_copy_from( IMAGE *in, IMAGE *out, im_arch_type architecture ); +#define MASK_IDEAL_HIGHPASS VIPS_MASK_IDEAL_HIGHPASS +#define MASK_IDEAL_LOWPASS VIPS_MASK_IDEAL_LOWPASS +#define MASK_BUTTERWORTH_HIGHPASS VIPS_MASK_BUTTERWORTH_HIGHPASS +#define MASK_BUTTERWORTH_LOWPASS VIPS_MASK_BUTTERWORTH_LOWPASS +#define MASK_GAUSS_HIGHPASS VIPS_MASK_GAUSS_HIGHPASS +#define MASK_GAUSS_LOWPASS VIPS_MASK_GAUSS_LOWPASS + +#define MASK_IDEAL_RINGPASS VIPS_MASK_IDEAL_RINGPASS +#define MASK_IDEAL_RINGREJECT VIPS_MASK_IDEAL_RINGREJECT +#define MASK_BUTTERWORTH_RINGPASS VIPS_MASK_BUTTERWORTH_RINGPASS +#define MASK_BUTTERWORTH_RINGREJECT VIPS_MASK_BUTTERWORTH_RINGREJECT +#define MASK_GAUSS_RINGPASS VIPS_MASK_GAUSS_RINGPASS +#define MASK_GAUSS_RINGREJECT VIPS_MASK_GAUSS_RINGREJECT + +#define MASK_IDEAL_BANDPASS VIPS_MASK_IDEAL_BANDPASS +#define MASK_IDEAL_BANDREJECT VIPS_MASK_IDEAL_BANDREJECT +#define MASK_BUTTERWORTH_BANDPASS VIPS_MASK_BUTTERWORTH_BANDPASS +#define MASK_BUTTERWORTH_BANDREJECT VIPS_MASK_BUTTERWORTH_BANDREJECT +#define MASK_GAUSS_BANDPASS VIPS_MASK_GAUSS_BANDPASS +#define MASK_GAUSS_BANDREJECT VIPS_MASK_GAUSS_BANDREJECT + +#define MASK_FRACTAL_FLT VIPS_MASK_FRACTAL_FLT + +#define MaskType VipsMaskType + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/fmask.h b/libvips/include/vips/fmask.h deleted file mode 100644 index 49e1ebd5..00000000 --- a/libvips/include/vips/fmask.h +++ /dev/null @@ -1,86 +0,0 @@ -/* @(#) Typical filter function - * va_list is filter parameters - * lowpass highpass filters - * flag = 0 -> idealhpf, parameters: frequency cutoff - * flag = 1 -> ideallpf, parameters: frequency cutoff - * flag = 2 -> buthpf, parameters: order, frequency cutoff, amplitude cutoff - * flag = 3 -> butlpf, parameters: order, frequency cutoff, amplitude cutoff - * flag = 4 -> gaussianlpf, parameters: frequency cutoff, amplitude cutoff - * flag = 5 -> gaussianhpf, parameters: frequency cutoff, amplitude cutoff - * ring pass ring reject filters - * flag = 6 -> idealrpf, parameters: frequency cutoff, width - * flag = 7 -> idealrrf, parameters: frequency cutoff, width - * flag = 8 -> butrpf, parameters: order, freq cutoff, width, ampl cutoff - * flag = 9 -> butrrf, parameters: order, freq cutoff, width, ampl cutoff - * flag = 10 -> gaussianrpf, parameters: frequency cutoff, width, ampl cutoff - * flag = 11 -> gaussianrrf, parameters: frequency cutoff, width, ampl cutoff - * bandpass bandreject filters - * flag = 12 -> idealbpf, parameters: center frequency, 2*radius - * flag = 13 -> idealbrf, parameters: centre frequency, 2*radius - * flag = 14 -> butbpf, parameters: order, frequency, 2*radius, ampl cutoff - * flag = 15 -> butbrf, parameters: order, frequency, 2*radius, ampl cutoff - * flag = 16 -> gaussianbpf, parameters: frequency cutoff, width, ampl cutoff - * flag = 17 -> gaussianbrf, parameters: frequency cutoff, width, ampl cutoff - * fractal filters (for filtering gaussian noises only) - * flag = 18 -> fractal, parameters: fractal dimension - */ - -/* - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - */ - -/* - - These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk - - */ - -#ifndef IM_FMASK_H -#define IM_FMASK_H - -typedef enum mask_type { - MASK_IDEAL_HIGHPASS = 0, - MASK_IDEAL_LOWPASS = 1, - MASK_BUTTERWORTH_HIGHPASS = 2, - MASK_BUTTERWORTH_LOWPASS = 3, - MASK_GAUSS_HIGHPASS = 4, - MASK_GAUSS_LOWPASS = 5, - - MASK_IDEAL_RINGPASS = 6, - MASK_IDEAL_RINGREJECT = 7, - MASK_BUTTERWORTH_RINGPASS = 8, - MASK_BUTTERWORTH_RINGREJECT = 9, - MASK_GAUSS_RINGPASS = 10, - MASK_GAUSS_RINGREJECT = 11, - - MASK_IDEAL_BANDPASS = 12, - MASK_IDEAL_BANDREJECT = 13, - MASK_BUTTERWORTH_BANDPASS = 14, - MASK_BUTTERWORTH_BANDREJECT = 15, - MASK_GAUSS_BANDPASS = 16, - MASK_GAUSS_BANDREJECT = 17, - - MASK_FRACTAL_FLT = 18 -} MaskType; - -int im_flt_image_freq( IMAGE *in, IMAGE *out, MaskType flag, ... ); -int im_create_fmask( IMAGE *out, int xsize, int ysize, MaskType flag, ... ); -int im__fmaskcir( IMAGE *out, MaskType flag, va_list ap ); - -#endif /*IM_FMASK_H*/ diff --git a/libvips/include/vips/freq_filt.h b/libvips/include/vips/freq_filt.h index f55d9f2a..dacd6648 100644 --- a/libvips/include/vips/freq_filt.h +++ b/libvips/include/vips/freq_filt.h @@ -37,15 +37,44 @@ extern "C" { #endif /*__cplusplus*/ -int im_fractsurf( IMAGE *out, int size, double frd ); -int im_freqflt( IMAGE *in, IMAGE *mask, IMAGE *out ); -int im_disp_ps( IMAGE *in, IMAGE *out ); -int im_rotquad( IMAGE *in, IMAGE *out ); +typedef enum { + VIPS_MASK_IDEAL_HIGHPASS = 0, + VIPS_MASK_IDEAL_LOWPASS = 1, + VIPS_MASK_BUTTERWORTH_HIGHPASS = 2, + VIPS_MASK_BUTTERWORTH_LOWPASS = 3, + VIPS_MASK_GAUSS_HIGHPASS = 4, + VIPS_MASK_GAUSS_LOWPASS = 5, + + VIPS_MASK_IDEAL_RINGPASS = 6, + VIPS_MASK_IDEAL_RINGREJECT = 7, + VIPS_MASK_BUTTERWORTH_RINGPASS = 8, + VIPS_MASK_BUTTERWORTH_RINGREJECT = 9, + VIPS_MASK_GAUSS_RINGPASS = 10, + VIPS_MASK_GAUSS_RINGREJECT = 11, + + VIPS_MASK_IDEAL_BANDPASS = 12, + VIPS_MASK_IDEAL_BANDREJECT = 13, + VIPS_MASK_BUTTERWORTH_BANDPASS = 14, + VIPS_MASK_BUTTERWORTH_BANDREJECT = 15, + VIPS_MASK_GAUSS_BANDPASS = 16, + VIPS_MASK_GAUSS_BANDREJECT = 17, + + VIPS_MASK_FRACTAL_FLT = 18 +} VipsMaskType; + int im_fwfft( IMAGE *in, IMAGE *out ); int im_invfft( IMAGE *in, IMAGE *out ); int im_invfftr( IMAGE *in, IMAGE *out ); + +int im_freqflt( IMAGE *in, IMAGE *mask, IMAGE *out ); +int im_disp_ps( IMAGE *in, IMAGE *out ); +int im_rotquad( IMAGE *in, IMAGE *out ); int im_phasecor_fft( IMAGE *in1, IMAGE *in2, IMAGE *out ); +int im_flt_image_freq( IMAGE *in, IMAGE *out, VipsMaskType flag, ... ); +int im_create_fmask( IMAGE *out, int xsize, int ysize, VipsMaskType flag, ... ); +int im_fractsurf( IMAGE *out, int size, double frd ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index 3bebd819..c2394250 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -267,6 +267,8 @@ int im_invmat( double **, int ); int im_conv_f_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask ); int im_convsep_f_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask ); +int im__fmaskcir( IMAGE *out, VipsMaskType flag, va_list ap ); + #ifdef __cplusplus } #endif /*__cplusplus*/