/** * im_tbmerge: * @ref: reference image * @sec: secondary image * @out: output image * @dx: displacement of ref from sec * @dy: displacement of ref from sec * @mwidth: maximum seam width * * This operation joins two images top-bottom (with @ref on the top) with a * smooth seam. * * If the number of bands differs, one of the images * must have one band. In this case, an n-band image is formed from the * one-band image by joining n copies of the one-band image together, and then * the two n-band images are operated upon. * * The two input images are cast up to the smallest common type (see table * Smallest common format in * <link linkend="VIPS-arithmetic">arithmetic</link>). * * @dx and @dy give the displacement of @sec relative to @ref, in other words, * the vector to get from the origin of @sec to the origin of @ref, in other * words, @dx will generally be a negative number. * * @mwidth limits the maximum height of the * blend area. A value of "-1" means "unlimited". The two images are blended * with a raised cosine. * * Pixels with all bands equal to zero are "transparent", that * is, zero pixels in the overlap area do not contribute to the merge. * This makes it possible to join non-rectangular images. * * See also: im_lrmosaic(), im_lrmerge(), im_match_linear(), im_insert(). * * Returns: 0 on success, -1 on error */ int 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 ); if( im_histlin( out, "#TBJOIN <%s> <%s> <%s> <%d> <%d> <%d>", ref->filename, sec->filename, out->filename, -dx, -dy, mwidth ) ) return( -1 ); return( 0 ); }
/* similarity+tbmerge. */ int im__tbmerge1( IMAGE *ref, IMAGE *sec, IMAGE *out, double a, double b, double dx, double dy, int mwidth ) { VipsTransformation trn; IMAGE *t1 = im_open_local( out, "im_lrmosaic1:2", "p" ); VipsBuf buf; char text[1024]; /* Scale, rotate and displace sec. */ if( !t1 || apply_similarity( &trn, sec, t1, a, b, dx, dy ) ) return( -1 ); /* And join to ref. */ if( im__tbmerge( ref, t1, out, -trn.oarea.left, -trn.oarea.top, mwidth ) ) return( -1 ); /* 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> <", 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 ); vips_buf_appendf( &buf, "> <" ); vips_buf_appendg( &buf, dx ); vips_buf_appendf( &buf, "> <" ); vips_buf_appendg( &buf, dy ); vips_buf_appendf( &buf, "> <%d>", mwidth ); if( im_histlin( out, "%s", vips_buf_all( &buf ) ) ) return( -1 ); return( 0 ); }