add im_align_bands
This commit is contained in:
parent
9410ec047f
commit
fac9cf135e
@ -664,6 +664,8 @@ int im_correl( IMAGE *ref, IMAGE *sec,
|
|||||||
int im_remosaic( IMAGE *in, IMAGE *out,
|
int im_remosaic( IMAGE *in, IMAGE *out,
|
||||||
const char *old_str, const char *new_str );
|
const char *old_str, const char *new_str );
|
||||||
|
|
||||||
|
int im_align_bands( IMAGE *in, IMAGE *out );
|
||||||
|
|
||||||
/* inplace
|
/* inplace
|
||||||
*/
|
*/
|
||||||
int im_plotmask( IMAGE *, int, int, PEL *, PEL *, Rect * );
|
int im_plotmask( IMAGE *, int, int, PEL *, PEL *, Rect * );
|
||||||
|
@ -2,6 +2,7 @@ noinst_LTLIBRARIES = libmosaicing.la
|
|||||||
|
|
||||||
libmosaicing_la_SOURCES = \
|
libmosaicing_la_SOURCES = \
|
||||||
im_affine.c \
|
im_affine.c \
|
||||||
|
im_align_bands.c \
|
||||||
match.c \
|
match.c \
|
||||||
mosaic1.c \
|
mosaic1.c \
|
||||||
mosaicing_dispatch.c \
|
mosaicing_dispatch.c \
|
||||||
|
87
libsrc/mosaicing/im_align_bands.c
Normal file
87
libsrc/mosaicing/im_align_bands.c
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Brute force align the bands of an image.
|
||||||
|
*
|
||||||
|
* Copyright: Nottingham Trent University
|
||||||
|
* Author: Tom Vajzovic
|
||||||
|
* Written on: 2008-02-04
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
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_align_bands( IMAGE *in, IMAGE *out ){
|
||||||
|
#define FUNCTION_NAME "im_align_bands"
|
||||||
|
if( im_piocheck( in, out ))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if( 1 == in-> Bands )
|
||||||
|
return im_copy( in, out );
|
||||||
|
{
|
||||||
|
IMAGE **bands= IM_ARRAY( out, 2 * in-> Bands, IMAGE* );
|
||||||
|
IMAGE **wrapped_bands= bands + in-> Bands;
|
||||||
|
double x= 0.0;
|
||||||
|
double y= 0.0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if( ! bands || im_open_local_array( out, bands, in-> Bands, FUNCTION_NAME ": bands", "p" )
|
||||||
|
|| im_open_local_array( out, wrapped_bands + 1, in-> Bands - 1, FUNCTION_NAME ": wrapped_bands", "p" ))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for( i= 0; i < in-> Bands; ++i )
|
||||||
|
if( im_extract_band( in, bands[i], i ))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
wrapped_bands[ 0 ]= bands[0];
|
||||||
|
|
||||||
|
for( i= 1; i < in-> Bands; ++i ){
|
||||||
|
IMAGE *temp= im_open( FUNCTION_NAME ": temp", "t" );
|
||||||
|
double this_x, this_y, val;
|
||||||
|
|
||||||
|
if( ! temp || im_phasecor_fft( bands[i-1], bands[i], temp )
|
||||||
|
|| im_maxpos_avg( temp, & this_x, & this_y, & val ) || im_close( temp ))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
x+= this_x;
|
||||||
|
y+= this_y;
|
||||||
|
|
||||||
|
if( im_wrap( bands[i], wrapped_bands[i], (int) x, (int) y ))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return im_gbandjoin( wrapped_bands, out, in-> Bands );
|
||||||
|
}
|
||||||
|
#undef FUNCTION_NAME
|
||||||
|
}
|
@ -814,10 +814,29 @@ static im_function remosaic_desc = {
|
|||||||
remosaic_args /* Arg list */
|
remosaic_args /* Arg list */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int align_bands_vec( im_object *argv ){
|
||||||
|
return im_align_bands( (IMAGE*)argv[0], (IMAGE*)argv[1] );
|
||||||
|
}
|
||||||
|
|
||||||
|
static im_arg_desc align_bands_arg_types[]= {
|
||||||
|
IM_INPUT_IMAGE( "in" ),
|
||||||
|
IM_OUTPUT_IMAGE( "out" )
|
||||||
|
};
|
||||||
|
|
||||||
|
static im_function align_bands_desc= {
|
||||||
|
"im_align_bands",
|
||||||
|
"align the bands of an image",
|
||||||
|
0,
|
||||||
|
align_bands_vec,
|
||||||
|
IM_NUMBER( align_bands_arg_types ),
|
||||||
|
align_bands_arg_types
|
||||||
|
};
|
||||||
|
|
||||||
/* Package up all these functions.
|
/* Package up all these functions.
|
||||||
*/
|
*/
|
||||||
static im_function *mos_list[] = {
|
static im_function *mos_list[] = {
|
||||||
&affine_desc,
|
&affine_desc,
|
||||||
|
&align_bands_desc,
|
||||||
&correl_desc,
|
&correl_desc,
|
||||||
&find_lroverlap_desc,
|
&find_lroverlap_desc,
|
||||||
&find_tboverlap_desc,
|
&find_tboverlap_desc,
|
||||||
|
Loading…
Reference in New Issue
Block a user