"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "GENERATED/PDL/Image2D.pm" between
PDL-2.078.tar.gz and PDL-2.079.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.pm  (PDL-2.078):Image2D.pm  (PDL-2.079)
# #
# GENERATED WITH PDL::PP! Don't modify! # GENERATED WITH PDL::PP! Don't modify!
# #
package PDL::Image2D; package PDL::Image2D;
our @EXPORT_OK = qw( conv2d med2d med2df box2d patch2d patchbad2d max2d_ind cent roid2d cc8compt cc4compt ccNcompt polyfill pnpoly polyfillv rotnewsz rot2d bilin 2d rescale2d fitwarp2d applywarp2d warp2d warp2d_kernel warp2d_kernel ); our @EXPORT_OK = qw( conv2d med2d med2df box2d patch2d patchbad2d max2d_ind cent roid2d crop cc8compt cc4compt ccNcompt polyfill pnpoly polyfillv rotnewsz rot2d bilin2d rescale2d fitwarp2d applywarp2d warp2d warp2d_kernel warp2d_kernel );
our %EXPORT_TAGS = (Func=>\@EXPORT_OK); our %EXPORT_TAGS = (Func=>\@EXPORT_OK);
use PDL::Core; use PDL::Core;
use PDL::Exporter; use PDL::Exporter;
use DynaLoader; use DynaLoader;
our @ISA = ( 'PDL::Exporter','DynaLoader' ); our @ISA = ( 'PDL::Exporter','DynaLoader' );
push @PDL::Core::PP, __PACKAGE__; push @PDL::Core::PP, __PACKAGE__;
bootstrap PDL::Image2D ; bootstrap PDL::Image2D ;
skipping to change at line 348 skipping to change at line 348
if all neighbours are bad, the output is set bad. if all neighbours are bad, the output is set bad.
If the input ndarray contains I<no> bad values, then a straight copy If the input ndarray contains I<no> bad values, then a straight copy
is performed (see L</patch2d>). is performed (see L</patch2d>).
=for bad =for bad
patchbad2d handles bad values. The output ndarray I<may> contain patchbad2d handles bad values. The output ndarray I<may> contain
bad values, depending on the pattern of bad values in the input ndarray. bad values, depending on the pattern of bad values in the input ndarray.
=cut =cut
#line 427 "Image2D.pm" #line 425 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*patchbad2d = \&PDL::patchbad2d; *patchbad2d = \&PDL::patchbad2d;
#line 434 "Image2D.pm" #line 432 "Image2D.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 max2d_ind =head2 max2d_ind
=for sig =for sig
Signature: (a(m,n); [o]val(); int [o]x(); int[o]y()) Signature: (a(m,n); [o]val(); int [o]x(); int[o]y())
=for ref =for ref
skipping to change at line 375 skipping to change at line 375
Return value/position of maximum value in 2D image Return value/position of maximum value in 2D image
Contributed by Tim Jeness Contributed by Tim Jeness
=for bad =for bad
Bad values are excluded from the search. If all pixels Bad values are excluded from the search. If all pixels
are bad then the output is set bad. are bad then the output is set bad.
=cut =cut
#line 465 "Image2D.pm" #line 463 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*max2d_ind = \&PDL::max2d_ind; *max2d_ind = \&PDL::max2d_ind;
#line 472 "Image2D.pm" #line 470 "Image2D.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 centroid2d =head2 centroid2d
=for sig =for sig
Signature: (im(m,n); x(); y(); box(); [o]xcen(); [o]ycen()) Signature: (im(m,n); x(); y(); box(); [o]xcen(); [o]ycen())
=for ref =for ref
skipping to change at line 404 skipping to change at line 404
C<$box> is the full-width of the box, i.e. the window C<$box> is the full-width of the box, i.e. the window
is C<+/- $box/2>. is C<+/- $box/2>.
=for bad =for bad
Bad pixels are excluded from the centroid calculation. If all elements are Bad pixels are excluded from the centroid calculation. If all elements are
bad (or the pixel sum is 0 - but why would you be centroiding bad (or the pixel sum is 0 - but why would you be centroiding
something with negatives in...) then the output values are set bad. something with negatives in...) then the output values are set bad.
=cut =cut
#line 503 "Image2D.pm" #line 501 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*centroid2d = \&PDL::centroid2d; *centroid2d = \&PDL::centroid2d;
#line 510 "Image2D.pm" #line 508 "Image2D.pm"
#line 803 "image2d.pd" #line 797 "image2d.pd"
=head2 crop
=for ref
Return bounding box of given mask in an C<indx> ndarray, so it can broadcast.
Use other operations (such as L<PDL::Bad/isgood>, or
L<PDL::Primitive/eqvec> with a colour vector) to create a mask suitable
for your application.
=for example
$x1x2y1y2 = crop($image);
=cut
*crop = \&PDL::crop;
sub PDL::crop {
my ($mask) = @_;
$mask->xchg(0,1)->orover->_which_int(my $out = null, null);
$out->badflag(1); $out->badvalue(-1);
my ($x1, $x2) = $out->minmaximum;
$mask->orover->_which_int($out = null, null);
$out->badflag(1); $out->badvalue(-1);
my ($y1, $y2) = $out->minmaximum;
$x1->cat($x2, $y1, $y2)->mv(-1,0);
}
#line 540 "Image2D.pm"
#line 827 "image2d.pd"
=head2 cc8compt =head2 cc8compt
=for ref =for ref
Connected 8-component labeling of a binary image. Connected 8-component labeling of a binary image.
Connected 8-component labeling of 0,1 image - i.e. find separate Connected 8-component labeling of 0,1 image - i.e. find separate
segmented objects and fill object pixels with object number. segmented objects and fill object pixels with object number.
8-component labeling includes all neighboring pixels. 8-component labeling includes all neighboring pixels.
skipping to change at line 454 skipping to change at line 484
sub PDL::cc8compt{ sub PDL::cc8compt{
return ccNcompt(shift,8); return ccNcompt(shift,8);
} }
*cc8compt = \&PDL::cc8compt; *cc8compt = \&PDL::cc8compt;
sub PDL::cc4compt{ sub PDL::cc4compt{
return ccNcompt(shift,4); return ccNcompt(shift,4);
} }
*cc4compt = \&PDL::cc4compt; *cc4compt = \&PDL::cc4compt;
#line 558 "Image2D.pm" #line 588 "Image2D.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 ccNcompt =head2 ccNcompt
=for sig =for sig
Signature: (a(m,n); int+ [o]b(m,n); int con) Signature: (a(m,n); int+ [o]b(m,n); int con)
=for ref =for ref
skipping to change at line 488 skipping to change at line 518
$segmented2 = ccNcompt( $image > $threshold, 8); $segmented2 = ccNcompt( $image > $threshold, 8);
where the second parameter specifies the connectivity (4 or 8) of the labeling. where the second parameter specifies the connectivity (4 or 8) of the labeling.
=for bad =for bad
ccNcompt ignores the bad-value flag of the input ndarrays. ccNcompt ignores the bad-value flag of the input ndarrays.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 601 "Image2D.pm" #line 631 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*ccNcompt = \&PDL::ccNcompt; *ccNcompt = \&PDL::ccNcompt;
#line 608 "Image2D.pm" #line 638 "Image2D.pm"
#line 972 "image2d.pd" #line 996 "image2d.pd"
=head2 polyfill =head2 polyfill
=for ref =for ref
fill the area of the given polygon with the given colour. fill the area of the given polygon with the given colour.
This function works inplace, i.e. modifies C<im>. This function works inplace, i.e. modifies C<im>.
=for usage =for usage
skipping to change at line 549 skipping to change at line 579
} }
else else
{ {
PDL::polyfill_pp($im,$ps,$colour); PDL::polyfill_pp($im,$ps,$colour);
} }
return $im; return $im;
} }
*polyfill = \&PDL::polyfill; *polyfill = \&PDL::polyfill;
#line 666 "Image2D.pm" #line 696 "Image2D.pm"
#line 1029 "image2d.pd" #line 1053 "image2d.pd"
=head2 pnpoly =head2 pnpoly
=for ref =for ref
'points in a polygon' selection from a 2-D ndarray 'points in a polygon' selection from a 2-D ndarray
=for usage =for usage
$mask = $img->pnpoly($ps); $mask = $img->pnpoly($ps);
skipping to change at line 630 skipping to change at line 660
my $testy = PDL::Core::topdl($ty)->dummy(0); my $testy = PDL::Core::topdl($ty)->dummy(0);
my $vertxj = PDL::Core::topdl($vertx)->rotate(1); my $vertxj = PDL::Core::topdl($vertx)->rotate(1);
my $vertyj = PDL::Core::topdl($verty)->rotate(1); my $vertyj = PDL::Core::topdl($verty)->rotate(1);
my $mask = ( ($verty>$testy) == ($vertyj>$testy) ); my $mask = ( ($verty>$testy) == ($vertyj>$testy) );
my $c = sumover( ! $mask & ( $testx < ($vertxj-$vertx) * ($testy-$verty) my $c = sumover( ! $mask & ( $testx < ($vertxj-$vertx) * ($testy-$verty)
/ ($vertyj-$verty+$mask) + $vertx) ) % 2; / ($vertyj-$verty+$mask) + $vertx) ) % 2;
return $c; return $c;
} }
*pnpoly = \&PDL::pnpoly; *pnpoly = \&PDL::pnpoly;
#line 750 "Image2D.pm" #line 780 "Image2D.pm"
#line 1112 "image2d.pd" #line 1136 "image2d.pd"
=head2 polyfillv =head2 polyfillv
=for ref =for ref
return the (dataflowed) area of an image described by a polygon return the (dataflowed) area of an image described by a polygon
=for usage =for usage
polyfillv($im,$ps,[\%options]); polyfillv($im,$ps,[\%options]);
skipping to change at line 684 skipping to change at line 714
my $parsed = PDL::Options->new({'Method' => undef}); my $parsed = PDL::Options->new({'Method' => undef});
$parsed->options($opt); $parsed->options($opt);
return $im->where(PDL::pnpoly_pp($im, $ps)) if $parsed->current-> {'Method'} eq 'pnpoly'; return $im->where(PDL::pnpoly_pp($im, $ps)) if $parsed->current-> {'Method'} eq 'pnpoly';
} }
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;
#line 807 "Image2D.pm" #line 837 "Image2D.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 rot2d =head2 rot2d
=for sig =for sig
Signature: (im(m,n); float angle(); bg(); int aa(); [o] om(p,q)) Signature: (im(m,n); float angle(); bg(); int aa(); [o] om(p,q))
=for ref =for ref
skipping to change at line 726 skipping to change at line 756
L<PDL::Transform> offers a more general interface to L<PDL::Transform> offers a more general interface to
distortions, including rotation, with various types of sampling; but distortions, including rotation, with various types of sampling; but
rot2d is faster. rot2d is faster.
=for bad =for bad
rot2d ignores the bad-value flag of the input ndarrays. rot2d ignores the bad-value flag of the input ndarrays.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 857 "Image2D.pm" #line 887 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*rot2d = \&PDL::rot2d; *rot2d = \&PDL::rot2d;
#line 864 "Image2D.pm" #line 894 "Image2D.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 bilin2d =head2 bilin2d
=for sig =for sig
Signature: (Int(n,m); O(q,p)) Signature: (Int(n,m); O(q,p))
=for ref =for ref
skipping to change at line 753 skipping to change at line 783
Bilinearly maps the first ndarray in the second. The Bilinearly maps the first ndarray in the second. The
interpolated values are actually added to the second interpolated values are actually added to the second
ndarray which is supposed to be larger than the first one. ndarray which is supposed to be larger than the first one.
=for bad =for bad
bilin2d ignores the bad-value flag of the input ndarrays. bilin2d ignores the bad-value flag of the input ndarrays.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 894 "Image2D.pm" #line 924 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*bilin2d = \&PDL::bilin2d; *bilin2d = \&PDL::bilin2d;
#line 901 "Image2D.pm" #line 931 "Image2D.pm"
#line 1058 "../../blib/lib/PDL/PP.pm" #line 1058 "../../blib/lib/PDL/PP.pm"
=head2 rescale2d =head2 rescale2d
=for sig =for sig
Signature: (Int(m,n); O(p,q)) Signature: (Int(m,n); O(p,q))
=for ref =for ref
skipping to change at line 785 skipping to change at line 815
tracking, consider using L<PDL::Transform::map|PDL::Transform/map> tracking, consider using L<PDL::Transform::map|PDL::Transform/map>
instead: it does these things, at some speed penalty compared to instead: it does these things, at some speed penalty compared to
rescale2d. rescale2d.
=for bad =for bad
rescale2d ignores the bad-value flag of the input ndarrays. rescale2d ignores the bad-value flag of the input ndarrays.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 936 "Image2D.pm" #line 966 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*rescale2d = \&PDL::rescale2d; *rescale2d = \&PDL::rescale2d;
#line 943 "Image2D.pm" #line 973 "Image2D.pm"
#line 1426 "image2d.pd" #line 1450 "image2d.pd"
=head2 fitwarp2d =head2 fitwarp2d
=for ref =for ref
Find the best-fit 2D polynomial to describe Find the best-fit 2D polynomial to describe
a coordinate transformation. a coordinate transformation.
=for usage =for usage
skipping to change at line 1215 skipping to change at line 1245
# #
my $mat = _mkbasis( ones(byte,$nf,$nf), $npts, $u, $v ); my $mat = _mkbasis( ones(byte,$nf,$nf), $npts, $u, $v );
my $x = reshape( $mat x $px->clump(-1)->transpose(), $npts ); my $x = reshape( $mat x $px->clump(-1)->transpose(), $npts );
my $y = reshape( $mat x $py->clump(-1)->transpose(), $npts ); my $y = reshape( $mat x $py->clump(-1)->transpose(), $npts );
return ( $x, $y ); return ( $x, $y );
} # sub: applywarp2d } # sub: applywarp2d
*applywarp2d = \&PDL::applywarp2d; *applywarp2d = \&PDL::applywarp2d;
#line 1372 "Image2D.pm" #line 1402 "Image2D.pm"
#line 1861 "image2d.pd" #line 1885 "image2d.pd"
=head2 warp2d =head2 warp2d
=for sig =for sig
Signature: (img(m,n); double px(np,np); double py(np,np); [o] warp(m,n); { opt ions }) Signature: (img(m,n); double px(np,np); double py(np,np); [o] warp(m,n); { opt ions })
=for ref =for ref
Warp a 2D image given a polynomial describing the I<reverse> mapping. Warp a 2D image given a polynomial describing the I<reverse> mapping.
skipping to change at line 1349 skipping to change at line 1379
# note: convert to lower case # note: convert to lower case
sub _check_kernel ($$) { sub _check_kernel ($$) {
my $kernel = lc shift; my $kernel = lc shift;
my $code = shift; my $code = shift;
barf "Unknown kernel $kernel sent to $code\n" . barf "Unknown kernel $kernel sent to $code\n" .
"\tmust be one of [" . join(',',keys %warp2d) . "]\n" "\tmust be one of [" . join(',',keys %warp2d) . "]\n"
unless exists $warp2d{$kernel}; unless exists $warp2d{$kernel};
return $kernel; return $kernel;
} }
} }
#line 1509 "Image2D.pm" #line 1539 "Image2D.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
sub PDL::warp2d { sub PDL::warp2d {
my $opts = PDL::Options->new( { KERNEL => "tanh", NOVAL => 0 } ); my $opts = PDL::Options->new( { KERNEL => "tanh", NOVAL => 0 } );
$opts->options( pop(@_) ) if ref($_[$#_]) eq "HASH"; $opts->options( pop(@_) ) if ref($_[$#_]) eq "HASH";
die "Usage: warp2d( in(m,n), px(np,np); py(np,np); [o] out(m,n), {Options} ) " die "Usage: warp2d( in(m,n), px(np,np); py(np,np); [o] out(m,n), {Options} ) "
if $#_<2 || $#_>3; if $#_<2 || $#_>3;
my $img = shift; my $img = shift;
skipping to change at line 1371 skipping to change at line 1401
my $py = shift; my $py = shift;
my $out = $#_ == -1 ? PDL->null() : shift; my $out = $#_ == -1 ? PDL->null() : shift;
# safety checks # safety checks
my $copt = $opts->current(); my $copt = $opts->current();
my $kernel = _check_kernel( $$copt{KERNEL}, "warp2d" ); my $kernel = _check_kernel( $$copt{KERNEL}, "warp2d" );
&PDL::_warp2d_int( $img, $px, $py, $out, $kernel, $$copt{NOVAL} ); &PDL::_warp2d_int( $img, $px, $py, $out, $kernel, $$copt{NOVAL} );
return $out; return $out;
} }
#line 1535 "Image2D.pm" #line 1565 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*warp2d = \&PDL::warp2d; *warp2d = \&PDL::warp2d;
#line 1542 "Image2D.pm" #line 1572 "Image2D.pm"
#line 2175 "image2d.pd" #line 2199 "image2d.pd"
=head2 warp2d_kernel =head2 warp2d_kernel
=for ref =for ref
Return the specified kernel, as used by L</warp2d> Return the specified kernel, as used by L</warp2d>
=for usage =for usage
( $x, $k ) = warp2d_kernel( $name ) ( $x, $k ) = warp2d_kernel( $name )
The valid values for C<$name> are the same as the C<KERNEL> option The valid values for C<$name> are the same as the C<KERNEL> option
of L<warp2d()|/warp2d>. of L<warp2d()|/warp2d>.
=for example =for example
line warp2d_kernel( "hamming" ); line warp2d_kernel( "hamming" );
=cut =cut
#line 1568 "Image2D.pm" #line 1598 "Image2D.pm"
#line 1059 "../../blib/lib/PDL/PP.pm" #line 1059 "../../blib/lib/PDL/PP.pm"
sub PDL::warp2d_kernel ($) { sub PDL::warp2d_kernel ($) {
my $kernel = _check_kernel( shift, "warp2d_kernel" ); my $kernel = _check_kernel( shift, "warp2d_kernel" );
my $nelem = _get_kernel_size(); my $nelem = _get_kernel_size();
my $x = zeroes( $nelem ); my $x = zeroes( $nelem );
my $k = zeroes( $nelem ); my $k = zeroes( $nelem );
&PDL::_warp2d_kernel_int( $x, $k, $kernel ); &PDL::_warp2d_kernel_int( $x, $k, $kernel );
return ( $x, $k ); return ( $x, $k );
# return _get_kernel( $kernel ); # return _get_kernel( $kernel );
} }
*warp2d_kernel = \&PDL::warp2d_kernel; *warp2d_kernel = \&PDL::warp2d_kernel;
#line 1589 "Image2D.pm" #line 1619 "Image2D.pm"
#line 1060 "../../blib/lib/PDL/PP.pm" #line 1060 "../../blib/lib/PDL/PP.pm"
*warp2d_kernel = \&PDL::warp2d_kernel; *warp2d_kernel = \&PDL::warp2d_kernel;
#line 1596 "Image2D.pm" #line 1626 "Image2D.pm"
#line 29 "image2d.pd" #line 29 "image2d.pd"
=head1 AUTHORS =head1 AUTHORS
Copyright (C) Karl Glazebrook 1997 with additions by Robin Williams Copyright (C) Karl Glazebrook 1997 with additions by Robin Williams
(rjrw@ast.leeds.ac.uk), Tim Jeness (timj@jach.hawaii.edu), (rjrw@ast.leeds.ac.uk), Tim Jeness (timj@jach.hawaii.edu),
and Doug Burke (burke@ifa.hawaii.edu). and Doug Burke (burke@ifa.hawaii.edu).
All rights reserved. There is no warranty. You are allowed All rights reserved. There is no warranty. You are allowed
to redistribute this software / documentation under certain to redistribute this software / documentation under certain
conditions. For details, see the file COPYING in the PDL conditions. For details, see the file COPYING in the PDL
distribution. If this file is separated from the PDL distribution, distribution. If this file is separated from the PDL distribution,
the copyright notice should be included in the file. the copyright notice should be included in the file.
=cut =cut
#line 1618 "Image2D.pm" #line 1648 "Image2D.pm"
# Exit with OK status # Exit with OK status
1; 1;
 End of changes. 34 change blocks. 
34 lines changed or deleted 64 lines changed or added

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