示例#1
0
/**
 * im_phasecor_fft:
 * @in1: first input image
 * @in2: second input image
 * @out: output image
 *
 * Convert the two input images to Fourier space, calculate phase-correlation,
 * back to real space.
 *
 * See also: im_fwfft(), im_cross_phase(), 
 *
 * Returns: 0 on success, -1 on error
 */
int 
im_phasecor_fft( IMAGE *in1, IMAGE *in2, IMAGE *out )
{
	IMAGE *t[3];

	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( 0 );
}
示例#2
0
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 );
}
示例#3
0
static int 
disp_ps( IMAGE *dummy, IMAGE *in, IMAGE *out )
{
	IMAGE *t[3];

	if( im_open_local_array( out, t, 3, "im_disp_ps temp 1", "p" ) )
		return( -1 );

	if( in->BandFmt != IM_BANDFMT_COMPLEX ) {
		if( im_fwfft( in, t[0] ) )
			return( -1 );
		in = t[0];
	}

	if( im_abs( in, t[1] ) ||
		im_scaleps( t[1], t[2] ) || 
		im_rotquad( t[2], out ) )
		return( -1 );

	return( 0 );
}