-
Notifications
You must be signed in to change notification settings - Fork 4
/
movingleastsquarestransform.bsh
275 lines (222 loc) · 33.8 KB
/
movingleastsquarestransform.bsh
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
import mpicbg.models.MovingLeastSquaresTransform;
import javax.vecmath.Point3f;
import javax.vecmath.Color3f;
import ij3d.Image3DUniverse;
import customnode.CustomPointMesh;
import customnode.CustomLineMesh;
import ij.IJ;
import java.util.ArrayList;
import mpicbg.models.AffineModel3D;
import mpicbg.models.Point;
import mpicbg.models.PointMatch;
import mpicbg.models.CoordinateTransform;
refLandmarks = new float[][]{{158.994, 120.15299999999999, 110.00715}, {75.867, 96.55799999999999, 60.003899999999994}, {104.181, 120.87899999999999, 64.00416}, {135.399, 25.773, 88.00572}, {165.891, 48.278999999999996, 46.00299}, {140.481, 62.073, 88.00572}, {192.027, 66.066, 78.00506999999999}, {125.235, 68.607, 40.002599999999994}};
refVector_peduncle = new float[][]{{124.872, 67.881, 38.802521999999996}, {124.9266315, 68.183696625, 39.60257399999999}, {124.98235199999999, 68.440383, 40.40262599999999}, {125.0402505, 68.654053875, 41.20267799999999}, {125.101416, 68.827704, 42.002729999999985}, {125.1669375, 68.964328125, 42.802781999999986}, {125.23790399999999, 69.066921, 43.60283399999998}, {125.3154045, 69.138477375, 44.40288599999998}, {125.40052800000001, 69.181992, 45.202937999999975}, {125.49436349999999, 69.200459625, 46.002989999999976}, {125.598, 69.19687499999999, 46.80304199999998}, {125.7125265, 69.174232875, 47.60309399999998}, {125.83903199999999, 69.135528, 48.403145999999985}, {125.97860549999999, 69.083755125, 49.203197999999986}, {126.132336, 69.021909, 50.00324999999999}, {126.3013125, 68.952984375, 50.80330199999999}, {126.48662399999999, 68.879976, 51.603353999999996}, {126.68935950000001, 68.805878625, 52.403406}, {126.910608, 68.73368699999999, 53.203458}, {127.15145849999999, 68.66639587499999, 54.003510000000006}, {127.413, 68.607, 54.903568500000006}, {127.641327, 68.552504625, 55.803627000000006}, {127.889256, 68.497737, 56.703685500000006}, {128.154609, 68.442424875, 57.603744000000006}, {128.43520800000002, 68.386296, 58.503802500000006}, {128.728875, 68.329078125, 59.403861000000006}, {129.033432, 68.270499, 60.303919500000006}, {129.346701, 68.210286375, 61.203978000000006}, {129.66650399999997, 68.148168, 62.10403650000001}, {129.99066299999998, 68.083871625, 63.00409500000001}, {130.317, 68.017125, 63.90415350000001}, {130.643337, 67.947655875, 64.804212}, {130.96749599999998, 67.875192, 65.7042705}, {131.287299, 67.799461125, 66.604329}, {131.600568, 67.720191, 67.5043875}, {131.905125, 67.637109375, 68.40444600000001}, {132.198792, 67.549944, 69.30450450000001}, {132.479391, 67.458422625, 70.20456300000001}, {132.744744, 67.362273, 71.10462150000001}, {132.992673, 67.26122287499999, 72.00468000000001}, {133.221, 67.155, 72.60471900000002}, {133.490572875, 67.05653625, 73.20475800000001}, {133.754973, 66.97712999999999, 73.80479700000001}, {134.014472625, 66.91405875, 74.404836}, {134.26934400000002, 66.8646, 75.004875}, {134.519859375, 66.82603125, 75.604914}, {134.766291, 66.79562999999999, 76.20495299999999}, {135.008911125, 66.77067375, 76.80499199999998}, {135.247992, 66.74844, 77.40503099999998}, {135.483805875, 66.72620624999999, 78.00506999999999}, {135.716625, 66.70125, 78.60510899999998}, {135.94672162499998, 66.67084874999999, 79.20514799999998}, {136.174368, 66.63228, 79.80518699999998}, {136.39983637499998, 66.58282125000001, 80.40522599999997}, {136.623399, 66.51975, 81.00526499999997}, {136.845328125, 66.44034375, 81.60530399999996}, {137.06589599999998, 66.34187999999999, 82.20534299999996}, {137.285374875, 66.22163625, 82.80538199999995}, {137.50403699999998, 66.07688999999999, 83.40542099999996}, {137.722154625, 65.90491875, 84.00545999999996}, {137.94, 65.703, 84.20547299999994}, {138.19636875, 65.4879225, 84.40548599999994}, {138.42279, 65.27829, 84.60549899999994}, {138.62198625, 65.07410250000001, 84.80551199999994}, {138.79668, 64.87536, 85.00552499999993}, {138.94959375, 64.6820625, 85.20553799999992}, {139.08345, 64.49421, 85.40555099999992}, {139.20097124999998, 64.3118025, 85.60556399999992}, {139.30488, 64.13484, 85.80557699999991}, {139.39789875, 63.963322500000004, 86.00558999999991}, {139.48275, 63.79725, 86.2056029999999}, {139.56215625, 63.6366225, 86.4056159999999}, {139.63884, 63.48144, 86.6056289999999}, {139.71552375, 63.3317025, 86.80564199999989}, {139.79493, 63.18740999999999, 87.00565499999989}, {139.87978125, 63.048562499999996, 87.20566799999987}, {139.9728, 62.91515999999999, 87.40568099999987}, {140.07670875, 62.7872025, 87.60569399999987}, {140.19422999999998, 62.66468999999999, 87.80570699999987}, {140.32808625, 62.5476225, 88.00571999999987}, {140.481, 62.436, 88.00572}};
refVector_dorsal_lobe = new float[][]{{140.481, 60.983999999999995, 88.10572649999999}, {140.55909037499998, 60.617732999999994, 88.205733}, {140.68101299999998, 60.177414000000006, 88.30573949999999}, {140.841595125, 59.670666, 88.405746}, {141.035664, 59.105112000000005, 88.50575249999999}, {141.258046875, 58.488375, 88.60575899999998}, {141.503571, 57.82807799999999, 88.70576549999998}, {141.767063625, 57.13184399999999, 88.80577199999998}, {142.043352, 56.40729600000001, 88.90577849999998}, {142.327263375, 55.662057, 89.00578499999997}, {142.61362499999998, 54.903749999999995, 89.10579149999997}, {142.897264125, 54.139998000000006, 89.20579799999997}, {143.17300799999998, 53.378424, 89.30580449999997}, {143.435683875, 52.626651, 89.40581099999997}, {143.680119, 51.892301999999994, 89.50581749999996}, {143.90114062499998, 51.183, 89.60582399999996}, {144.09357599999998, 50.506367999999995, 89.70583049999996}, {144.25225237499998, 49.870029, 89.80583699999995}, {144.371997, 49.281606, 89.90584349999996}, {144.447637125, 48.748721999999994, 90.00584999999995}, {144.474, 48.278999999999996, 89.90584349999996}, {144.50984624999998, 47.83028662499999, 89.80583699999995}, {144.5103, 47.357343, 89.70583049999996}, {144.47808375, 46.863163875, 89.60582399999996}, {144.41592, 46.350744000000006, 89.50581749999996}, {144.32653125, 45.823078125, 89.40581099999997}, {144.21264, 45.28316099999999, 89.30580449999997}, {144.07696875, 44.733987375, 89.20579799999997}, {143.92224000000002, 44.178552, 89.10579149999997}, {143.75117625000001, 43.61984962499999, 89.00578499999997}, {143.5665, 43.060874999999996, 88.90577849999998}, {143.37093375, 42.504622874999995, 88.80577199999998}, {143.16719999999998, 41.954088, 88.70576549999998}, {142.95802125, 41.412265125, 88.60575899999998}, {142.74612, 40.882149, 88.50575249999999}, {142.53421875, 40.366734375, 88.405746}, {142.32504, 39.869015999999995, 88.30573949999999}, {142.12130625, 39.391988625, 88.205733}, {141.92574, 38.938646999999996, 88.10572649999999}, {141.74106375, 38.511985875, 88.00572}, {141.57, 38.115, 88.00572}, {141.38822775, 37.702314375, 88.00572}, {141.17215199999998, 37.231094999999996, 88.00572}, {140.92558424999999, 36.708148124999994, 88.00572}, {140.652336, 36.14028, 88.00572}, {140.35621874999998, 35.534296874999995, 88.00572}, {140.041044, 34.89700499999999, 88.00572}, {139.71062325, 34.235210625, 88.00572}, {139.368768, 33.55572, 88.00572}, {139.01928974999998, 32.865339375, 88.00572}, {138.666, 32.170875, 88.00572}, {138.31271024999998, 31.479133125, 88.00572}, {137.963232, 30.79692, 88.00572}, {137.62137675, 30.131041874999998, 88.00572}, {137.290956, 29.488305, 88.00572}, {136.97578124999998, 28.875515625, 88.00572}, {136.679664, 28.299479999999996, 88.00572}, {136.40641574999998, 27.767004374999996, 88.00572}, {136.159848, 27.284894999999995, 88.00572}, {135.94377225, 26.859958124999995, 88.00572}, {135.762, 26.499, 88.00572}};
refVector_medial_lobe = new float[][]{{140.481, 62.073, 88.00572}, {140.819179875, 62.062518374999996, 88.00572}, {141.280689, 62.032707, 88.00572}, {141.85273162500002, 61.986016125, 88.00572}, {142.522512, 61.924896000000004, 88.00572}, {143.277234375, 61.851796875, 88.00572}, {144.10410299999998, 61.769169000000005, 88.00572}, {144.99032212499998, 61.679462625, 88.00572}, {145.92309600000002, 61.585128, 88.00572}, {146.889628875, 61.488615375, 88.00572}, {147.877125, 61.392375, 88.00572}, {148.872788625, 61.298857125000005, 88.00572}, {149.863824, 61.210511999999994, 88.00572}, {150.83743537499998, 61.129789875, 88.00572}, {151.78082700000002, 61.059141, 88.00572}, {152.681203125, 61.001015625, 88.00572}, {153.525768, 60.957864, 88.00572}, {154.301725875, 60.932136375, 88.00572}, {154.996281, 60.926283, 88.00572}, {155.596637625, 60.94275412499999, 88.00572}, {156.09, 60.983999999999995, 87.805707}, {156.518748375, 61.038631499999994, 87.605694}, {157.037067, 61.094352, 87.40568100000002}, {157.63651612499999, 61.1522505, 87.20566800000002}, {158.308656, 61.213416, 87.00565500000002}, {159.045046875, 61.2789375, 86.80564200000002}, {159.83724899999999, 61.349904, 86.60562900000002}, {160.676822625, 61.427404499999994, 86.40561600000004}, {161.555328, 61.512527999999996, 86.20560300000004}, {162.464325375, 61.60636349999999, 86.00559000000004}, {163.395375, 61.71, 85.80557700000004}, {164.34003712499998, 61.82452649999999, 85.60556400000004}, {165.289872, 61.95103199999999, 85.40555100000006}, {166.236439875, 62.090605499999995, 85.20553800000006}, {167.171301, 62.244336000000004, 85.00552500000006}, {168.086015625, 62.413312499999996, 84.80551200000006}, {168.972144, 62.598624, 84.60549900000007}, {169.82124637500002, 62.801359500000004, 84.40548600000008}, {170.62488299999998, 63.022608000000005, 84.20547300000008}, {171.374614125, 63.263458500000006, 84.00546000000008}, {172.06199999999998, 63.525, 83.70544050000008}, {172.71798637499998, 63.797023124999996, 83.40542100000008}, {173.378601, 64.067685, 83.10540150000007}, {174.04302712499998, 64.335624375, 82.80538200000007}, {174.710448, 64.59948, 82.50536250000006}, {175.380046875, 64.857890625, 82.20534300000007}, {176.051007, 65.109495, 81.90532350000007}, {176.722511625, 65.352931875, 81.60530400000006}, {177.393744, 65.58684, 81.30528450000006}, {178.063887375, 65.809858125, 81.00526500000005}, {178.732125, 66.020625, 80.70524550000005}, {179.39764012499998, 66.217779375, 80.40522600000004}, {180.05961599999998, 66.39996, 80.10520650000004}, {180.71723587499997, 66.565805625, 79.80518700000003}, {181.36968299999998, 66.713955, 79.50516750000003}, {182.016140625, 66.843046875, 79.20514800000002}, {182.655792, 66.95172, 78.90512850000002}, {183.287820375, 67.038613125, 78.60510900000003}, {183.911409, 67.10236499999999, 78.30508950000002}, {184.525741125, 67.14161437499999, 78.00507000000002}, {185.13, 67.155, 78.00507000000002}, {185.16970312499998, 67.15236825, 78.00507000000002}, {185.284275, 67.144836, 78.00507000000002}, {185.466909375, 67.13294775, 78.00507000000002}, {185.7108, 67.117248, 78.00507000000002}, {186.009140625, 67.09828125, 78.00507000000002}, {186.355125, 67.07659199999999, 78.00507000000002}, {186.74194687499997, 67.05272475, 78.00507000000002}, {187.1628, 67.02722399999999, 78.00507000000002}, {187.610878125, 67.00063424999999, 78.00507000000002}, {188.079375, 66.9735, 78.00507000000002}, {188.561484375, 66.94636575, 78.00507000000002}, {189.05039999999997, 66.919776, 78.00507000000002}, {189.539315625, 66.89427524999999, 78.00507000000002}, {190.02142499999997, 66.870408, 78.00507000000002}, {190.489921875, 66.84871875, 78.00507000000002}, {190.938, 66.829752, 78.00507000000002}, {191.35885312499997, 66.81405225, 78.00507000000002}, {191.745675, 66.80216399999999, 78.00507000000002}, {192.091659375, 66.79463175, 78.00507000000002}, {192.39, 66.792, 78.00506999999999}};
srcLandmarks = new float[][]{{56.895759631119816, 80.065978485422, 109.44}, {117.39577552846445, 94.99789730263896, 48.0}, {90.36385353177853, 105.03832547283658, 74.88}, {77.62023316191232, 25.873411053970777, 38.4}, {28.447879815559904, 55.479801812245796, 28.8}, {73.37235970529026, 44.795756451650895, 65.27999999999999}, {17.37766414072664, 49.42980022251133, 55.67999999999999}, {76.46172221919721, 71.44150813409841, 36.48}};
srcVector_peduncle = new float[][]{{76.07555190495884, 72.60001907681352, 36.864}, {76.14187665642929, 72.40085173724508, 37.248}, {76.2238413056264, 72.15360619355397, 37.632}, {76.31970808613606, 71.86233723403967, 38.01599999999999}, {76.42773923154424, 71.53109964700172, 38.39999999999999}, {76.54619697543686, 71.16394822073958, 38.78399999999999}, {76.67334355139984, 70.76493774355278, 39.16799999999999}, {76.80744119301912, 70.33812300374083, 39.55199999999999}, {76.94675213388061, 69.8875587896032, 39.93599999999999}, {77.08953860757025, 69.41729988943943, 40.31999999999999}, {77.23406284767395, 68.931401091549, 40.70399999999999}, {77.37858708777766, 68.43391718423142, 41.08799999999999}, {77.5213735614673, 67.9289029557862, 41.47199999999999}, {77.66068450232879, 67.42041319451282, 41.85599999999999}, {77.79478214394807, 66.9125026887108, 42.23999999999999}, {77.92192871991105, 66.40922622667965, 42.62399999999999}, {78.04038646380367, 65.91463859671886, 43.00799999999999}, {78.14841760921186, 65.43279458712793, 43.39199999999999}, {78.24428438972153, 64.96774898620637, 43.77599999999999}, {78.32624903891862, 64.52355658225369, 44.15999999999999}, {78.39257379038906, 64.10427216356939, 44.54399999999998}, {78.39817325994552, 63.707289080532334, 44.92799999999998}, {78.41419932798642, 63.326525150693314, 45.31199999999998}, {78.43949348356902, 62.960821863109565, 45.695999999999984}, {78.47289721575065, 62.60902070683842, 46.079999999999984}, {78.51325201358856, 62.269963170937125, 46.463999999999984}, {78.55939936614004, 61.94249074446299, 46.847999999999985}, {78.61018076246239, 61.62544491647329, 47.231999999999985}, {78.66443769161287, 61.3176671760253, 47.61599999999998}, {78.7210116426488, 61.01799901217634, 47.99999999999998}, {78.77874410462744, 60.72528191398365, 48.38399999999998}, {78.83647656660607, 60.43835737050454, 48.76799999999998}, {78.893050517642, 60.15606687079629, 49.15199999999998}, {78.94730744679248, 59.87725190391619, 49.53599999999998}, {78.99808884311483, 59.600753958921516, 49.91999999999998}, {79.04423619566631, 59.32541452486956, 50.30399999999998}, {79.08459099350422, 59.05007509081759, 50.68799999999998}, {79.11799472568585, 58.77357714582293, 51.071999999999974}, {79.14328888126845, 58.49476217894282, 51.455999999999975}, {79.15931494930935, 58.212471679234575, 51.839999999999975}, {79.1649144188658, 57.925547135755465, 52.223999999999975}, {79.15921840673079, 57.62756846703129, 52.607999999999976}, {79.14251654063999, 57.31423952831613, 52.991999999999976}, {79.11538807606473, 56.987587713759744, 53.375999999999976}, {79.07841226847641, 56.649640417511904, 53.75999999999998}, {79.03216837334637, 56.30242503372232, 54.14399999999997}, {78.97723564614596, 55.94796895654077, 54.52799999999997}, {78.91419334234655, 55.58829958011701, 54.91199999999997}, {78.84362071741948, 55.22544429860079, 55.29599999999997}, {78.76609702683614, 54.86143050614185, 55.67999999999997}, {78.68220152606784, 54.498285596889936, 56.06399999999997}, {78.59251347058598, 54.13803696499482, 56.44799999999997}, {78.4976121158619, 53.78271200460623, 56.83199999999997}, {78.39807671736696, 53.43433810987395, 57.21599999999997}, {78.29448653057253, 53.094942674947696, 57.599999999999966}, {78.18742081094993, 52.766553093977244, 57.983999999999966}, {78.07745881397055, 52.45119676111234, 58.36799999999997}, {77.96517979510575, 52.15090107050273, 58.75199999999997}, {77.85116300982686, 51.86769341629816, 59.13599999999997}, {77.73598771360527, 51.60360119264839, 59.51999999999997}, {77.62023316191232, 51.360651793703184, 59.90399999999997}, {77.50959536688303, 51.11490265997974, 60.28799999999997}, {77.40706714845275, 50.84279740230952, 60.67199999999996}, {77.30917297379332, 50.546942670313655, 61.05599999999996}, {77.21243731007661, 50.22994511361323, 61.43999999999996}, {77.11338462447446, 49.89441138182937, 61.82399999999996}, {77.00853938415875, 49.54294812458318, 62.20799999999996}, {76.89442605630131, 49.178161991495756, 62.59199999999996}, {76.767569108074, 48.802659632188224, 62.975999999999964}, {76.62449300664869, 48.41904769628168, 63.359999999999964}, {76.46172221919721, 48.02993283339724, 63.743999999999964}, {76.27578121289143, 47.63792169315602, 64.12799999999996}, {76.06319445490321, 47.24562092517911, 64.51199999999996}, {75.82048641240439, 46.85563717908764, 64.89599999999996}, {75.54418155256685, 46.47057710450271, 65.27999999999996}, {75.23080434256241, 46.09304735104542, 65.66399999999996}, {74.87687924956295, 45.72565456833689, 66.04799999999996}, {74.47893074074031, 45.371005405998226, 66.43199999999996}, {74.03348328326635, 45.03170651365053, 66.81599999999996}, {73.53706134431292, 44.71036454091494, 67.19999999999996}, {72.9861893910519, 44.409586137412525, 67.2}};
srcVector_dorsal_lobe = new float[][]{{73.37235970529026, 44.409586137412525, 67.008}, {73.37231143400098, 44.17508421409128, 66.81599999999999}, {73.37197353497602, 43.93536899152782, 66.62399999999998}, {73.3710563804797, 43.69101972519348, 66.43199999999997}, {73.36927034277635, 43.442615670559654, 66.23999999999998}, {73.36632579413029, 43.19073608309767, 66.04799999999997}, {73.36193310680582, 42.93596021827891, 65.85599999999997}, {73.35580265306729, 42.67886733157471, 65.66399999999996}, {73.347644805179, 42.42003667845645, 65.47199999999995}, {73.33716993540529, 42.160047514395465, 65.27999999999994}, {73.32408841601047, 41.899479094863125, 65.08799999999994}, {73.30811061925885, 41.638910675330784, 64.89599999999994}, {73.28894691741476, 41.3789215112698, 64.70399999999994}, {73.26630768274254, 41.120090858151535, 64.51199999999993}, {73.23990328750651, 40.862997971447335, 64.31999999999992}, {73.20944410397095, 40.608222106628574, 64.12799999999991}, {73.17464050440022, 40.356342519166596, 63.93599999999991}, {73.13520286105862, 40.107938464532765, 63.74399999999991}, {73.09084154621048, 39.86358919819843, 63.5519999999999}, {73.04126693212014, 39.623873975634964, 63.35999999999989}, {72.9861893910519, 39.38937205231372, 63.071999999999896}, {72.87318630284788, 39.16042132725964, 62.78399999999989}, {72.76568614162179, 38.93639427371211, 62.49599999999989}, {72.6633992796379, 38.71642200846408, 62.207999999999885}, {72.56603608916055, 38.49963564830852, 61.91999999999988}, {72.47330694245406, 38.28516631003838, 61.631999999999884}, {72.38492221178275, 38.07214511044664, 61.34399999999988}, {72.30059226941094, 37.859703166326256, 61.05599999999988}, {72.22002748760296, 37.646971594470195, 60.76799999999987}, {72.14293823862313, 37.43308151167142, 60.47999999999987}, {72.06903489473576, 37.217164034722884, 60.19199999999987}, {71.99802782820518, 36.99835028041757, 59.90399999999987}, {71.92962741129571, 36.77577136554843, 59.615999999999865}, {71.86354401627166, 36.548558406908434, 59.32799999999986}, {71.79948801539737, 36.315842521290534, 59.03999999999986}, {71.73716978093717, 36.076754825487704, 58.75199999999986}, {71.67629968515534, 35.830426436292896, 58.46399999999986}, {71.61658810031624, 35.5759884704991, 58.17599999999985}, {71.55774539868415, 35.31257204489925, 57.88799999999985}, {71.49948195252344, 35.03930827628632, 57.599999999999845}, {71.44150813409841, 34.75532828145328, 57.023999999999845}, {71.45285188707916, 34.4657005457745, 56.44799999999984}, {71.48591772023583, 34.176072810095725, 55.87199999999984}, {71.53925749489, 33.88644507441695, 55.29599999999983}, {71.6114230723633, 33.59681733873817, 54.71999999999982}, {71.70096631397732, 33.30718960305939, 54.14399999999982}, {71.80643908105367, 33.017561867380614, 53.56799999999981}, {71.92639323491396, 32.727934131701836, 52.99199999999981}, {72.0593806368798, 32.43830639602306, 52.415999999999805}, {72.20395314827279, 32.14867866034428, 51.8399999999998}, {72.35866263041454, 31.859050924665507, 51.2639999999998}, {72.52206094462665, 31.56942318898673, 50.68799999999979}, {72.69269995223073, 31.27979545330795, 50.11199999999979}, {72.86913151454839, 30.990167717629173, 49.53599999999978}, {73.04990749290121, 30.7005399819504, 48.95999999999978}, {73.23357974861085, 30.41091224627162, 48.38399999999978}, {73.41870014299886, 30.121284510592844, 47.80799999999979}, {73.60382053738688, 29.831656774914066, 47.231999999999786}, {73.7874927930965, 29.542029039235288, 46.655999999999786}, {73.96826877144935, 29.25240130355651, 46.079999999999785}, {74.14470033376699, 28.962773567877733, 45.695999999999785}, {74.31577378297459, 28.68999251215761, 45.311999999999784}, {74.48221318841134, 28.44878087962646, 44.92799999999979}, {74.64517706101992, 28.23595276519184, 44.54399999999979}, {74.80582391174309, 28.048322263761275, 44.15999999999979}, {74.96531225152353, 27.882703470242294, 43.77599999999979}, {75.12480059130398, 27.73591047954243, 43.39199999999979}, {75.28544744202715, 27.604757386569226, 43.00799999999979}, {75.44841131463573, 27.486058286230207, 42.62399999999979}, {75.61485072007247, 27.37662727343291, 42.23999999999979}, {75.78592416928007, 27.273278443084866, 41.85599999999979}, {75.96279017320124, 27.17282589009361, 41.471999999999795}, {76.1466072427787, 27.072083709366677, 41.087999999999795}, {76.33853388895518, 26.967865995811596, 40.703999999999795}, {76.53972862267337, 26.856986844335903, 40.319999999999794}, {76.75134995487599, 26.736260349847132, 39.935999999999794}, {76.97455639650578, 26.60250060725282, 39.55199999999979}, {77.2105064585054, 26.452521711460488, 39.16799999999979}, {77.46035865181764, 26.283137757377684, 38.78399999999979}, {77.72527148738516, 26.091162839911934, 38.3999999999998}, {78.0064034761507, 25.873411053970777, 38.4}};
srcVector_medial_lobe = new float[][]{{72.9861893910519, 44.409586137412525, 67.104}, {72.53311506987171, 44.343309657231366, 67.00800000000001}, {71.99141466157386, 44.26168290705923, 66.912}, {71.37093550917135, 44.16673328104587, 66.81600000000002}, {70.68152495567732, 44.06048817334104, 66.72000000000001}, {69.93303034410478, 43.944974978094486, 66.62400000000002}, {69.13529901746685, 43.822221089455965, 66.52800000000002}, {68.29817831877664, 43.69425390157523, 66.43200000000002}, {67.43151559104719, 43.56310080860202, 66.33600000000003}, {66.54515817729155, 43.43078920468609, 66.24000000000002}, {65.64895342052286, 43.29934648397721, 66.14400000000003}, {64.75274866375418, 43.17080004062512, 66.04800000000003}, {63.86639124999856, 43.047177268779556, 65.95200000000004}, {62.99972852226908, 42.93050556259029, 65.85600000000004}, {62.16260782357885, 42.82281231620706, 65.76000000000005}, {61.36487649694095, 42.72612492377963, 65.66400000000004}, {60.616381885368426, 42.642470779457746, 65.56800000000005}, {59.92697133187438, 42.573877277391155, 65.47200000000005}, {59.306492179471874, 42.52237181172961, 65.37600000000006}, {58.764791771174, 42.48998177662287, 65.28000000000006}, {58.311717449993836, 42.47873456622067, 65.08800000000005}, {57.82596346597124, 42.48438230706641, 64.89600000000006}, {57.29879271574661, 42.50074627413226, 64.70400000000006}, {56.73512887082641, 42.526957584211196, 64.51200000000007}, {56.13989560271726, 42.56214735409617, 64.32000000000008}, {55.51801658292563, 42.60544670058014, 64.12800000000009}, {54.874415482958106, 42.655986740456086, 63.936000000000085}, {54.21401597432122, 42.712898590516964, 63.74400000000009}, {53.5417417285215, 42.775313367555746, 63.5520000000001}, {52.86251641706549, 42.842362188365385, 63.360000000000106}, {52.181263711459714, 42.91317616973884, 63.16800000000011}, {51.502907283210746, 42.98688642846909, 62.97600000000011}, {50.83237080382509, 43.06262408134909, 62.78400000000012}, {50.174577944809315, 43.1395202451718, 62.59200000000013}, {49.534452377669936, 43.2167060367302, 62.400000000000134}, {48.916917773913504, 43.293312572817236, 62.20800000000014}, {48.32689780504655, 43.36847097022588, 62.01600000000015}, {47.769316142575626, 43.4413123457491, 61.82400000000015}, {47.24909645800726, 43.51096781617984, 61.632000000000154}, {46.77116242284799, 43.57656849831108, 61.44000000000016}, {46.34043770860438, 43.637245508935784, 61.24800000000017}, {45.946013003899154, 43.700818796917275, 61.056000000000175}, {45.571572612955784, 43.775108311118885, 60.86400000000018}, {45.21393063068177, 43.859245168333565, 60.67200000000018}, {44.86990115198467, 43.9523604853543, 60.48000000000019}, {44.53629827177199, 44.05358537897403, 60.288000000000196}, {44.20993608495128, 44.16205096598573, 60.0960000000002}, {43.88762868643009, 44.276888363182366, 59.90400000000021}, {43.566190171115935, 44.3972286873569, 59.71200000000022}, {43.24243463391633, 44.522203055302285, 59.520000000000216}, {42.91317616973884, 44.650942583811506, 59.32800000000022}, {42.57522887349099, 44.78257838967751, 59.13600000000023}, {42.2254068400803, 44.916241589693264, 58.94400000000024}, {41.86052416441432, 45.051063300651734, 58.752000000000244}, {41.47739494140058, 45.186174639345886, 58.560000000000244}, {41.07283326594661, 45.32070672256868, 58.36800000000025}, {40.64365323295994, 45.453790667113076, 58.17600000000026}, {40.18666893734812, 45.58455758977205, 57.984000000000265}, {39.698694474018644, 45.712138607338545, 57.79200000000027}, {39.17654393787909, 45.835664836605545, 57.60000000000028}, {38.61703142383698, 45.954267394366006, 57.50400000000028}, {38.029569833301856, 46.08126915646115, 57.40800000000028}, {37.42762685598281, 46.228834487789484, 57.31200000000028}, {36.81409876923659, 46.394356738729904, 57.216000000000285}, {36.191881850420025, 46.575229259661306, 57.12000000000029}, {35.56387237688987, 46.76884540096257, 57.02400000000029}, {34.93296662600293, 46.972598513012585, 56.928000000000296}, {34.30206087511599, 47.183881946190255, 56.8320000000003}, {33.67405140158585, 47.40008905087446, 56.7360000000003}, {33.05183448276927, 47.6186131774441, 56.640000000000306}, {32.43830639602306, 47.836847676278055, 56.54400000000031}, {31.836363418704, 48.05218589775523, 56.44800000000031}, {31.24890182816888, 48.2620211922545, 56.35200000000032}, {30.678817901774487, 48.46374691015477, 56.25600000000031}, {30.129007916877608, 48.65475640183492, 56.160000000000316}, {29.602368150835034, 48.83244301767385, 56.06400000000032}, {29.101794881003542, 48.99420010805045, 55.96800000000032}, {28.630184384739938, 49.137421023343606, 55.87200000000033}, {28.190432939400996, 49.25949911393221, 55.77600000000033}, {27.7854368223435, 49.357827730195154, 55.680000000000334}, {27.418092310924255, 49.42980022251133, 55.680000000000334}, {26.990360416615975, 49.48487776357958, 55.680000000000334}, {26.521791011576997, 49.534452377669936, 55.680000000000334}, {26.017887022785203, 49.57881369251806, 55.680000000000334}, {25.4841513772185, 49.618251335859654, 55.680000000000334}, {24.926087001854775, 49.65305493543039, 55.680000000000334}, {24.349196823671928, 49.68351411896593, 55.680000000000334}, {23.758983769647863, 49.70991851420198, 55.680000000000334}, {23.160950766760465, 49.732557748874214, 55.680000000000334}, {22.56060074198764, 49.751721450718286, 55.680000000000334}, {21.96343662230728, 49.767699247469906, 55.680000000000334}, {21.374961334697286, 49.78078076686473, 55.680000000000334}, {20.800677806135553, 49.791255636638446, 55.680000000000334}, {20.24608896359997, 49.79941348452673, 55.680000000000334}, {19.716697734068443, 49.805543938265274, 55.680000000000334}, {19.21800704451887, 49.80993662558973, 55.680000000000334}, {18.75551982192914, 49.81288117423579, 55.680000000000334}, {18.33473899327716, 49.814667211939145, 55.680000000000334}, {17.961167485540816, 49.81558436643546, 55.680000000000334}, {17.64030822569801, 49.81592226546042, 55.680000000000334}, {17.37766414072664, 49.8159705367497, 55.67999999999999}};
CustomPointMesh makePointMesh( float[][] coordinates )
{
final ArrayList points = new ArrayList();
for ( int i = 0; i < coordinates.length; ++i )
{
points.add( new Point3f( coordinates[ i ][ 0 ], coordinates[ i ][ 1 ], coordinates[ i ][ 2 ] ) );
}
return new CustomPointMesh( points );
}
CustomLineMesh makeLineMesh( float[][] coordinates )
{
final ArrayList line = new ArrayList();
for ( int i = 0; i < coordinates.length; ++i )
{
line.add( new Point3f( coordinates[ i ][ 0 ], coordinates[ i ][ 1 ], coordinates[ i ][ 2 ] ) );
}
return new CustomLineMesh( line, CustomLineMesh.CONTINUOUS );
}
void displayPointMesh(
float[][] points,
Image3DUniverse universe,
Color3f color,
float pointSize,
String title )
{
CustomPointMesh mesh = makePointMesh( points );
universe.addCustomMesh( mesh, title );
mesh.setPointSize( pointSize );
mesh.setColor( color );
}
void displayLineMesh(
float[][] lines,
Image3DUniverse universe,
Color3f color,
float lineWidth,
String title )
{
CustomLineMesh mesh = makeLineMesh( lines );
univ.addCustomMesh( mesh, title );
mesh.setLineWidth( lineWidth );
mesh.setColor( color );
}
/**
* Create a grid visualization of the given coordinates
* being transformed by a {@link CoordinateTransform}.
*/
CustomLineMesh makeGridMesh(
float[][] coordinates,
int maxRes,
CoordinateTransform t )
{
float[] min = new float[ coordinates[ 0 ].length ];
float[] size = new float[ coordinates[ 0 ].length ];
/* estimate the bounding box */
for ( float[] p : coordinates )
{
for ( int i = 0; i < p.length; ++i )
{
if ( p[ i ] < min[ i ] )
min[ i ] = p[ i ];
else if ( p[ i ] > size[ i ] )
size[ i ] = p[ i ];
}
}
float maxSize = -Float.MAX_VALUE;
for ( int i = 0; i < size.length; ++i )
{
size[ i ] -= min[ i ];
if ( maxSize < size[ i ] ) maxSize = size[ i ];
}
int[] res = new int[ size.length ];
final float s = maxSize / maxRes;
for ( int i = 0; i < size.length; ++i )
res[ i ] = ( int )Math.max( 1, ( int )Math.floor( size[ i ] / s ) );
/* build a 3d grid */
final ArrayList grid = new ArrayList();
for ( int z = 0; z <= res[ 2 ]; ++z )
{
for ( int y = 0; y <= res[ 1 ]; ++y )
{
for ( int x = 0; x <= res[ 0 ]; ++x )
{
float[] p = new float[]{
x * size[ 0 ] / res[ 0 ],
y * size[ 1 ] / res[ 1 ],
z * size[ 2 ] / res[ 2 ] };
if ( t != null ) t.applyInPlace( p );
if ( x != 0 )
{
float[] px = new float[]{
( x - 1 ) * size[ 0 ] / res[ 0 ],
y * size[ 1 ] / res[ 1 ],
z * size[ 2 ] / res[ 2 ] };
if ( t != null ) t.applyInPlace( px );
grid.add(
new Point3f( p[ 0 ], p[ 1 ], p[ 2 ] ) );
grid.add(
new Point3f( px[ 0 ], px[ 1 ], px[ 2 ] ) );
}
if ( y != 0 )
{
float[] py = new float[]{
x * size[ 0 ] / res[ 0 ],
( y - 1 ) * size[ 1 ] / res[ 1 ],
z * size[ 2 ] / res[ 2 ] };
if ( t != null ) t.applyInPlace( py );
grid.add(
new Point3f( p[ 0 ], p[ 1 ], p[ 2 ] ) );
grid.add(
new Point3f( py[ 0 ], py[ 1 ], py[ 2 ] ) );
}
if ( z != 0 )
{
float[] pz = new float[]{
x * size[ 0 ] / res[ 0 ],
y * size[ 1 ] / res[ 1 ],
( z - 1 ) * size[ 2 ] / res[ 2 ] };
if ( t != null ) t.applyInPlace( pz );
grid.add(
new Point3f( p[ 0 ], p[ 1 ], p[ 2 ] ) );
grid.add(
new Point3f( pz[ 0 ], pz[ 1 ], pz[ 2 ] ) );
}
}
}
}
return new CustomLineMesh( grid, CustomLineMesh.PAIRWISE );
}
Color3f r = new Color3f( 1, 0, 0 );
Color3f g = new Color3f( 0, 1, 0 );
Color3f y = new Color3f( 1, 1, 0 );
Image3DUniverse univ = new Image3DUniverse();
univ.show();
/* display the reference */
displayPointMesh( refLandmarks, univ, r, 4, "refLandmarks" );
displayLineMesh( refVector_peduncle, univ, r, 4, "refVector_peduncle" );
displayLineMesh( refVector_dorsal_lobe, univ, r, 4, "refVector_dorsal_lobe" );
displayLineMesh( refVector_medial_lobe, univ, r, 4, "refVector_medial_lobe" );
/* display the source grid */
CustomLineMesh srcLandmarksGrid = makeGridMesh( srcLandmarks, 16, null );
univ.addCustomMesh( srcLandmarksGrid, "grid" );
srcLandmarksGrid.setLineWidth( 0.5f );
srcLandmarksGrid.setTransparency( 0.8f );
/* display the source */
displayPointMesh( srcLandmarks, univ, g, 4, "srcLandmarks" );
displayLineMesh( srcVector_peduncle, univ, g, 4, "srcVector_peduncle" );
displayLineMesh( srcVector_dorsal_lobe, univ, g, 4, "srcVector_dorsal_lobe" );
displayLineMesh( srcVector_medial_lobe, univ, g, 4, "srcVector_medial_lobe" );
/* Now transform a bit ... */
ArrayList matches = new ArrayList();
for ( int i = 0; i < refLandmarks.length; ++i )
matches.add(
new PointMatch(
new Point(
new float[]{
srcLandmarks[ i ][ 0 ],
srcLandmarks[ i ][ 1 ],
srcLandmarks[ i ][ 2 ] } ),
new Point(
new float[]{
refLandmarks[ i ][ 0 ],
refLandmarks[ i ][ 1 ],
refLandmarks[ i ][ 2 ] } ) ) );
/* First with a single affine ... */
/*
AffineModel3D at = new AffineModel3D();
at.fit( matches );
for ( int i = 0; i < srcLandmarks.length; ++i )
at.applyInPlace( srcLandmarks[ i ] );
for ( int i = 0; i < srcVector_peduncle.length; ++i )
at.applyInPlace( srcVector_peduncle[ i ] );
for ( int i = 0; i < srcVector_dorsal_lobe.length; ++i )
at.applyInPlace( srcVector_dorsal_lobe[ i ] );
for ( int i = 0; i < srcVector_medial_lobe.length; ++i )
at.applyInPlace( srcVector_medial_lobe[ i ] );
displayPointMaytch( srcLandmarks, univ, g, 4, "srcLandmarks_affine" );
displayLineMesh( srcVector_peduncle, univ, g, 4, "srcVector_peduncle_affine" );
displayLineMesh( srcVector_dorsal_lobe, univ, g, 4, "srcVector_dorsal_lobe_affine" );
displayLineMesh( srcVector_medial_lobe, univ, g, 4, "srcVector_medial_lobe_affine" );
*/
/* Then with a MLS ... */
MovingLeastSquaresTransform mt = new MovingLeastSquaresTransform();
mt.setModel( AffineModel3D.class );
mt.setMatches( matches );
/* display the source transformation grid */
CustomLineMesh srcLandmarksGridMLS = makeGridMesh( srcLandmarks, 16, mt );
univ.addCustomMesh( srcLandmarksGridMLS, "grid_mls" );
srcLandmarksGridMLS.setLineWidth( 0.5f );
srcLandmarksGridMLS.setColor( y );
srcLandmarksGridMLS.setTransparency( 0.8f );
for ( int i = 0; i < srcLandmarks.length; ++i )
mt.applyInPlace( srcLandmarks[ i ] );
for ( int i = 0; i < srcVector_peduncle.length; ++i )
mt.applyInPlace( srcVector_peduncle[ i ] );
for ( int i = 0; i < srcVector_dorsal_lobe.length; ++i )
mt.applyInPlace( srcVector_dorsal_lobe[ i ] );
for ( int i = 0; i < srcVector_medial_lobe.length; ++i )
mt.applyInPlace( srcVector_medial_lobe[ i ] );
displayPointMesh( srcLandmarks, univ, y, 8, "srcLandmarks_mls" );
displayPointMesh( srcVector_peduncle, univ, y, 4, "srcVector_peduncle_mls" );
displayPointMesh( srcVector_dorsal_lobe, univ, y, 4, "srcVector_dorsal_lobe_mls" );
displayPointMesh( srcVector_medial_lobe, univ, y, 4, "srcVector_medial_lobe_mls" );