Linear Pixel Shuffling

and

and

Pattern Recognition

Pattern Recognition


Table of Contents


Acknowledgments

Definition

Linear Pixel Shuffling (LPS) is a method to get a semi-random ordering of pixels. Unlike other techniques, LPS creates a pixel ordering that is spread evenly across the image. It wraps around the image by use of modular arithmetic. A simple arithmetic progression is needed to determine the next pixel location.

Objective

The objective of this project is to compare Linear Pixel Shuffling (LPS) as a Pattern Recognition tool, against more traditional algorithms that are based on Space and Frequency Domain Correlation. The study will demonstrate the speed and efficiency of LPS as a potentially enhanced method for Pattern Recognition.

Outline

Experimental Rational

- Traditional textbook algorithm
- Same correlation equation
- Used for large ratio problems
- Used for small ratio problems
- Compare "pseudo-random" ordering of LPS against "true-random" ordering

Space Domain

Frequency Domain

Random Ordering

Linear Pixel Shuffling

Outline

Algorithm Implementation

Space Domain

Space Domain isn't implemented in the traditional way. Instead, this algorithm sums the absolute value of the difference between corresponding pixels.

Advantages to this method are:

The algorithm steps are:

  1. At [row = 0, col = 0], find the difference
  2. Check difference value for minimum

  3. Move to the next pixel location until every pixel in the image is sampled

Algorithm Implementation (cont.)

Frequency Domain

Algorithm Implementation (cont.)

The steps for this algorithm are as follows:

  1. Determine 2N size equal to or greater than the largest dimension of the pattern and image
  2. Zero pad pattern and image to the size determined in (1)
  3. Calculate Fourier Transform of image and pattern
  4. Multiply the FFT of the image and pattern on a pixel-by-pixel basis
  5. Take the inverse Fourier Transform of multiplication
  6. Search for a maximum in the inverted transform results

Algorithm Implementation (cont.)

Random Ordering

Algorithm Implementation (cont.)

Linear Pixel Shuffling

Instead of a sequential pixel ordering, change in position is calculated by:

Software Implementation

Sherlock

Sherlock is an Open Look\xaa application that can read in an image and pattern and run the 4 algorithms.

Software Implementation (cont.)

After an algorithm has run, information about it is presented. In Batch Mode, it is written to the screen. In UI Mode, a window pops up with the information. Both cases provide the following:

Test - Name of algorithm
Ratio - ratio between image and pattern (image:pattern)
Time - algorithm runtime (h:m:s)
Pos - Location of a match
Image - filename of the image
Pattern - filename of the pattern (or from image if cropped)

Software Implementation (cont.)

Tools used:

Common Experimental Elements

Experiments

Experiment 1

Objective

Experimental Conditions

Experiments (cont.)

Experiment 2

Objective

Experimental Conditions

Experiments (cont.)

Experiments (cont.)

Experiment 3

Objective

Experimental Conditions

Outline

Outline

Conclusions

Limitations

Future Research

Numerical Results

Experiment 1

TABLE 1. first partial match found 
-------------------------------
Case   Space  Freq  Random  LPS  
-------------------------------
3x3    12     100   86      2    
5x5    28     98    84      2    
11x11  128    100   88      2    
41x41  1,584  98    100     2    
81x81  5,424  100   74      2    
                                 
-------------------------------
TABLE 2. found pattern center 
---------------------------------
Case   Space  Freq  Random  LPS    
---------------------------------
3x3    12     100   96      8      
5x5    28     100   116     14     
11x11  130    100   194     62     
41x41  1,768  100   1,920   812    
81x81  6,866  100   5,376   3,136  
                                   
---------------------------------

Numerical Results (cont.)

Experiment 2

TABLE 3. first partial match found (in seconds) 
-----------------------------------
Case       Space  Freq  Random  LPS  
-----------------------------------
(102,17)   4      96    84      2    
(148,157)  48     98    76      2    
(182,59)   16     98    90      2    
(196,36)   8      98    84      2    
(202,248)  76     96    86      2    
(226,327)  102    96    86      2    
(290,201)  60     98    82      2    
(293,138)  42     98    82      2    
(354,168)  50     98    92      2    
(368,291)  90     98    88      2    
(374,13)   2      96    76      2    
(387,5)    2      98    78      2    
(408,67)   18     140   72      2    
(432,338)  104    96    88      2    
(444,251)  76     96    88      2    
(447,36)   8      98    88      2    
(466,392)  124    98    78      2    
(489,174)  52     96    74      2    
(63,48)    12     98    92      2    
(91,321)   100    98    106     2    
                                     
-----------------------------------

Numerical Results (cont.)

TABLE 4. found pattern center (in seconds) 
-----------------------------------
Case       Space  Freq  LPS  Random  
-----------------------------------
(102,17)   6      96    44   146     
(148,157)  50     98    22   126     
(182,59)   20     98    158  148     
(196,36)   12     98    112  210     
(202,248)  78     96    86   200     
(226,327)  106    98    168  88      
(290,201)  64     98    62   196     
(293,138)  44     98    44   140     
(354,168)  54     98    92   216     
(368,291)  92     98    98   178     
(374,13)   4      96    156  104     
(387,5)    2      98    38   234     
(408,67)   22     140   28   164     
(432,338)  108    98    68   120     
(444,251)  80     98    100  106     
(447,36)   12     98    8    160     
(466,392)  128    98    106  210     
(489,174)  56     96    154  192     
(63,48)    16     98    62   176     
(91,321)   104    98    104  124     
                                     
