/* Call im_matinv via arg vector.
 */
static int
matinv_vec( im_object *argv )
{
	im_mask_object *in = argv[0];
	im_mask_object *out = argv[1];

	if( !(out->mask = 
		im_matinv( in->mask, out->name )) )
		return( -1 );

	return( 0 );
}
Example #2
0
/* Given a pair of points, return scale, angle, dx, dy to resample the 2nd
 * image with.
 */
int 
im__coeff( int xr1, int yr1, int xs1, int ys1, 
	int xr2, int yr2, int xs2, int ys2, 
	double *a, double *b, double *dx, double *dy )
{	
	DOUBLEMASK *in, *out;

	if( !(in = im_create_dmask( "in", 4, 4 )) ) {
		im_errormsg( "im__coeff: unable to allocate matrix" );
		return( -1 );
	}

	in->coeff[0] = (double)xs1;
	in->coeff[1] = (double)-ys1;
	in->coeff[2] = 1.0;
	in->coeff[3] = 0.0;
	in->coeff[4] = (double)ys1;
	in->coeff[5] = (double)xs1;
	in->coeff[6] = 0.0;
	in->coeff[7] = 1.0;
	in->coeff[8] = (double)xs2;
	in->coeff[9] = (double)-ys2;
	in->coeff[10] = 1.0;
	in->coeff[11] = 0.0;
	in->coeff[12] = (double)ys2;
	in->coeff[13] = (double)xs2;
	in->coeff[14] = 0.0;
	in->coeff[15] = 1.0;

	if( !(out = im_matinv( in, "out" )) ) {
		im_free_dmask( in );
		im_errormsg( "im__coeff: unable to invert matrix" );
		return( -1 );
	}

	*a = out->coeff[0]*xr1 + out->coeff[1]*yr1 + 
		out->coeff[2]*xr2 + out->coeff[3]*yr2;
	*b = out->coeff[4]*xr1 + out->coeff[5]*yr1 + 
		out->coeff[6]*xr2 + out->coeff[7]*yr2;
	*dx= out->coeff[8]*xr1 + out->coeff[9]*yr1 + 	
		out->coeff[10]*xr2 + out->coeff[11]*yr2;
	*dy= out->coeff[12]*xr1 + out->coeff[13]*yr1 + 
		out->coeff[14]*xr2 + out->coeff[15]*yr2;

	im_free_dmask( in );
	im_free_dmask( out );

	return( 0 );
}
Example #3
0
/* Calculate the inverse transformation.
 */
int
im__transform_calc_inverse( Transformation *trn )
{
    DOUBLEMASK *msk, *msk2;

    if( !(msk = im_create_dmaskv( "boink", 2, 2,
                                  trn->a, trn->b, trn->c, trn->d )) )
        return( -1 );
    if( !(msk2 = im_matinv( msk, "boink2" )) ) {
        (void) im_free_dmask( msk );
        return( -1 );
    }
    trn->ia = msk2->coeff[0];
    trn->ib = msk2->coeff[1];
    trn->ic = msk2->coeff[2];
    trn->id = msk2->coeff[3];
    (void) im_free_dmask( msk );
    (void) im_free_dmask( msk2 );

    return( 0 );
}