Miscellaneous 2D image processing functions - for want of anywhere else to put them
use PDL::Image2D;
Signature: (a(m,n); kern(p,q); [o]b(m,n); int opt)
$new = conv2d $old, $kernel, {OPTIONS}
perldl> $smoothed = conv2d $image, ones(3,3), {Boundary => Reflect}
Boundary - controls what values are assumed for the image when kernel crosses its edge: => Default - periodic boundary conditions (i.e. wrap around axis) => Reflect - reflect at boundary => Truncate - truncate at boundary
Signature: (a(m,n); kern(p,q); [o]b(m,n); int opt)
Note: only points in the kernel >0 are included in the median, other points are weighted by the kernel value (medianing lots of zeroes is rather pointless)
$new = med2d $old, $kernel, {OPTIONS}
perldl> $smoothed = med2d $image, ones(3,3), {Boundary => Reflect}
Boundary - controls what values are assumed for the image when kernel crosses its edge: => Default - periodic boundary conditions (i.e. wrap around axis) => Reflect - reflect at boundary => Truncate - truncate at boundary
Signature: (a(m,n); int bad(m,n); [o]b(m,n))
$patched
= patch2d $data, $bad;
$bad
is a 2D mask array where 1=bad pixel 0=good pixel. Pixels
are replaced by the average of their non-bad neighbours.
Signature: (a(m,n); [o]b(); int [o]c(); int[o]d())
Contributed by Tim Jeness
Signature: (im(m,n); x(); y(); box(); [o]xcen(); [o]ycen())
$box
is the full-width of the box, i.e. the window is +/-
$box/2
Signature: (a(m,n); [o]b(m,n))
Connected 8-component labeling of a binary image.
Connected 8-component labeling of 0,1 image - i.e. find seperate segmented objects and fill object pixels with object number
perldl> $segmented
=
cc8compt($image>$threshold);