-----------------------------------

Numerical Results (cont.)

Experiment 3

TABLE 5. first partial match found (in seconds) 
-------------------------------
Case  Space   Freq  Random  LPS  
-------------------------------
text  10,186  550   844     98   
                                 
-------------------------------
TABLE 6. found pattern center (in seconds) 
---------------------------------
Case  Space   Freq  Random  LPS    
---------------------------------
text  14,506  550   7,676   7,162  
---------------------------------

Numerical Analysis of Results

Experiment 1

TABLE 7. timing for Experiment 1 cases 
------------------------------------------------------------------
Case   # pixels  Seconds/    Pixels/      # of pixels   Seconds     
                 Pixel       Second       til 1st                   
                                          partial                   
                                          match                     
------------------------------------------------------------------
3x3    200,400   5.9880E-05  16,700.0000  570           3.4132E-02  
5x5    200,400   1.3972E-04  7,157.1429   570           7.9641E-02  
11x11  200,400   6.4870E-04  1,541.5385   570           3.6976E-01  
41x41  200,400   8.8224E-03  113.3484     5             4.4112E-02  
81x81  200,400   3.4261E-02  29.1873      5             1.7131E-01  
                                                                    
------------------------------------------------------------------

Numerical Analysis of Results (cont.)

Experiment 2

TABLE 8. timing for Experiment 2 cases 
--------------------------------------------------------------------
Case       # pixels  Seconds/    Pixels/    # of pixels   Seconds     
                     Pixel       Second     til 1st                   
                                            partial                   
                                            match                     
--------------------------------------------------------------------
(102,17)   8,602     6.9751E-04  1433.6667  98            6.3374E-02  
(148,157)  78,648    6.3574E-04  1572.9600  583           3.7701E-01  
(182,59)   29,682    6.7381E-04  1484.1000  160           1.0347E-01  
(196,36)   18,196    6.5949E-04  1516.3333  4             2.5867E-03  
(202,248)  124,202   6.2801E-04  1592.3333  555           3.5891E-01  
(226,327)  163,726   6.4742E-04  1544.5849  412           2.6643E-01  
(290,201)  100,790   6.3498E-04  1574.8438  191           1.2352E-01  
(293,138)  69,293    6.3498E-04  1574.8409  525           3.3951E-01  
(354,168)  84,354    6.4016E-04  1562.1111  151           9.7648E-02  
(368,291)  145,868   6.3071E-04  1585.5217  279           1.8042E-01  
(374,13)   6,874     5.8190E-04  1718.5000  60            3.8801E-02  
(387,5)    2,887     6.9276E-04  1443.5000  416           2.6902E-01  
(408,67)   33,908    6.4881E-04  1541.2727  442           2.8583E-01  
(432,338)  169,432   6.3742E-04  1568.8148  338           2.1858E-01  
(444,251)  125,944   6.3520E-04  1574.3000  159           1.0282E-01  
(447,36)   18,447    6.5051E-04  1537.2500  43            2.7807E-02  
(466,392)  196,466   6.5151E-04  1534.8906  362           2.3410E-01  
(489,174)  87,489    6.4008E-04  1562.3036  604           3.9059E-01  
(63,48)    24,063    6.6492E-04  1503.9375  63            4.0741E-02  
(91,321)   160,591   6.4761E-04  1544.1442  638           4.1258E-01  
                                                                      
--------------------------------------------------------------------

Numerical Analysis of Results (cont.)

The results for Frequency Domain in the 408x67 case obviously don't seem to belong. This anomaly is explained by background processes running at the same time. Repeat trials of this case show the results to be similar to other case results.

TABLE 9. results for 5 retrials of case 408x67 for partial match 
-----------------------------------
Case       Space  Freq  Random  LPS  
-----------------------------------
retrial 1  20     99    42      2    
retrial 2  18     99    39      2    
retrial 3  18     98    114     2    
retrial 4  18     98    82      2    
retrial 5  20     99    80      2    
means      18.8   98.6  71.4    2    
                                     
-----------------------------------
TABLE 10. results for 5 retrials of case 408x67 for pattern center 
------------------------------------
Case       Space  Freq  Random  LPS   
------------------------------------
retrial 1  24     99    120     28    
retrial 2  22     99    158     28    
retrial 3  22     98    268     26    
retrial 4  22     98    176     26    
retrial 5  22     99    100     28    
means      22.4   98.6  164.4   27.2  
                                      
------------------------------------
The same approximate values resulted for Space Domain, LPS, and Random Order as in the original test case. Rerunning this particular case shows that the 140 seconds from the original experiment is not correct. The mean values for Frequency Domain are close to other case results, as expected.

Numerical Analysis of Results (cont.)

Experiment 3

TABLE 11. timing for Experiment 3 case 
-------------------------------------------------------------
Case  # pixels  Seconds/    Pixels/  # of pixels   Seconds     
                Pixel       Second   til 1st                   
                                     partial                   
                                     match                     
-------------------------------------------------------------
text  314,061   4.6188E-02  21.6504  2089          9.6488E+01  
                                                               
-------------------------------------------------------------

Footnotes

(1)
This experiment was performed to demonstrate the use of LPS with typical images. It is not intended to demonstrate the effect of image noise. A detailed study of LPS and noise is beyond the scope of this project