This commit is contained in:
John Cupitt 2010-02-17 22:06:29 +00:00
parent 3c18b0f0c1
commit fb4a191ab7
4 changed files with 30 additions and 62 deletions

32
TODO
View File

@ -1,35 +1,3 @@
- im_fastcor() could use a rewrite
- im_spcor a.value a.value fails, argh
nip2: im_prepare.c:324: im_prepare_to:
Assertion `clipped.left == r->left' failed.
also, im_spcor a rectangular image one pixel smaller with itself and the
peak comes at (eg. 134x134) rather than in the centre of the image
suspicious!
looks like it's a problem with im_embed()
$ header t1.v
Xsize: 183
Ysize: 119
Bands: 1
Bbits: 8
then
$ vips im_embed t1.v out2.v 1 100 74 364 240
$ vips im_embed t1.v out2.v 1 100 73 364 240
vips: error calling function
im_prepare_to: valid clipped to nothing
im__write_extension_block: file has been truncated
though 74 fails too, tiles are in the wrong place
seems fixed, test this
- doing im_create_fmask() and friends
- how about im_invalidate_area()? we currently repaint the whole window on

View File

@ -1314,18 +1314,18 @@ static im_arg_desc wrap_args[] = {
static int
wrap_vec (im_object * argv)
{
return im_wrap( (IMAGE*)argv[0], (IMAGE*)argv[1], *(int*)argv[2], *(int*)argv[3] );
return im_wrap( argv[0], argv[1], *(int*)argv[2], *(int*)argv[3] );
}
/* Description of im_wrap.
*/
static im_function wrap_desc = {
"im_wrap", /* Name */
"im_wrap", /* Name */
"shift image origin, wrapping at sides",
IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */
wrap_vec, /* Dispatch function */
wrap_vec, /* Dispatch function */
IM_NUMBER (wrap_args), /* Size of arg list */
wrap_args /* Arg list */
wrap_args /* Arg list */
};
/* Args for im_embed.
@ -1336,8 +1336,8 @@ static im_arg_desc embed_args[] = {
IM_INPUT_INT( "type" ),
IM_INPUT_INT( "x" ),
IM_INPUT_INT( "y" ),
IM_INPUT_INT( "w" ),
IM_INPUT_INT( "h" )
IM_INPUT_INT( "width" ),
IM_INPUT_INT( "height" )
};
/* Call im_embed via arg vector.
@ -1348,10 +1348,10 @@ embed_vec( im_object *argv )
int type = *((int *) argv[2]);
int x = *((int *) argv[3]);
int y = *((int *) argv[4]);
int w = *((int *) argv[5]);
int h = *((int *) argv[6]);
int width = *((int *) argv[5]);
int height = *((int *) argv[6]);
return( im_embed( argv[0], argv[1], type, x, y, w, h ) );
return( im_embed( argv[0], argv[1], type, x, y, width, height ) );
}
/* Description of im_embed.
@ -1361,7 +1361,7 @@ static im_function embed_desc = {
"embed in within a set of borders",
IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */
embed_vec, /* Dispatch function */
IM_NUMBER( embed_args ), /* Size of arg list */
IM_NUMBER( embed_args ), /* Size of arg list */
embed_args /* Arg list */
};

View File

@ -73,10 +73,6 @@ fastcor_gen( REGION *or, void *seq, void *a, void *b )
IMAGE *ref = (IMAGE *) b;
Rect irect;
Rect *r = &or->valid;
int le = r->left;
int to = r->top;
int bo = IM_RECT_BOTTOM(r);
int ri = IM_RECT_RIGHT(r);
int x, y, i, j;
int lsk;
@ -94,29 +90,30 @@ fastcor_gen( REGION *or, void *seq, void *a, void *b )
/* Loop over or.
*/
for( y = to; y < bo; y++ ) {
PEL *a = (PEL *) IM_REGION_ADDR( ir, le, y );
unsigned int *q = (unsigned int *) IM_REGION_ADDR( or, le, y );
for( y = 0; y < r->height; y++ ) {
unsigned int *q = (unsigned int *)
IM_REGION_ADDR( or, r->left, r->top + y );
for( x = le; x < ri; x++ ) {
int sum = 0;
for( x = 0; x < r->width; x++ ) {
PEL *b = (PEL *) ref->data;
PEL *a1 = a;
PEL *a = (PEL *)
IM_REGION_ADDR( ir, r->left + x, r->top + y );
int sum;
sum = 0;
for( j = 0; j < ref->Ysize; j++ ) {
PEL *a2 = a1;
for( i = 0; i < ref->Xsize; i++ ) {
int t = *b++ - *a2++;
int t = b[i] - a[i];
sum += t * t;
}
a1 += lsk;
a += lsk;
b += ref->Xsize;
}
*q++ = sum;
a += 1;
q[x] = sum;
}
}
@ -137,7 +134,8 @@ im_fastcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out )
/* Check sizes.
*/
if( in->Xsize < ref->Xsize || in->Ysize < ref->Ysize ) {
im_error( "im_fastcor", "%s", _( "ref not smaller than in" ) );
im_error( "im_fastcor", "%s",
_( "ref not smaller than or equal to in" ) );
return( -1 );
}
@ -183,7 +181,8 @@ im_fastcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out )
*
* @ref is placed at every position in @in and the sum of squares of
* differences calculated. One-band, 8-bit unsigned images only. The output
* image is always %IM_BANDFMT_UINT. @ref must be smaller than @in. The output
* image is always %IM_BANDFMT_UINT. @ref must be smaller than or equal to
* @in. The output
* image is the same size as the input.
*
* See also: im_spcor().

View File

@ -248,7 +248,7 @@ im_spcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out )
if( in->Xsize < ref->Xsize ||
in->Ysize < ref->Ysize ) {
im_error( "im_spcor_raw",
"%s", _( "ref not smaller than in" ) );
"%s", _( "ref not smaller than or equal to in" ) );
return( -1 );
}
@ -304,7 +304,8 @@ im_spcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out )
* @ref is placed at every position in @in and the correlation coefficient
* calculated. One-band, 8 or 16-bit images only. @in and @ref must have the
* same #VipsBandFmt. The output
* image is always %IM_BANDFMT_FLOAT. @ref must be smaller than @in. The output
* image is always %IM_BANDFMT_FLOAT. @ref must be smaller than or equal to
* @in. The output
* image is the same size as the input.
*
* The correlation coefficient is calculated as: