add im_phasecor_fft

This commit is contained in:
John Cupitt 2008-01-22 10:43:26 +00:00
parent 731707f73b
commit 34f80ebeed
4 changed files with 85 additions and 0 deletions

View File

@ -270,6 +270,7 @@ int im_convsub( IMAGE *, IMAGE *, INTMASK *, int, int );
int im_grad_x( IMAGE *in, IMAGE *out );
int im_grad_y( IMAGE *in, IMAGE *out );
int im_phasecor_fft( IMAGE *in1, IMAGE *in2, IMAGE *out );
int im_fastcor( IMAGE *, IMAGE *, IMAGE * );
int im_fastcor_raw( IMAGE *, IMAGE *, IMAGE * );
int im_spcor( IMAGE *, IMAGE *, IMAGE * );

View File

@ -20,6 +20,7 @@ libconvolution_la_SOURCES = \
im_logmasks.c \
im_rank_image.c \
im_mpercent.c \
im_phasecor_fft.c \
im_rank.c \
im_resize_linear.c \
im_sharpen.c \

View File

@ -152,6 +152,25 @@ static im_function contrast_surface_raw_desc = {
contrast_surface_raw_args /* Arg list */
};
/* Call im_phasecor_fft via arg vector.
*/
static int
phasecor_fft_vec( im_object *argv )
{
return( im_phasecor_fft( argv[0], argv[1], argv[2] ) );
}
/* Description of im_phasecor_fft.
*/
static im_function phasecor_fft_desc = {
"im_phasecor_fft", /* Name */
"non-normalised correlation of gradient of in2 within in1",
IM_FN_TRANSFORM, /* Flags */
phasecor_fft_vec, /* Dispatch function */
IM_NUMBER( two_in_one_out ), /* Size of arg list */
two_in_one_out /* Arg list */
};
/* Args to im_rank.
*/
static im_arg_desc rank_args[] = {
@ -1342,6 +1361,7 @@ static im_function *convol_list[] = {
&log_imask_desc,
&maxvalue_desc,
&mpercent_desc,
&phasecor_fft_desc,
&rank_desc,
&rank_raw_desc,
&read_dmask_desc,

View File

@ -0,0 +1,63 @@
/* Like im_spcor(), but calculates phase correlation in the Fourier domain.
*
* Copyright: 2008, Nottingham Trent University
*
* Author: Tom Vajzovic
* Written on: 2008-01-16
*/
/*
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
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <vips/vips.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#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" );
if( ! temp1 || ! temp2 || ! temp3 )
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
}