int im_freqflt( IMAGE *in, IMAGE *mask, IMAGE *out ) { IMAGE *dummy; /* Placeholder for memory free. */ if( !(dummy = im_open( "memory-1", "p" )) ) return( -1 ); if( im_iscomplex( in ) ) { /* Easy case! Assume it has already been transformed. */ IMAGE *t1 = im_open_local( dummy, "im_freqflt-1", "p" ); if( !t1 || im_multiply( in, mask, t1 ) || im_invfftr( t1, out ) ) { im_close( dummy ); return( -1 ); } } else { /* Harder - fft first, then mult, then force back to start * type. * * Optimisation: output of im_invfft() is float buffer, we * will usually chagetype to char, so rather than keeping a * large float buffer and partial to char from that, do * changetype to a memory buffer, and copy to out from that. */ IMAGE *t[3]; IMAGE *t3; if( im_open_local_array( dummy, t, 3, "im_freqflt-1", "p" ) || !(t3 = im_open_local( out, "im_freqflt-3", "t" )) || im_fwfft( in, t[0] ) || im_multiply( t[0], mask, t[1] ) || im_invfftr( t[1], t[2] ) || im_clip2fmt( t[2], t3, in->BandFmt ) || im_copy( t3, out ) ) { im_close( dummy ); return( -1 ); } } im_close( dummy ); return( 0 ); }
/** * im_cmulnorm * @in1: input #IMAGE 1 * @in2: input #IMAGE 2 * @out: output #IMAGE * * im_cmulnorm() multiplies two complex images. The complex output is * normalised to 1 by dividing both the real and the imaginary part of each * pel with the norm. This is useful for phase correlation. * * This operation used to be important, but now simply calls im_multiply() * then im_sign(). * * See also: im_multiply(), im_sign(). * * Returns: 0 on success, -1 on error */ int im_cmulnorm( IMAGE *in1, IMAGE *in2, IMAGE *out ) { IMAGE *t1; if( !(t1 = im_open_local( out, "im_cmulnorm:1", "p" )) || im_multiply( in1, in2, t1 ) || im_sign( t1, out ) ) return( -1 ); return( 0 ); }