Image::Find::Paths - Find paths in an image.
Use new to create and analyze a new image, then print to visualize the paths detected, or path to get the coordinates of points along each path in sequential order with an estimate of the thickness of the path at each point.
Find paths in an image.
The following sections describe the methods in each functional area of this module. For an alphabetic listing of all methods by name see Index.
Find paths in an image
Find paths in an image represented as a string.
Parameter Description 1 $string String of blanks; non blanks; new lines defining the image
Example:
my $d = new(<<END); 11 111 11 1 111 1111 111 111 1 111111 1 111 111 1111 111 111 11 1111111 1 1 11 11111 1 1 1 111 1 1 1 1111111111 1 111111 1 111 1 1 1 END is_deeply [$d->count, $d->x, $d->y, $d->numberOfPaths], [96, 80, 10, 6]; ok nws($d->print) eq nws(<<END); 0 1 2 3 4 5 6 7 8 01234567890123456789012345678901234567890123456789012345678901234567890123456789 0 E1 E 1 11 23 2 1111 3 3 1 322E S 3 4 111 2 E1 2S 5 11 221S 1 6 11 23 1 E 7 1 3 1 S 1 8 11111112 1 E1111 1 9 S S Image: X = 80, Y = 10, Paths = 6 END is_deeply $d->path(5), [[79,4, 1], [78,4, 2], [78,3, 3], [78,2, 3], [78,1, 3], [77,1, 2], [77,0, 1]];
This is a static method and so should be invoked as:
Image::Find::Paths::new
Number of paths in the image.
Parameter Description 1 $i Image
is_deeply [$d->count, $d->x, $d->y, $d->numberOfPaths], [96, 80, 10, 6];
Returns an array of arrays [x, y, t] where x, y are the coordinates of each point sequentially along the specified path and t is the estimated thickness of the path at that point. Paths are numbered from 1 to numberOfPaths.
Parameter Description 1 $i Image 2 $partition Partition
is_deeply $d->path(5), [[79,4, 1], [78,4, 2], [78,3, 3], [78,2, 3], [78,1, 3], [77,1, 2], [77,0, 1]];
Print the image: use S, E to show the start and end of each path, otherwise use the estimated thickness of the path at each point to mark the track of each path within each connected partition of the image.
ok nws($d->print) eq nws(<<END); 0 1 2 3 4 5 6 7 8 01234567890123456789012345678901234567890123456789012345678901234567890123456789 0 E1 E 1 11 23 2 1111 3 3 1 322E S 3 4 111 2 E1 2S 5 11 221S 1 6 11 23 1 E 7 1 3 1 S 1 8 11111112 1 E1111 1 9 S S Image: X = 80, Y = 10, Paths = 6 END
Attributes of an image
Number of points in the image.
Image data points.
Number of partitions in the image.
End points for each path.
Start points for each path.
Path for each partition.
Image dimension in x.
Image dimension in y.
Clone an image.
is_deeply $d, $d->clone;
Clone a partition of an image.
Count the pixels in an image.
Clone an image adding height to each pixel.
Partition the images into disjoint sets of connected points.
Locate the pixels in the image that are connected to a pixel with a specified value.
Parameter Description 1 $i Image 2 $x X coordinate of first point in partition 3 $y Y coordinate of first point in partition
Find the starting point for a path in a partition.
Find the other end of a path in a partition.
Traverse to the other end of a partition.
Parameter Description 1 $I Image 2 $partition Partition 3 $X Start x coordinate 4 $Y Start y coordinate
Return the pixels to search from around a given pixel.
Parameter Description 1 $i Image 2 $partition Partition 3 $x X coordinate of center of search 4 $y Y coordinate of center of search.
Confirm that the specified pixel is at level one.
Parameter Description 1 $i Image 2 $partition Partition 3 $pixel Pixel
Return the highest pixels to search from around a given pixel.
Parameter Description 1 $i Image 2 $partition Partition 3 $seen Pixels already visited 4 $depth Depth of search 5 $x X coordinate of center of search 6 $y Y coordinate of center of search.
Find the shortest path between the start and the end points of a partition.
Parameter Description 1 $I Image 2 $i Image height clone 3 $partition Partition
Find the (estimated) width of the path at each point.
Parameter Description 1 $I Image 2 $partition Partition
Find the (estimated) width of each path at each point.
Print a header for the image so we can locate pixels by their coordinates.
1 checkAtLevelOne
2 clone
3 clonePartition
4 count
5 countPixels
6 end
7 height
8 image
9 mapPartition
10 new
11 numberOfPaths
12 partition
13 partitionEnd
14 partitionPath
15 partitions
16 partitionStart
17 path
18 print
19 printHeader
20 searchArea
21 searchAreaHighest
22 shortestPathBetweenEndPoints
23 start
24 traverseToOtherEnd
25 widthOfPath
26 widthOfPaths
27 x
28 y
This module is written in 100% Pure Perl and, thus, it is easy to read, use, modify and install.
Standard Module::Build process for building and installing modules:
perl Build.PL ./Build ./Build test ./Build install
philiprbrenan@gmail.com
http://www.appaapps.com
Copyright (c) 2016-2018 Philip R Brenan.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
To install Image::Find::Paths, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Image::Find::Paths
CPAN shell
perl -MCPAN -e shell install Image::Find::Paths
For more information on module installation, please visit the detailed CPAN module installation guide.