1 X Y 2 X Y 3 X Y . . . N X Y 1 X Y 2 X Y . . M X Y 1 -1 -1 1 X Y . . #### my $i = 0; my $toggle = -1; my @p = qw|ROI1 ROI2 ROI3 ROI4 ROI5 ROI6 ROI7|; my @points,%ROI; open (POINTS, ") { chomp $_; my $a,$b,$c; ($a,$b,$c) = split(/\t/,$_); if ($a == 1) { $toggle *= -1; if ($toggle < 0) { $i++; $toggle = 1; } } if ($b == -1) { $i++; $toggle = -1; } else { push @{$p[$i]}, [$b,$c]; } } #### # this is sent the roi info and the distances from that point to all of the other points from the template #$index pulls in the roi info, @deltas then pulls in the distances. #if there is a match from a point in the region in question and the region it is testing against, it stops testing against that region and increments its success, if it has 4 successes, it stops checking that point. If at the end it does not have 4 successes it splices that point….. again untested. sub filter1 { my $i = $j = $k = 0; my $index = shift; my @deltas = @_; foreach my $testreg (@{$p[$index]}) { my ($testX,$testY) = @$testreg; foreach my $region (@p) { do { if ($i == $index) {$i++} else { $k = 0; foreach my $points(@{$region}) { do { my ($X,$Y) = @$points; my $distance = sqrt(abs(($testX - $X)**2 + ($testY - $Y)**2)); if (($deltas[$i] - $precision) <= $distance) && ($deltas[$i] + $precision) >= $distance)){ $k++; $j++; } } unless ($k == 1); } } } unless ($j == 4); } if ($j < 4) { splice (@{$p[$index]},$i,1); } else { $i++; } } } #### 1 599 377 2 829 410 3 643 465 4 522 511 5 626 552 6 762 575 7 577 597 8 699 618 1 1474 13 2 1507 14 3 1882 15 4 1912 15 5 1704 16 6 1573 17 7 1685 21 8 1709 21 9 1795 90 10 1668 107 11 1732 131 12 1819 144 13 1755 159 14 1692 163 15 1936 213 16 1708 218 17 1808 227 18 1704 221 19 1747 229 20 1744 293 1 2673 619 2 2765 620 3 2839 638 4 2729 659 5 2779 688 6 2681 703 7 2744 729 8 2821 738 9 2807 788 10 2740 808 11 2560 822 12 2570 821 1 3308 1800 2 3371 1828 3 3280 1854 4 3412 1856 5 3274 1934 6 3360 1986 7 3308 1998 8 3366 2046 1 2235 2522 2 2408 2541 3 2335 2547 4 2267 2580 5 2383 2602 6 2296 2630 7 2214 2627 8 2426 2652 9 2425 2657 10 2228 2678 11 2364 2684 12 2283 2726 13 2358 2764 1 1768 2505 2 1696 2527 3 1800 2567 4 1650 2586 5 1733 2624 6 1835 2632 7 1621 2675 8 1689 2677 9 1650 2730 10 1770 2738 1 29 1746 2 30 1764 3 78 1781 4 30 1783 5 30 1806 6 320 1897 7 231 1944 8 31 1938 9 30 1968 10 376 1965 11 206 2013 12 260 2068 13 193 2096 14 401 2097 15 350 2133 16 32 2166 17 257 2187 18 32 2258 ____________________ 1 585 600 1 1715 280 1 2745 815 1 3240 2090 1 2280 2770 1 1715 2770 1 190 2090 #### ---------------------------------- | | | 2 | | | | 1 | | 3 | | | | | | 7 4 | | | | | | 6 5 | | | ---------------------------------- #### ______ __________ / \ / -- / | -- | to | -- | | -- | | / \_______/ \____/ #### ROI X Y 1 464 642 2 157 1756 3 687 2779 4 5 2631 2296 6 2625 1732 7 #### ROI 1 3 643 465 ROI 2 13 1755 159 ROI 3 5 2779 688 ROI 4 None ROI 5 6 2296 2630 ROI 6 5 1733 2624 ROI 7 None #### True Point Distances for ROI1. ROI2 Distance = 1153.33429672407 ROI3 Distance = 2147.60913576004 ROI5 Distance = 2723.90051213329 ROI6 Distance = 2418.54935860321 Template Point Distances for ROI1. ROI2 Distance = 1174.4360348695 ROI3 Distance = 2170.67385850569 ROI5 Distance = 2753.52955313721 ROI6 Distance = 2446.58946290545 True Point Distances for ROI2. ROI1 Distance = 1153.33429672407 ROI3 Distance = 1152.56973758641 ROI5 Distance = 2529.5299958688 ROI6 Distance = 2465.09817248725 Template Point Distances for ROI2. ROI1 Distance = 1174.4360348695 ROI3 Distance = 1160.65714145048 ROI5 Distance = 2553.29688833868 ROI6 Distance = 2490 True Point Distances for ROI3. ROI1 Distance = 2147.60913576004 ROI2 Distance = 1152.56973758641 ROI5 Distance = 2001.16291190897 ROI6 Distance = 2200.50266984614 Template Point Distances for ROI3. ROI1 Distance = 2170.67385850569 ROI2 Distance = 1160.65714145048 ROI5 Distance = 2009.53974830059 ROI6 Distance = 2209.73414690546 True Point Distances for ROI5. ROI1 Distance = 2723.90051213329 ROI2 Distance = 2529.5299958688 ROI3 Distance = 2001.16291190897 ROI6 Distance = 563.031970673069 Template Point Distances for ROI5. ROI1 Distance = 2753.52955313721 ROI2 Distance = 2553.29688833868 ROI3 Distance = 2009.53974830059 ROI6 Distance = 565 True Point Distances for ROI6. ROI1 Distance = 2418.54935860321 ROI2 Distance = 2465.09817248725 ROI3 Distance = 2200.50266984614 ROI5 Distance = 563.031970673069 Template Point Distances for ROI6. ROI1 Distance = 2446.58946290545 ROI2 Distance = 2490 ROI3 Distance = 2209.73414690546 ROI5 Distance = 565