From e6eb08173f64f2242a12fa871d9109778575285f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 18 Dec 2012 13:08:18 +0000 Subject: [PATCH] can now displace affine input space so hopefully that means you can change corner vs. centre convention easily --- ChangeLog | 1 + TODO | 9 --------- libvips/mosaicing/global_balance.c | 12 ++++++++---- libvips/mosaicing/mosaic1.c | 6 ++++-- libvips/resample/affine.c | 23 +++++++++++++++++------ 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5341631c..089e03f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,7 @@ - all interpolators use corner convention ... we had round-to-nearest in several of them before, causing a range of annoying problems - redone im_affine*() as a class +- added input space displacement to affine 14/11/12 started 7.30.6 - capture tiff warnings earlier diff --git a/TODO b/TODO index 253e4985..c0d66d47 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,5 @@ - test affine labq processing -- now we've removed round-to-nearest from NN, we need something extra in the - affine transform to displace the input cods - - dx/dy displace output - -- make affinei into a class - - - - quadratic doesn't work for order 3 diff --git a/libvips/mosaicing/global_balance.c b/libvips/mosaicing/global_balance.c index f506127d..e4d9e178 100644 --- a/libvips/mosaicing/global_balance.c +++ b/libvips/mosaicing/global_balance.c @@ -499,8 +499,10 @@ make_join( SymbolTable *st, JoinType type, out->thistrn.b = -b; out->thistrn.c = b; out->thistrn.d = a; - out->thistrn.dx = dx; - out->thistrn.dy = dy; + out->thistrn.idx = 0; + out->thistrn.idy = 0; + out->thistrn.odx = dx; + out->thistrn.ody = dy; /* Clean the table and propogate the transform down the RHS of the * graph. @@ -519,8 +521,10 @@ make_join( SymbolTable *st, JoinType type, trn.b = 0.0; trn.c = 0.0; trn.d = 1.0; - trn.dx = -out->cumtrn.oarea.left; - trn.dy = -out->cumtrn.oarea.top; + trn.idx = 0; + trn.idy = 0; + trn.odx = -out->cumtrn.oarea.left; + trn.ody = -out->cumtrn.oarea.top; clean_table( st ); if( propogate_transform( out, &trn ) ) return( -1 ); diff --git a/libvips/mosaicing/mosaic1.c b/libvips/mosaicing/mosaic1.c index c64995f3..55605407 100644 --- a/libvips/mosaicing/mosaic1.c +++ b/libvips/mosaicing/mosaic1.c @@ -80,8 +80,10 @@ apply_similarity( VipsTransformation *trn, IMAGE *in, IMAGE *out, trn->b = -b; trn->c = b; trn->d = a; - trn->dx = dx; - trn->dy = dy; + trn->idx = 0; + trn->idy = 0; + trn->odx = dx; + trn->ody = dy; vips__transform_set_area( trn ); if( vips__transform_calc_inverse( trn ) ) return( -1 ); diff --git a/libvips/resample/affine.c b/libvips/resample/affine.c index ffc388ee..a25c0717 100644 --- a/libvips/resample/affine.c +++ b/libvips/resample/affine.c @@ -78,6 +78,7 @@ * - gtk-doc * 14/12/12 * - redone as a class + * - added input space translation */ /* @@ -334,6 +335,11 @@ vips_affine_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) ix += iarea->left; iy += iarea->top; + /* And the input offset. + */ + ix -= affine->trn.idx; + iy -= affine->trn.idy; + q = VIPS_REGION_ADDR( or, le, y ); for( x = le; x < ri; x++ ) { @@ -429,6 +435,11 @@ vips_affine_build( VipsObject *object ) if( vips_object_argument_isset( object, "ody" ) ) affine->trn.ody = affine->ody; + if( vips_object_argument_isset( object, "idx" ) ) + affine->trn.idx = affine->idx; + if( vips_object_argument_isset( object, "idy" ) ) + affine->trn.idy = affine->idy; + if( vips__transform_calc_inverse( &affine->trn ) ) return( -1 ); @@ -541,28 +552,28 @@ vips_affine_class_init( VipsAffineClass *class ) _( "Horizontal output displacement" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsAffine, odx ), - 0, 10000000, 0 ); + -10000000, 10000000, 0 ); VIPS_ARG_DOUBLE( class, "ody", 113, _( "Output offset" ), _( "Vertical output displacement" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsAffine, ody ), - 0, 10000000, 0 ); + -10000000, 10000000, 0 ); - VIPS_ARG_DOUBLE( class, "idx", 112, + VIPS_ARG_DOUBLE( class, "idx", 114, _( "Input offset" ), _( "Horizontal input displacement" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsAffine, idx ), - 0, 10000000, 0 ); + -10000000, 10000000, 0 ); - VIPS_ARG_DOUBLE( class, "idy", 113, + VIPS_ARG_DOUBLE( class, "idy", 115, _( "Input offset" ), _( "Vertical input displacement" ), VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsAffine, idy ), - 0, 10000000, 0 ); + -10000000, 10000000, 0 ); } static void