added im_insertplaceset

This commit is contained in:
John Cupitt 2009-10-20 12:58:45 +00:00
parent 41f92d853c
commit 8f60a3a957
4 changed files with 68 additions and 6 deletions

View File

@ -67,6 +67,7 @@
- threadgroup no longer has any default action, you must attach a work
function
- added im_copy_file()
- added im_insertplaceset()
25/3/09 started 7.18.0
- revised version numbers

6
TODO
View File

@ -1,8 +1,4 @@
- im_cache() seems to kill threading?
pipeline, im_cache(), output
can we get >100% cpu? try a tiny test program
- im_lineset() could be simpler, see im_insertplaceset()
- memory.c

View File

@ -186,6 +186,55 @@ static im_function lineset_desc = {
lineset_args /* Arg list */
};
/* Args for im_insertplaceset.
*/
static im_arg_desc insertplaceset_args[] = {
IM_INPUT_IMAGE( "main" ),
IM_INPUT_IMAGE( "sub" ),
IM_OUTPUT_IMAGE( "out" ),
IM_INPUT_INTVEC( "x" ),
IM_INPUT_INTVEC( "y" )
};
/* Call im_insertplaceset via arg vector.
*/
static int
insertplaceset_vec( im_object *argv )
{
im_intvec_object *xv = (im_intvec_object *) argv[3];
im_intvec_object *yv = (im_intvec_object *) argv[4];
int i;
if( xv->n != yv->n ) {
im_error( "im_insertplaceset", "%s",
_( "vectors not same length" ) );
return( -1 );
}
/* Copy the image then repeatedly im_insertplace(). This will make
* "out" into a "t", usually.
*/
if( im_copy( argv[0], argv[2] ) )
return( -1 );
for( i = 0; i < xv->n; i++ )
if( im_insertplace( argv[2], argv[1], xv->vec[i], yv->vec[i] ) )
return( -1 );
return( 0 );
}
/* Description of im_insertplaceset.
*/
static im_function insertplaceset_desc = {
"im_insertplaceset", /* Name */
"insert sub into main at every position in x, y",
0, /* Flags */
insertplaceset_vec, /* Dispatch function */
IM_NUMBER( insertplaceset_args ), /* Size of arg list */
insertplaceset_args /* Arg list */
};
/* Calculate a pixel for an image from a vec of double. Valid while im is
* valid.
*/
@ -346,6 +395,7 @@ static im_function *inplace_list[] = {
&flood_other_copy_desc,
&segment_desc,
&insertplace_desc,
&insertplaceset_desc,
&line_desc,
&lineset_desc
};

View File

@ -327,6 +327,13 @@ eval_to_region( REGION *or, im_threadgroup_t *tg )
int x, y;
#ifdef DEBUG_IO
int ntiles = 0;
printf( "eval_to_region: partial image output to region\n" );
printf( "\tleft = %d, top = %d, width = %d, height = %d\n",
r->left, r->top, r->width, r->height );
#endif /*DEBUG_IO*/
image.left = 0;
image.top = 0;
image.width = or->im->Xsize;
@ -377,6 +384,10 @@ eval_to_region( REGION *or, im_threadgroup_t *tg )
im_threadgroup_wait( tg );
return( -1 );
}
#ifdef DEBUG_IO
ntiles++;
#endif /*DEBUG_IO*/
}
/* Wait for all threads to hit 'go' again.
@ -386,6 +397,10 @@ eval_to_region( REGION *or, im_threadgroup_t *tg )
if( im_threadgroup_iserror( tg ) )
return( -1 );
#ifdef DEBUG_IO
printf( "eval_to_region: %d patches calculated\n", ntiles );
#endif /*DEBUG_IO*/
return( 0 );
}
@ -451,7 +466,7 @@ eval_to_memory( im_threadgroup_t *tg, REGION *or )
result |= im__end_eval( im );
#ifdef DEBUG_IO
printf( "eval_to_memory: %d patches written\n", ntiles );
printf( "eval_to_memory: %d patches calculated\n", ntiles );
#endif /*DEBUG_IO*/
return( result );