"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Libtmp/Image2D/image2d.pd" between
PDL-2.074.tar.gz and PDL-2.075.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

image2d.pd  (PDL-2.074):image2d.pd  (PDL-2.075)
skipping to change at line 60 skipping to change at line 60
pp_addhdr(' pp_addhdr('
void polyfill(PDL_Long *image, int wx, int wy, float *ps, int n, void polyfill(PDL_Long *image, int wx, int wy, float *ps, int n,
PDL_Long col, int *ierr); PDL_Long col, int *ierr);
'); ');
pp_def('polyfill_pp', pp_def('polyfill_pp',
HandleBad => 0, # a marker HandleBad => 0, # a marker
Pars => 'int [o,nc] im(m,n); float ps(two=2,np); int col()', Pars => 'int [o,nc] im(m,n); float ps(two=2,np); int col()',
Code => 'int ierr = 0, nerr; Code => 'int ierr = 0, nerr;
threadloop %{ broadcastloop %{
polyfill($P(im), $SIZE(m), $SIZE(n), $P(ps), $SIZE(np), $col() , &nerr); polyfill($P(im), $SIZE(m), $SIZE(n), $P(ps), $SIZE(np), $col() , &nerr);
ierr = ierr < nerr ? nerr : ierr; ierr = ierr < nerr ? nerr : ierr;
%} %}
if (ierr) warn("errors during polygonfilling"); if (ierr) warn("errors during polygonfilling");
', ',
Doc => undef, Doc => undef,
PMFunc => '' PMFunc => ''
); );
my %pnpolyFields = ( my %pnpolyFields = (
skipping to change at line 88 skipping to change at line 88
PMFunc => '', PMFunc => '',
Doc => undef, Doc => undef,
Pars => $pnpolyFields{$name}->{'pars'}, Pars => $pnpolyFields{$name}->{'pars'},
Code => ' Code => '
int i, j, c, nvert; int i, j, c, nvert;
nvert = $SIZE(l); nvert = $SIZE(l);
#define VERTX(q) $ps(k=>0,l=>q) #define VERTX(q) $ps(k=>0,l=>q)
#define VERTY(q) $ps(k=>1,l=>q) #define VERTY(q) $ps(k=>1,l=>q)
threadloop %{ broadcastloop %{
loop(n) %{ loop(n) %{
loop(m) %{ loop(m) %{
c = 0; c = 0;
for(i=0,j=nvert-1;i<nvert;j=i++) { for(i=0,j=nvert-1;i<nvert;j=i++) {
if( ((VERTY(i)>n) != (VERTY(j)>n)) && if( ((VERTY(i)>n) != (VERTY(j)>n)) &&
(m < (VERTX(j)-VERTX(i)) * (n-VERTY(i)) / (VE RTY(j)-VERTY(i)) + VERTX(i)) ) (m < (VERTX(j)-VERTX(i)) * (n-VERTY(i)) / (VE RTY(j)-VERTY(i)) + VERTX(i)) )
c = !c; c = !c;
} }
' . $pnpolyFields{$name}->{'special'} .' ' . $pnpolyFields{$name}->{'special'} .'
%} %}
skipping to change at line 274 skipping to change at line 274
3*($$opt{Boundary} eq "Replicate"))); 3*($$opt{Boundary} eq "Replicate")));
return $c; return $c;
} }
', ',
Code => Code =>
init_vars( { vars => 'PDL_Double tmp;' } ) . init_vars( { vars => 'PDL_Double tmp;' } ) .
init_map("i") . init_map("i") .
init_map("j") . init_map("j") .
' '
threadloop %{ broadcastloop %{
for(j=0; j<n_size; j++) { for(j=0; j<n_size; j++) {
for(i=0; i<m_size; i++) { for(i=0; i<m_size; i++) {
tmp = 0; tmp = 0;
for(j1=0; j1<q_size; j1++) { for(j1=0; j1<q_size; j1++) {
j2 = mapj[j-j1]; j2 = mapj[j-j1];
if (j2 >= 0) { if (j2 >= 0) {
for(i1=0; i1<p_size; i1++) { for(i1=0; i1<p_size; i1++) {
i2 = mapi[i-i1]; i2 = mapi[i-i1];
if (i2 >= 0) if (i2 >= 0)
skipping to change at line 299 skipping to change at line 299
$b(m=>i,n=>j) = tmp; $b(m=>i,n=>j) = tmp;
} /* for: i */ } /* for: i */
} /* for: j */ } /* for: j */
%} %}
free(mapj+1-q_size); free(mapi+1-p_size);', free(mapj+1-q_size); free(mapi+1-p_size);',
BadCode => BadCode =>
init_vars( { vars => 'PDL_Double tmp; int flag;' } ) . init_vars( { vars => 'PDL_Double tmp; int flag;' } ) .
init_map("i") . init_map("i") .
init_map("j") . init_map("j") .
' '
threadloop %{ broadcastloop %{
for(j=0; j<n_size; j++) { for(j=0; j<n_size; j++) {
for(i=0; i<m_size; i++) { for(i=0; i<m_size; i++) {
tmp = 0; tmp = 0;
for(j1=0; j1<q_size; j1++) { for(j1=0; j1<q_size; j1++) {
j2 = mapj[j-j1]; j2 = mapj[j-j1];
if (j2 >= 0) { if (j2 >= 0) {
for(i1=0; i1<p_size; i1++) { for(i1=0; i1<p_size; i1++) {
i2 = mapi[i-i1]; i2 = mapi[i-i1];
if (i2 >= 0) { if (i2 >= 0) {
skipping to change at line 393 skipping to change at line 393
} }
', ',
Code => Code =>
init_vars( { vars => 'PDL_Double *tmp, kk; int count;', init_vars( { vars => 'PDL_Double *tmp, kk; int count;',
malloc => 'tmp = malloc(p_size*q_size*sizeof(PDL_Double) );', malloc => 'tmp = malloc(p_size*q_size*sizeof(PDL_Double) );',
check => '(tmp==NULL) || ' } ) . check => '(tmp==NULL) || ' } ) .
init_map("i") . init_map("i") .
init_map("j") . init_map("j") .
' '
threadloop %{ broadcastloop %{
for(j=0; j<n_size; j++) { for(j=0; j<n_size; j++) {
for(i=0; i<m_size; i++) { for(i=0; i<m_size; i++) {
count = 0; count = 0;
for(j1=0; j1<q_size; j1++) { for(j1=0; j1<q_size; j1++) {
j2 = mapj[j-j1]; j2 = mapj[j-j1];
if (j2 >= 0) if (j2 >= 0)
for(i1=0; i1<p_size; i1++) { for(i1=0; i1<p_size; i1++) {
i2 = mapi[i-i1]; i2 = mapi[i-i1];
if (i2 >= 0) { if (i2 >= 0) {
skipping to change at line 426 skipping to change at line 426
} /* for: j */ } /* for: j */
%} %}
free(mapj+1-q_size); free(mapi+1-p_size); free(tmp); free(mapj+1-q_size); free(mapi+1-p_size); free(tmp);
', ',
BadCode => BadCode =>
init_vars( { vars => 'PDL_Double kk, aa; int count, flag;' } ) . init_vars( { vars => 'PDL_Double kk, aa; int count, flag;' } ) .
init_map("i") . init_map("i") .
init_map("j") . init_map("j") .
' '
PDL_Double tmp[p_size*q_size]; PDL_Double tmp[p_size*q_size];
threadloop %{ broadcastloop %{
for(j=0; j<n_size; j++) { for(j=0; j<n_size; j++) {
for(i=0; i<m_size; i++) { for(i=0; i<m_size; i++) {
count = 0; count = 0;
flag = 0; flag = 0;
for(j1=0; j1<q_size; j1++) { for(j1=0; j1<q_size; j1++) {
j2 = mapj[j-j1]; j2 = mapj[j-j1];
if (j2 >= 0) if (j2 >= 0)
for(i1=0; i1<p_size; i1++) { for(i1=0; i1<p_size; i1++) {
i2 = mapi[i-i1]; i2 = mapi[i-i1];
skipping to change at line 523 skipping to change at line 523
return $c; return $c;
} }
', ',
Code => Code =>
init_vars( { vars => '$GENERIC() kk; int count;' }, [qw(m n)], [qw(p q)] ) . init_vars( { vars => '$GENERIC() kk; int count;' }, [qw(m n)], [qw(p q)] ) .
init_map("i") . init_map("i") .
init_map("j") . init_map("j") .
' '
$GENERIC() tmp[p_size*q_size]; $GENERIC() tmp[p_size*q_size];
threadloop %{ broadcastloop %{
for(j=0; j<n_size; j++) { for(j=0; j<n_size; j++) {
for(i=0; i<m_size; i++) { for(i=0; i<m_size; i++) {
count = 0; count = 0;
for(j1=0; j1<q_size; j1++) { for(j1=0; j1<q_size; j1++) {
j2 = mapj[j-j1]; j2 = mapj[j-j1];
if (j2 >= 0) if (j2 >= 0)
for(i1=0; i1<p_size; i1++) { for(i1=0; i1<p_size; i1++) {
i2 = mapi[i-i1]; i2 = mapi[i-i1];
if (i2 >= 0) { if (i2 >= 0) {
skipping to change at line 567 skipping to change at line 567
register int nx = 0.5*$COMP(wx); register int nx = 0.5*$COMP(wx);
register int ny = 0.5*$COMP(wy); register int ny = 0.5*$COMP(wy);
register int xs = $SIZE(n); register int xs = $SIZE(n);
register int ys = $SIZE(m); register int ys = $SIZE(m);
register int ez = $COMP(edgezero); register int ez = $COMP(edgezero);
double div, sum, lsum; double div, sum, lsum;
int xx,yy,y,ind1,ind2,first; int xx,yy,y,ind1,ind2,first;
div = 1/((2.0*nx+1)*(2.0*ny+1)); div = 1/((2.0*nx+1)*(2.0*ny+1));
threadloop %{ broadcastloop %{
first = 1; first = 1;
for (y=0;y<ys;y++) for (y=0;y<ys;y++)
for (xx=0; xx<nx; xx++) { for (xx=0; xx<nx; xx++) {
ind1 = xs-1-xx; /* rightmost strip */ ind1 = xs-1-xx; /* rightmost strip */
$b(n=>xx,m=>y) = EZ($a(n=>xx,m=>y)); $b(n=>xx,m=>y) = EZ($a(n=>xx,m=>y));
$b(n=>ind1,m=>y) = EZ($a(n=>ind1,m=>y)); $b(n=>ind1,m=>y) = EZ($a(n=>ind1,m=>y));
} }
for (xx=0;xx<xs;xx++) for (xx=0;xx<xs;xx++)
for (y=0; y<ny; y++) { for (y=0; y<ny; y++) {
ind1 = ys-1-y; /* topmost strip */ ind1 = ys-1-y; /* topmost strip */
skipping to change at line 668 skipping to change at line 668
BadDoc => BadDoc =>
'This routine does not handle bad values - use L</patchbad2d> instead', 'This routine does not handle bad values - use L</patchbad2d> instead',
HandleBad => 0, HandleBad => 0,
Pars => 'a(m,n); int bad(m,n); [o]b(m,n);', Pars => 'a(m,n); int bad(m,n); [o]b(m,n);',
Code => Code =>
'int m_size, n_size, i,j, i1,j1, i2,j2, norm; 'int m_size, n_size, i,j, i1,j1, i2,j2, norm;
double tmp; double tmp;
m_size = $SIZE(m); n_size = $SIZE(n); m_size = $SIZE(m); n_size = $SIZE(n);
threadloop %{ broadcastloop %{
for(j=0; j<n_size; j++) { for(j=0; j<n_size; j++) {
for(i=0; i<m_size; i++) { for(i=0; i<m_size; i++) {
$b(m=>i,n=>j) = $a(m=>i,n=>j); $b(m=>i,n=>j) = $a(m=>i,n=>j);
if ( $bad(m=>i,n=>j)==1 ) { if ( $bad(m=>i,n=>j)==1 ) {
tmp = 0; norm=0; tmp = 0; norm=0;
for(j1=-1; j1<=1; j1++) { for(j1=-1; j1<=1; j1++) {
j2 = j+j1; j2 = j+j1;
skipping to change at line 702 skipping to change at line 702
if (norm>0) { /* Patch */ if (norm>0) { /* Patch */
$b(m=>i,n=>j) = tmp/norm; $b(m=>i,n=>j) = tmp/norm;
} }
} /* if: bad() */ } /* if: bad() */
} /* for: i */ } /* for: i */
} /* for: j */ } /* for: j */
%} /* threadloop */ %} /* broadcastloop */
', # Code ', # Code
); );
pp_def('patchbad2d', pp_def('patchbad2d',
Doc=><<'EOD', Doc=><<'EOD',
=for ref =for ref
patch bad pixels out of 2D images containing bad values patch bad pixels out of 2D images containing bad values
skipping to change at line 741 skipping to change at line 741
Code => 'loop(n,m) %{ $b() = $a(); %}', # just copy Code => 'loop(n,m) %{ $b() = $a(); %}', # just copy
CopyBadStatusCode => '', # handled by BadCode CopyBadStatusCode => '', # handled by BadCode
BadCode => BadCode =>
'int m_size, n_size, i,j, i1,j1, i2,j2, norm, flag; 'int m_size, n_size, i,j, i1,j1, i2,j2, norm, flag;
double tmp; double tmp;
$GENERIC(a) a_val; $GENERIC(a) a_val;
flag = 0; flag = 0;
m_size = $SIZE(m); n_size = $SIZE(n); m_size = $SIZE(m); n_size = $SIZE(n);
threadloop %{ broadcastloop %{
for(j=0; j<n_size; j++) { for(j=0; j<n_size; j++) {
for(i=0; i<m_size; i++) { for(i=0; i<m_size; i++) {
a_val = $a(m=>i,n=>j); a_val = $a(m=>i,n=>j);
if ( $ISGOODVAR(a_val,a) ) { if ( $ISGOODVAR(a_val,a) ) {
$b(m=>i,n=>j) = a_val; $b(m=>i,n=>j) = a_val;
} else { } else {
tmp = 0; norm=0; tmp = 0; norm=0;
skipping to change at line 784 skipping to change at line 784
} else { } else {
$SETBAD(b(m=>i,n=>j)); $SETBAD(b(m=>i,n=>j));
flag = 1; flag = 1;
} }
} /* if: ISGOODVAR() */ } /* if: ISGOODVAR() */
} /* for: i */ } /* for: i */
} /* for: j */ } /* for: j */
%} /* threadloop */ %} /* broadcastloop */
/* handle bad flag */ /* handle bad flag */
if ( flag ) $PDLSTATESETBAD(b); if ( flag ) $PDLSTATESETBAD(b);
', # BadCode ', # BadCode
); );
pp_def('max2d_ind', pp_def('max2d_ind',
Doc=><<'EOD', Doc=><<'EOD',
=for ref =for ref
skipping to change at line 1303 skipping to change at line 1303
my $msk = zeroes(long,$im->dims); my $msk = zeroes(long,$im->dims);
PDL::polyfill_pp($msk, $ps, 1); PDL::polyfill_pp($msk, $ps, 1);
return $im->where($msk); return $im->where($msk);
} }
*polyfillv = \&PDL::polyfillv; *polyfillv = \&PDL::polyfillv;
EOPM EOPM
pp_addhdr(<<'EOF'); pp_addhdr(<<'EOF');
int getnewsize(int cols, int rows, float fangle, int *newcols, int *newrows); int getnewsize(PDL_Indx cols, PDL_Indx rows, float fangle, PDL_Indx *newcols, PD L_Indx *newrows);
typedef unsigned char imT; /* image type */ typedef unsigned char imT; /* image type */
int rotate(imT *im, imT *out, int cols, int rows, int nc, int nr, int rotate(imT *im, imT *out, int cols, int rows, int nc, int nr,
float fangle, imT bgval, int antialias); float fangle, imT bgval, int antialias);
EOF EOF
pp_add_exported('','rotnewsz'); pp_add_exported('','rotnewsz');
pp_addxs(' pp_addxs('
void void
rotnewsz(m,n,angle) rotnewsz(m,n,angle)
int m int m
int n int n
float angle float angle
PPCODE: PPCODE:
int newcols, newrows; PDL_Indx newcols, newrows;
if (getnewsize(m,n,angle,&newcols,&newrows) != 0) if (getnewsize(m,n,angle,&newcols,&newrows) != 0)
croak("wrong angle (should be between -90 and +90)"); croak("wrong angle (should be between -90 and +90)");
EXTEND(sp,2); EXTEND(sp,2);
PUSHs(sv_2mortal(newSVnv(newcols))); PUSHs(sv_2mortal(newSVnv(newcols)));
PUSHs(sv_2mortal(newSVnv(newrows))); PUSHs(sv_2mortal(newSVnv(newrows)));
'); ');
pp_def('rot2d', pp_def('rot2d',
HandleBad => 0, HandleBad => 0,
Pars => 'im(m,n); float angle(); bg(); int aa(); [o] om(p,q)', Pars => 'im(m,n); float angle(); bg(); int aa(); [o] om(p,q)',
Code => 'int ierr; Code => 'int ierr;
if ((ierr = rotate($P(im),$P(om),$SIZE(m),$SIZE(n),$SIZE(p), if ((ierr = rotate($P(im),$P(om),$SIZE(m),$SIZE(n),$SIZE(p),
$SIZE(q),$angle(),$bg(),$aa())) != 0) { $SIZE(q),$angle(),$bg(),$aa())) != 0) {
if (ierr == -1) if (ierr == -1)
croak("error during rotate, wrong angle"); $CROAK("error during rotate, wrong angle");
else else
croak("wrong output dims, did you set them?"); $CROAK("wrong output dims, did you set them?");
}', }',
# ugly workaround since $SIZE(m) and $SIZE(n) are not initialized RedoDimsCode => '
# when the redodimscode is called if (getnewsize($SIZE(m),$SIZE(n),
# need to fix this! $angle(), &$SIZE(p),
RedoDimsCode => 'int ncols, nrows; &$SIZE(q)) != 0)
if ($PDL(im)->ndims < 2) $CROAK("error during rotate, wrong angle");
croak("need > 2d ndarray");
if (getnewsize($PDL(im)->dims[0],$PDL(im)->dims[1],
$angle(), &ncols,
&nrows) != 0)
croak("error during rotate, wrong angle");
/* printf("o: %d, p: %d\n",ncols,nrows); */ /* printf("o: %d, p: %d\n",ncols,nrows); */
$SIZE(p) = ncols; ',
$SIZE(q) = nrows;',
GenericTypes => ['B'], GenericTypes => ['B'],
Doc => << 'EOD', Doc => << 'EOD',
=for ref =for ref
rotate an image by given C<angle> rotate an image by given C<angle>
=for example =for example
# rotate by 10.5 degrees with antialiasing, set missing values to 7 # rotate by 10.5 degrees with antialiasing, set missing values to 7
skipping to change at line 1404 skipping to change at line 1398
=cut =cut
EOD EOD
, ,
Code =>' Code =>'
int i,j,ii,jj,ii1,jj1,num; int i,j,ii,jj,ii1,jj1,num;
double x,y,dx,dy,y1,y2,y3,y4,t,u,sum; double x,y,dx,dy,y1,y2,y3,y4,t,u,sum;
if ($SIZE(q)>=$SIZE(n) && $SIZE(p)>=$SIZE(m)) { if ($SIZE(q)>=$SIZE(n) && $SIZE(p)>=$SIZE(m)) {
threadloop %{ broadcastloop %{
dx = ((double) ($SIZE(n)-1)) / ($SIZE(q)-1); dx = ((double) ($SIZE(n)-1)) / ($SIZE(q)-1);
dy = ((double) ($SIZE(m)-1)) / ($SIZE(p)-1); dy = ((double) ($SIZE(m)-1)) / ($SIZE(p)-1);
for(i=0,x=0;i<$SIZE(q);i++,x+=dx) { for(i=0,x=0;i<$SIZE(q);i++,x+=dx) {
for(j=0,y=0;j<$SIZE(p);j++,y+=dy) { for(j=0,y=0;j<$SIZE(p);j++,y+=dy) {
ii = (int) floor(x); ii = (int) floor(x);
if (ii>=($SIZE(n)-1)) ii = $SIZE(n)-2; if (ii>=($SIZE(n)-1)) ii = $SIZE(n)-2;
jj = (int) floor(y); jj = (int) floor(y);
if (jj>=($SIZE(m)-1)) jj = $SIZE(m)-2; if (jj>=($SIZE(m)-1)) jj = $SIZE(m)-2;
ii1 = ii+1; ii1 = ii+1;
jj1 = jj+1; jj1 = jj+1;
skipping to change at line 1461 skipping to change at line 1455
Code =>' Code =>'
int ix,iy,ox,oy,i,j,lx,ly,cx,cy,xx,yy,num; int ix,iy,ox,oy,i,j,lx,ly,cx,cy,xx,yy,num;
double kx,ky,temp; double kx,ky,temp;
ix = $SIZE(m); ix = $SIZE(m);
iy = $SIZE(n); iy = $SIZE(n);
ox = $SIZE(p); ox = $SIZE(p);
oy = $SIZE(q); oy = $SIZE(q);
if(ox >= ix && oy >= iy) { if(ox >= ix && oy >= iy) {
threadloop %{ broadcastloop %{
kx = ((double) (ox)) / (ix); kx = ((double) (ox)) / (ix);
ky = ((double) (oy)) / (iy); ky = ((double) (oy)) / (iy);
lx = 0; lx = 0;
for(i=0;i<ix;i++) { for(i=0;i<ix;i++) {
ly = 0; ly = 0;
for(j=0;j<iy;j++) { for(j=0;j<iy;j++) {
cx = rint((i+1)*kx)-1; cx = rint((i+1)*kx)-1;
cy = rint((j+1)*ky)-1; cy = rint((j+1)*ky)-1;
for(xx=lx;xx<=cx;xx++) for(xx=lx;xx<=cx;xx++)
for(yy=ly;yy<=cy;yy++) { for(yy=ly;yy<=cy;yy++) {
/* fprintf(stderr,"i: %d, j: %d, xx: %d, yy: %d\n",i,j,xx,yy); */ /* fprintf(stderr,"i: %d, j: %d, xx: %d, yy: %d\n",i,j,xx,yy); */
$O(p=>xx,q=>yy) += $Int(m=>i,n=>j); $O(p=>xx,q=>yy) += $Int(m=>i,n=>j);
} }
ly = cy + 1; ly = cy + 1;
} }
lx = cx + 1; lx = cx + 1;
} }
%} %}
} }
else if(ox < ix && oy < iy) { else if(ox < ix && oy < iy) {
threadloop %{ broadcastloop %{
kx = ((double) (ix)) / (ox); kx = ((double) (ix)) / (ox);
ky = ((double) (iy)) / (oy); ky = ((double) (iy)) / (oy);
lx = 0; lx = 0;
for(i=0;i<ox;i++) { for(i=0;i<ox;i++) {
ly = 0; ly = 0;
for(j=0;j<oy;j++) { for(j=0;j<oy;j++) {
cx = rint((i+1)*kx)-1; cx = rint((i+1)*kx)-1;
cy = rint((j+1)*ky)-1; cy = rint((j+1)*ky)-1;
temp = 0.0; temp = 0.0;
num = 0; num = 0;
skipping to change at line 1507 skipping to change at line 1501
num++; num++;
} }
$O(p=>i,q=>j) += temp/num; $O(p=>i,q=>j) += temp/num;
ly = cy + 1; ly = cy + 1;
} }
lx = cx + 1; lx = cx + 1;
} }
%} %}
} }
else if(ox >= ix && oy < iy) { else if(ox >= ix && oy < iy) {
threadloop %{ broadcastloop %{
kx = ((double) (ox)) / (ix); kx = ((double) (ox)) / (ix);
ky = ((double) (iy)) / (oy); ky = ((double) (iy)) / (oy);
lx = 0; lx = 0;
for(i=0;i<ix;i++) { for(i=0;i<ix;i++) {
ly = 0; ly = 0;
for(j=0;j<oy;j++) { for(j=0;j<oy;j++) {
cx = rint((i+1)*kx)-1; cx = rint((i+1)*kx)-1;
cy = rint((j+1)*ky)-1; cy = rint((j+1)*ky)-1;
temp = 0.0; temp = 0.0;
num = 0; num = 0;
skipping to change at line 1534 skipping to change at line 1528
/* fprintf(stderr,"2 i: %d, j: %d, xx: %d, yy: %d\n",i,j,xx,yy); */ /* fprintf(stderr,"2 i: %d, j: %d, xx: %d, yy: %d\n",i,j,xx,yy); */
$O(p=>xx,q=>j) += temp/num; $O(p=>xx,q=>j) += temp/num;
} }
ly = cy + 1; ly = cy + 1;
} }
lx = cx + 1; lx = cx + 1;
} }
%} %}
} }
else if(ox < ix && oy >= iy) { else if(ox < ix && oy >= iy) {
threadloop %{ broadcastloop %{
kx = ((double) (ix)) / (ox); kx = ((double) (ix)) / (ox);
ky = ((double) (oy)) / (iy); ky = ((double) (oy)) / (iy);
lx = 0; lx = 0;
for(i=0;i<ox;i++) { for(i=0;i<ox;i++) {
ly = 0; ly = 0;
for(j=0;j<iy;j++) { for(j=0;j<iy;j++) {
cx = rint((i+1)*kx)-1; cx = rint((i+1)*kx)-1;
cy = rint((j+1)*ky)-1; cy = rint((j+1)*ky)-1;
temp = 0.0; temp = 0.0;
num = 0; num = 0;
skipping to change at line 2184 skipping to change at line 2178
sumrs ; sumrs ;
double x, y ; double x, y ;
int px, py ; int px, py ;
int tabx, taby ; int tabx, taby ;
double *kernel, *poly ; double *kernel, *poly ;
int da[16], db[16] ; int da[16], db[16] ;
/* Generate default interpolation kernel */ /* Generate default interpolation kernel */
kernel = generate_interpolation_kernel( $COMP(kernel_type) ) ; kernel = generate_interpolation_kernel( $COMP(kernel_type) ) ;
if (kernel == NULL) { if (kernel == NULL) {
croak( "Ran out of memory building kernel\n" ); $CROAK( "Ran out of memory building kernel\n" );
} }
/* Compute sizes */ /* Compute sizes */
ncoeff = $SIZE(np); ncoeff = $SIZE(np);
lx_out = $SIZE(m); /* is this right? */ lx_out = $SIZE(m); /* is this right? */
ly_out = $SIZE(n); ly_out = $SIZE(n);
lx_3 = lx_out - 3; lx_3 = lx_out - 3;
ly_3 = ly_out - 3; ly_3 = ly_out - 3;
/* Pre compute leaps for 16 closest neighbors positions */ /* Pre compute leaps for 16 closest neighbors positions */
skipping to change at line 2218 skipping to change at line 2212
da[11] = 2; db[11] = 1; da[11] = 2; db[11] = 1;
da[12] = -1; db[12] = 2; da[12] = -1; db[12] = 2;
da[13] = 0; db[13] = 2; da[13] = 0; db[13] = 2;
da[14] = 1; db[14] = 2; da[14] = 1; db[14] = 2;
da[15] = 2; db[15] = 2; da[15] = 2; db[15] = 2;
/* allocate memory for polynomial */ /* allocate memory for polynomial */
poly = malloc( ncoeff * sizeof(double) ); poly = malloc( ncoeff * sizeof(double) );
if ( poly == NULL ) { if ( poly == NULL ) {
croak( "Ran out of memory\n" ); $CROAK( "Ran out of memory\n" );
} }
poly[0] = 1.0; poly[0] = 1.0;
/* Loop over the output image */ /* Loop over the output image */
threadloop %{ broadcastloop %{
loop(n) %{ loop(n) %{
/* fill in poly array */ /* fill in poly array */
for ( k = 1; k < ncoeff; k++ ) { for ( k = 1; k < ncoeff; k++ ) {
poly[k] = (double) n * poly[k-1]; poly[k] = (double) n * poly[k-1];
} }
loop(m) %{ loop(m) %{
/* Compute the original source for this pixel */ /* Compute the original source for this pixel */
skipping to change at line 2295 skipping to change at line 2289
rsc[2]*neighbors[14] + rsc[2]*neighbors[14] +
rsc[3]*neighbors[15] ) ; rsc[3]*neighbors[15] ) ;
/* Copy the value to the output image */ /* Copy the value to the output image */
$warp() = ($GENERIC()) (cur/sumrs); $warp() = ($GENERIC()) (cur/sumrs);
} /* if: edge or interior */ } /* if: edge or interior */
%} /* loop(m) */ %} /* loop(m) */
%} /* loop(n) */ %} /* loop(n) */
%} /* threadloop */ %} /* broadcastloop */
free(poly); free(poly);
kernel_free(kernel) ; kernel_free(kernel) ;
', ',
); # pp_def: warp2d ); # pp_def: warp2d
pp_addxs( ' pp_addxs( '
int int
skipping to change at line 2370 skipping to change at line 2364
', ',
Pars => '[o] x(n); [o] k(n);', Pars => '[o] x(n); [o] k(n);',
OtherPars => 'char *name;', OtherPars => 'char *name;',
GenericTypes => [ 'D' ], GenericTypes => [ 'D' ],
Code => ' Code => '
double *kernel, xx; double *kernel, xx;
if ( $SIZE(n) != KERNEL_SAMPLES ) { if ( $SIZE(n) != KERNEL_SAMPLES ) {
croak( "Internal error in warp2d_kernel - mismatch in kernel size\n" ); $CROAK( "Internal error in warp2d_kernel - mismatch in kernel size\n" );
} }
kernel = generate_interpolation_kernel($COMP(name)); kernel = generate_interpolation_kernel($COMP(name));
if ( kernel == NULL ) { if ( kernel == NULL ) {
croak( "unable to allocate memory for kernel" ); $CROAK( "unable to allocate memory for kernel" );
} }
/* fill in ndarrays */ /* fill in ndarrays */
xx = 0.0; xx = 0.0;
threadloop %{ broadcastloop %{
loop (n) %{ loop (n) %{
$x() = xx; $x() = xx;
$k() = kernel[n]; $k() = kernel[n];
xx += 1.0 / (double) TABSPERPIX; xx += 1.0 / (double) TABSPERPIX;
%} %}
%} %}
/* free the kernel */ /* free the kernel */
kernel_free( kernel ); kernel_free( kernel );
 End of changes. 30 change blocks. 
40 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)