Name

Image::Find::Paths - Locate paths in an image.

Synopsis

Description

Locate 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 image

image :lvalue

Image data points

partitions :lvalue

Number of parts in the image

partitionEnd :lvalue

End point for a partition

partitionStart :lvalue

Start point for a partition

partitionPath :lvalue

Start path for each partition

x :lvalue

Image dimension in x

y :lvalue

Image dimension in y

Methods

Locate 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                              11              1                     1
        111                             111             111                    1
       11  11 1                         1                1                      
      11    111                         1                                      1
      1       1                         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);
     E+                                                                        E
      ++                                                                       +
       ++++                            E++                                     +
          +                              +               S                     +
        +++                             ++              E+                     S
       ++  S+                           +
      ++    +++                         +                                      E
      +       +                         +                 S                    +
      +++++++++                         +             E++++                    +
                                        S                                      S
END

ok $d->numberOfPaths == 6;

is_deeply $d->path(5), [[79, 4], [79, 3], [79, 2], [79, 1], [79, 0]];

This is a static method and so should be invoked as:

Image::Find::Paths::new

clone($)

Clone an image.

   Parameter  Description  
1  $i         Image        

Example:

is_deeply $d, $d->clone;

numberOfPaths($)

Number of paths in the image.

   Parameter  Description  
1  $i         Image        

Example:

ok $d->numberOfPaths == 6;

path($$)

Path for a specified partition.

   Parameter   Description  
1  $i          Image        
2  $partition  Partition    

Example:

is_deeply $d->path(5), [[79, 4], [79, 3], [79, 2], [79, 1], [79, 0]];

print($)

Print the image.

   Parameter  Description  
1  $i         Image        

Example:

ok nws($d->print) eq nws(<<END);
     E+                                                                        E
      ++                                                                       +
       ++++                            E++                                     +
          +                              +               S                     +
        +++                             ++              E+                     S
       ++  S+                           +
      ++    +++                         +                                      E
      +       +                         +                 S                    +
      +++++++++                         +             E++++                    +
                                        S                                      S
END

Private Methods

partition($)

Partition == set 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    

Index

1 clone

2 count

3 end

4 image

5 mapPartition

6 new

7 numberOfPaths

8 partition

9 partitionEnd

10 partitionPath

11 partitions

12 partitionStart

13 path

14 print

15 searchArea

16 shortestPathBetweenEndPoints

17 start

18 traverseToOtherEnd

19 x

20 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

philiprbrenan@gmail.com

http://www.appaapps.com

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.