示例#1
0
int 
im__improve( TIE_POINTS *inpoints, TIE_POINTS *outpoints )
{
	TIE_POINTS points1, points2;
	TIE_POINTS *p = &points1;
	TIE_POINTS *q = &points2;

	/* p has the current state - make a new state, q, with only those
	 * points which have a small deviation.
	 */
	for( copypoints( p, inpoints ); 
		copypoints( q, p ), copydevpoints( q, p ); ) {
		/* If there are only a few left, jump out.
		 */
		if( q->nopoints < 2 )
			break;

		/* Fit the model to the new set of points.
		 */
		if( im__clinear( q ) )
			return( -1 );

		/* And loop.
		 */
		IM_SWAP( void *, p, q );
	}

	/* q has the output - copy to outpoints.
	 */
	copypoints( outpoints, q );

	return( 0 );
}
示例#2
0
int 
im__initialize( TIE_POINTS *points )
{
	if( im__clinear( points ) ) {
		/* im_clinear failed! Set some sensible fallback values.
		 */
		int i, j;
		double xdelta, ydelta, max_cor;
		double a1, a2;

		int *xref = &points->x_reference[0];
		int *yref = &points->y_reference[0];
		int *xsec = &points->x_secondary[0];
		int *ysec = &points->y_secondary[0];

		double *corr = &points->correlation[0];
		double *dx = &points->dx[0];
		double *dy = &points->dy[0];

		int npt = points->nopoints;

		max_cor = 0.0;
		for( i = 0; i < npt; i++ )
			if( corr[i] > max_cor )
				max_cor = corr[i];

		max_cor = max_cor - 0.04;
		xdelta = 0.0;
		ydelta = 0.0;
		j = 0;
		for( i = 0; i < npt; i++ )
			if( corr[i] >= max_cor ) {
				xdelta += xsec[i] - xref[i];
				ydelta += ysec[i] - yref[i];
				++j;
			}

		xdelta = xdelta/j;
		ydelta = ydelta/j;
		for(i = 0; i < npt; i++ ) {
			dx[i] = (xsec[i] - xref[i]) - xdelta;
			dy[i] = (ysec[i] - yref[i]) - ydelta;
		}

		for( i = 0; i < npt; i++ ) {
			a1 = dx[i];
			a2 = dy[i];
			points->deviation[i] = sqrt( a1*a1 + a2*a2 );
		}	

		points->l_scale = 1.0;
		points->l_angle = 0.0;
		points->l_deltax = xdelta;
		points->l_deltay = ydelta;
	}

	return( 0 );
}