Name
Image::Find::Paths - Find paths in an image.
Synopsis
Description
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.
Attributes
Attributes of an image
count :lvalue
Number of points in the image.
image :lvalue
Image data points.
partitions :lvalue
Number of partitions in the image.
partitionEnd :lvalue
End points for each path.
partitionStart :lvalue
Start points for each path.
partitionPath :lvalue
Path for each partition.
x :lvalue
Image dimension in x.
y :lvalue
Image dimension in y.
Methods
Find paths in an image
new($)
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 1
11 1 1
1111 111 1
1 111111 1 1
111 1111 111 1
11 1111111 1 1
11 11111 1 1
1 111 1 1 1
1111111111 1 111111 1
111 1 1 1
END
ok $d->x == 80;
ok $d->y == 10;
ok nws($d->print) eq nws(<<END);
E1 E
11 1
1111 1
1 322E S 1
111 2 E1 S
11 2221S 1
11 2 1 E
1 3 1 S 1
11111112 1 E1111 1
S S
END
ok $d->numberOfPaths == 6;
is_deeply $d->path(5),
[[79, 4, 1], [79, 3, 1], [79, 2, 1], [79, 1, 1], [79, 0, 1]];
This is a static method and so should be invoked as:
Image::Find::Paths::new
numberOfPaths($)
Number of paths in the image. The partitions and paths are numbered from 1.
Parameter Description
1 $i Image
Example:
ok $d->numberOfPaths == 6;
path($$)
Path for a specified partition. The partitions and paths are numbered from 1. Returns an array of arrays [x, y, t] where x, y are the coordinates of each point sequentially along the path and t is the estimated thickness of the path at that point.
Parameter Description
1 $i Image
2 $partition Partition
Example:
is_deeply $d->path(5),
[[79, 4, 1], [79, 3, 1], [79, 2, 1], [79, 1, 1], [79, 0, 1]];
print($)
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.
Parameter Description
1 $i Image
Example:
ok nws($d->print) eq nws(<<END);
E1 E
11 1
1111 1
1 322E S 1
111 2 E1 S
11 2221S 1
11 2 1 E
1 3 1 S 1
11111112 1 E1111 1
S S
END
Private Methods
clone($)
Clone an image.
Parameter Description
1 $i Image
Example:
is_deeply $d, $d->clone;
partition($)
Partition the images into disjoint sets of connected points.
Parameter Description
1 $i Image
mapPartition($$$)
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
traverseToOtherEnd($$$$)
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
start($$)
Find the starting point for a path in a partition.
Parameter Description
1 $i Image
2 $partition Partition
end($$)
Find the other end of a path in a partition.
Parameter Description
1 $i Image
2 $partition Partition
searchArea($$$$)
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.
shortestPathBetweenEndPoints($$)
Find the shortest path between the start and the end points of a partition.
Parameter Description
1 $I Image
2 $partition Partition
widthOfPath($$$)
Find the (estimated) width of the path at each point
Parameter Description
1 $I Image
2 $i Cloned copy of image
3 $partition Partition
widthOfPaths($)
Find the (estimated) width of each path at each point
Parameter Description
1 $I Image
Index
1 clone
2 count
3 end
4 image
6 new
11 partitions
13 path
14 print
15 searchArea
16 shortestPathBetweenEndPoints
17 start
19 widthOfPath
20 widthOfPaths
21 x
22 y
Installation
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
Author
Copyright
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.