PDL::Image2D#
Two-dimensional image processing: median filters, polygon filling, connected components, rotation and warping.
use PDL;
use PDL::Image2D;
my $im = zeroes(long, 5, 5);
polyfill($im, float([[1, 1], [3, 1], [3, 3], [1, 3]]), 7);
print $im->sum, " ", sequence(5, 4)->med2d(ones(3, 3))->at(2, 2), "\n"; # 63 12
med2d and med2df are median filters (by a kernel, or by a box); polyfill, polyfillv, pnpoly fill or select the inside of a polygon; cc8compt, cc4compt and ccNcompt label connected components; max2d_ind and centroid2d locate features; rot2d and rotnewsz rotate a byte image; fitwarp2d, applywarp2d, warp2d and warp2d_kernel fit and apply a polynomial distortion; conv2d convolves with a kernel ({ Boundary => 'Reflect' } and the like choose the edge treatment), box2d is a box-mean filter, patch2d and patchbad2d replace marked or bad pixels by the mean of their neighbours, bilin2d and rescale2d resample into an ndarray of another size, and crop gives the bounding box of the non-zero pixels.
polyfill_pp, pnpoly_pp and pnpolyfill_pp are the kernels under polyfill, pnpoly and polyfillv.
This is PDL::Image2D of PDL 2.106: upstream’s Perl, unchanged, over PDL’s own kernels and support C run by pperl’s engine.
Functions#
Other Functions#
rotnewsz#
($cols, $rows) = rotnewsz($m, $n, $angle) - the size of an $m by $n image once rot2d has turned it by $angle degrees.