mostly working
still some strange things with order3, not initing ddx correctly?
This commit is contained in:
parent
8df32c84c1
commit
d5a1d65183
@ -44,6 +44,27 @@ static im_arg_desc one_in_one_out[] = {
|
||||
IM_OUTPUT_IMAGE( "out" )
|
||||
};
|
||||
|
||||
static im_arg_desc quadratic_args[] = {
|
||||
IM_INPUT_IMAGE( "in" ),
|
||||
IM_OUTPUT_IMAGE( "out" ),
|
||||
IM_INPUT_IMAGE( "coeff" )
|
||||
};
|
||||
|
||||
static int
|
||||
quadratic_vec( im_object *argv )
|
||||
{
|
||||
return( im_quadratic( argv[0], argv[1], argv[2] ) );
|
||||
}
|
||||
|
||||
static im_function quadratic_desc = {
|
||||
"im_quadratic", /* Name */
|
||||
"transform via quadratic",
|
||||
IM_FN_PIO, /* Flags */
|
||||
quadratic_vec, /* Dispatch function */
|
||||
IM_NUMBER( quadratic_args ), /* Size of arg list */
|
||||
quadratic_args /* Arg list */
|
||||
};
|
||||
|
||||
/* Two images in, one out.
|
||||
*/
|
||||
static im_arg_desc two_in_one_out[] = {
|
||||
@ -2295,7 +2316,8 @@ static im_function *deprecated_list[] = {
|
||||
&moreeqconst_desc,
|
||||
¬equal_desc,
|
||||
¬equal_vec_desc,
|
||||
¬equalconst_desc
|
||||
¬equalconst_desc,
|
||||
&quadratic_desc
|
||||
};
|
||||
|
||||
/* Package of functions.
|
||||
|
@ -2789,3 +2789,20 @@ im_icc_ac2rc( VipsImage *in, VipsImage *out, const char *profile_filename )
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int
|
||||
im_quadratic( IMAGE *in, IMAGE *out, IMAGE *coeff )
|
||||
{
|
||||
VipsImage *x;
|
||||
|
||||
if( vips_quadratic( in, &x, coeff,
|
||||
NULL ) )
|
||||
return( -1 );
|
||||
if( im_copy( x, out ) ) {
|
||||
g_object_unref( x );
|
||||
return( -1 );
|
||||
}
|
||||
g_object_unref( x );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -788,6 +788,8 @@ int im_lab_morph( VipsImage *in, VipsImage *out,
|
||||
|
||||
#define im_col_dE00 vips_col_dE00
|
||||
|
||||
int im_quadratic( IMAGE *in, IMAGE *out, IMAGE *coeff );
|
||||
|
||||
/* ruby-vips uses this
|
||||
*/
|
||||
#define vips_class_map_concrete_all vips_class_map_all
|
||||
|
@ -52,26 +52,23 @@
|
||||
|
||||
#include "resample.h"
|
||||
|
||||
/* **************************************************************************
|
||||
/@ imtranf.c
|
||||
/@
|
||||
/@ ALGORITHM
|
||||
/@
|
||||
/@ x',y' = coordinates of srcim
|
||||
/@ x,y = coordinates of dstim
|
||||
/@
|
||||
/@
|
||||
/@ x = x' + srcvec[0] : order 0 image shift only
|
||||
/@ + srcvec[2]x' + srcvec[4]y' : order 1 + affine transf.
|
||||
/@ + srcvec[6]x'y' : order 2 + bilinear transf.
|
||||
/@ + srcvec[8]x'x' + srcvec[10]y'y': order 3 + quadratic transf.
|
||||
/@
|
||||
/@ y = y' + srcvec[1]
|
||||
/@ + srcvec[3]x' + srcvec[5]y'
|
||||
/@ + srcvec[7]x'y'
|
||||
/@ + srcvec[9]x'x' + srcvec[11]y'y'
|
||||
/@
|
||||
************************************************************************/
|
||||
/* The transform we compute:
|
||||
|
||||
x',y' = coordinates of srcim
|
||||
x,y = coordinates of dstim
|
||||
a .. l = coefficients
|
||||
|
||||
x = x' + a : order 0 image shift only
|
||||
+ b x' + c y' : order 1 + affine transf.
|
||||
+ d x' y' : order 2 + bilinear transf.
|
||||
+ e x' x' + f y' y' : order 3 + quadratic transf.
|
||||
|
||||
y = y' + g
|
||||
+ h y' + i x'
|
||||
+ j y' x'
|
||||
+ k y' y' + l x' x'
|
||||
|
||||
*/
|
||||
|
||||
typedef struct _VipsQuadratic {
|
||||
VipsResample parent_instance;
|
||||
@ -203,6 +200,10 @@ vips_quadratic_gen( VipsRegion *or, void *vseq,
|
||||
fyi += vec[5] * yo + vec[3] * xlow;
|
||||
dx += vec[2];
|
||||
dy += vec[3];
|
||||
|
||||
case 0:
|
||||
/* See above for order 0.
|
||||
*/
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -225,7 +226,6 @@ vips_quadratic_gen( VipsRegion *or, void *vseq,
|
||||
if( xi < 0 || xi >= sizex1 || yi < 0 || yi >= sizey1 ) {
|
||||
for( z = 0; z < ps; z++ )
|
||||
q[z] = 0;
|
||||
q += ps;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
@ -252,6 +252,8 @@ vips_quadratic_gen( VipsRegion *or, void *vseq,
|
||||
TYPE_SWITCH_IPOL;
|
||||
}
|
||||
|
||||
q += ps;
|
||||
|
||||
fxi += dx;
|
||||
fyi += dy;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user