fix up global balance names

track mosaic-name now
This commit is contained in:
John Cupitt 2014-05-28 23:00:41 +01:00
parent 170efb1452
commit 8a38cb1946
5 changed files with 52 additions and 17 deletions

13
TODO
View File

@ -1,16 +1,3 @@
- when adding a history line like
if( im_histlin( out, "#LRJOIN <%s> <%s> <%s> <%d> <%d> <%d>",
look for a meta field called "mosaicing-name" and use that for the filename
if it's not set, use "original-fileanme" instead
make up a new name and attach that to the output as "mosaicing-name"
means we don't need to track copies in globalbalance
test on two-point mosaicing example
- more mosaicing?

View File

@ -1088,14 +1088,50 @@ im__lrmerge( IMAGE *ref, IMAGE *sec, IMAGE *out, int dx, int dy, int mwidth )
return ( 0 );
}
const char *
im__get_mosaic_name( VipsImage *image )
{
const char *name;
if( vips_image_get_typeof( image, "mosaic-name" ) ) {
if( vips_image_get_string( image, "mosaic-name", &name ) )
return( NULL );
}
else if( vips_image_get_typeof( image, "original-filename" ) ) {
if( vips_image_get_string( image, "original-filename", &name ) )
return( NULL );
}
else
name = image->filename;
return( name );
}
void
im__add_mosaic_name( VipsImage *image )
{
static int serial = 0;
char name[256];
/* We must override any inherited name, so don't test for doesn't
* exist before setting.
*/
vips_snprintf( name, 256, "mosaic-temp-%d", serial++ );
vips_image_set_string( image, "mosaic-name", name );
}
int
im_lrmerge( IMAGE *ref, IMAGE *sec, IMAGE *out, int dx, int dy, int mwidth )
{
if( im__lrmerge( ref, sec, out, dx, dy, mwidth ) )
return( -1 );
im__add_mosaic_name( out );
if( im_histlin( out, "#LRJOIN <%s> <%s> <%s> <%d> <%d> <%d>",
ref->filename, sec->filename, out->filename,
im__get_mosaic_name( ref ),
im__get_mosaic_name( sec ),
im__get_mosaic_name( out ),
-dx, -dy, mwidth ) )
return( -1 );

View File

@ -711,8 +711,11 @@ im_tbmerge( IMAGE *ref, IMAGE *sec, IMAGE *out, int dx, int dy, int mwidth )
if( im__tbmerge( ref, sec, out, dx, dy, mwidth ) )
return( -1 );
im__add_mosaic_name( out );
if( im_histlin( out, "#TBJOIN <%s> <%s> <%s> <%d> <%d> <%d>",
ref->filename, sec->filename, out->filename,
im__get_mosaic_name( ref ),
im__get_mosaic_name( sec ),
im__get_mosaic_name( out ),
-dx, -dy, mwidth ) )
return( -1 );

View File

@ -100,6 +100,9 @@ extern int *im__icoef1;
extern int *im__icoef2;
int im__make_blend_luts();
void im__add_mosaic_name( VipsImage *image );
const char *im__get_mosaic_name( VipsImage *image );
int im__attach_input( REGION *or, REGION *ir, Rect *area );
int im__copy_input( REGION *or, REGION *ir, Rect *area, Rect *reg );
Overlapping *im__build_mergestate( const char *domain,

View File

@ -124,9 +124,12 @@ im__lrmerge1( IMAGE *ref, IMAGE *sec, IMAGE *out,
/* Note parameters in history file ... for global balance to pick up
* later.
*/
im__add_mosaic_name( out );
vips_buf_init_static( &buf, text, 1024 );
vips_buf_appendf( &buf, "#LRROTSCALE <%s> <%s> <%s> <",
ref->filename, sec->filename, out->filename );
im__get_mosaic_name( ref ),
im__get_mosaic_name( sec ),
im__get_mosaic_name( out ) );
vips_buf_appendg( &buf, a );
vips_buf_appendf( &buf, "> <" );
vips_buf_appendg( &buf, b );
@ -166,9 +169,12 @@ im__tbmerge1( IMAGE *ref, IMAGE *sec, IMAGE *out,
/* Note parameters in history file ... for global balance to pick up
* later.
*/
im__add_mosaic_name( out );
vips_buf_init_static( &buf, text, 1024 );
vips_buf_appendf( &buf, "#TBROTSCALE <%s> <%s> <%s> <",
ref->filename, sec->filename, out->filename );
im__get_mosaic_name( ref ),
im__get_mosaic_name( sec ),
im__get_mosaic_name( out ) );
vips_buf_appendg( &buf, a );
vips_buf_appendf( &buf, "> <" );
vips_buf_appendg( &buf, b );