use PDL::ImageND; my $edge_detector_kern = pdl [ -1, 1 ]; my $upper_edges = convolveND( $mask, $edge_detector_kern ); # where it is -1 is the upper edge of a region of zeroes # where it is 1 is the upper edge of a region of ones