summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/stitch/src/c/getANMS.c
blob: fa03a858726ed670a76d6062eb777448da83381c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/********************************
Author: Sravanthi Kota Venkata
********************************/

#include "stitch.h"

F2D* getANMS (F2D *points, int r)
{
  unsigned int MAX_LIMIT = 10000000;
  F2D *suppressR;
  float C_ROBUST = 0.9;
  F2D *srtdPnts;
  int n, k;
  I2D *srtdVIdx, *supId;
  float r_sq, t, t1;
  F2D *tempF, *srtdV, *interestPnts;
  int i, j, validCount=0, cnt, end;
  F2D *v;
    int iter, rows, cols;
    F2D* temp;
    int supIdPtr = 0;

  v = fMallocHandle(points->height, 1);
  for(i=0; i<v->height; i++)
      asubsref(v,i) = subsref(points,i,2);

  r_sq = r * r * 1.0;
  n = v->height;

    srtdVIdx = fSortIndices (v, 1);
    srtdPnts = fMallocHandle (srtdVIdx->height, points->width);

    for (i = 0; i < srtdVIdx->height; i++)
        for(j=0; j<points->width; j++)
            subsref(srtdPnts,i,j) = subsref(points, asubsref(srtdVIdx,i), j);

    temp = fSetArray (1, 3, 0);
    suppressR = fSetArray(n, 1, MAX_LIMIT);

    validCount = 0;
    iter = 0;
    for (i = 0; i < suppressR->height; i++)
    {
	    if ( asubsref(suppressR,i) > r_sq)
        {
            validCount++;
        }
    }
   
    k = 0;
    supId = iMallocHandle(validCount, 1);
    for (i = 0; i < (suppressR->height*suppressR->width); i++)
    {
        if ( asubsref(suppressR,i) > r_sq)
        {
            asubsref(supId,k++) = i;
        }
    }
         
    while (validCount > 0)
    {
        F2D *tempp, *temps;
        asubsref(temp,0) = subsref(srtdPnts, asubsref(supId,0), 0);
        asubsref(temp,1) = subsref(srtdPnts, asubsref(supId,0), 1);
        asubsref(temp,2) = subsref(srtdPnts, asubsref(supId,0), 2);
       
        if(iter == 0)
            interestPnts = fDeepCopy(temp);
        else
        {
            tempp = fDeepCopy(interestPnts);
            fFreeHandle(interestPnts); 
            interestPnts = ffVertcat(tempp, temp);
            fFreeHandle(tempp);
        }
        iter++;

        tempp = fDeepCopy(srtdPnts);
        temps = fDeepCopy(suppressR);

        fFreeHandle(srtdPnts);
        fFreeHandle(suppressR);

        srtdPnts = fMallocHandle(supId->height-1, 3);
        suppressR = fMallocHandle(supId->height-1, 1);
        
        k=0;
        for(i=1; i<supId->height; i++)
        {
            subsref(srtdPnts,k,0) = subsref(tempp, asubsref(supId,i) ,0);
            subsref(srtdPnts,k,1) = subsref(tempp, asubsref(supId,i) ,1);
            subsref(srtdPnts,k,2) = subsref(tempp, asubsref(supId,i) ,2);
            subsref(suppressR,k,0) = subsref(temps, asubsref(supId,i) ,0);
            k++;
        }
         
        fFreeHandle(tempp);
        fFreeHandle(temps);
        rows = interestPnts->height-1;
        cols = interestPnts->width;
        for (i = 0; i < srtdPnts->height; i++)
	    {
    	    t = 0;
	        t1 = 0;

	        if ((C_ROBUST * subsref(interestPnts,rows,2)) >= subsref(srtdPnts, i,2))
	        {
        		t = subsref(srtdPnts, i,0) - subsref(interestPnts,rows,0);
        		t1 = subsref(srtdPnts, i,1) - subsref(interestPnts,rows,1);
        		t = t * t + t1 * t1;
                t1 = 0;
            }

	        if ((C_ROBUST * subsref(interestPnts,rows,2)) < subsref(srtdPnts, i,2))
    	        t1 = 1 * MAX_LIMIT;

	        if ( asubsref(suppressR, i) > (t + t1))
            {
	            asubsref(suppressR, i) = t + t1;
            }  
        }
        
        validCount=0;
        for (i = 0; i < suppressR->height; i++)
	        if ( asubsref(suppressR,i) > r_sq)
                validCount++;
   
        k = 0;
        iFreeHandle(supId);
        supId = iMallocHandle(validCount, 1);
        
        for (i = 0; i < suppressR->height*suppressR->width; i++)
            if ( asubsref(suppressR,i) > r_sq)
                asubsref(supId,k++) = i;
    }
  
    iFreeHandle(supId);
    iFreeHandle(srtdVIdx);
    fFreeHandle(srtdPnts);
    fFreeHandle(temp);
    fFreeHandle(suppressR);
    fFreeHandle(v);

    return interestPnts;
}
8 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
%PDF-1.3
%Äåòåë§ó ÐÄÆ
4 0 obj
<< /Length 5 0 R /Filter /FlateDecode >>
stream
x½ZÙŽ5}ï¯pÂ’ž�ñ´Ý«		�
^ˆt%h4‘@�	ü?Çö©Þ¸KÍèêN"µº¯}ª\uj±»?˜·æƒqÿ­óUåM;ôvLߥËÍ•ùÉüi.žtæò£©Ò¿�—˜SYßTñ/?ï\7X?D„ª³Cqymžm0Ðite6—�‘&ñ²¹6¯œuÆ™Í{SÞ»f6¿c