-
Notifications
You must be signed in to change notification settings - Fork 0
/
X-ray Bubbles v1.9.nb
1369 lines (1343 loc) · 68.7 KB
/
X-ray Bubbles v1.9.nb
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
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
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 0, 0]
NotebookDataLength[ 68943, 1368]
NotebookOptionsPosition[ 66340, 1304]
NotebookOutlinePosition[ 66906, 1325]
CellTagsIndexPosition[ 66863, 1322]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[CellGroupData[{
Cell["Initialize", "Section",
CellChangeTimes->{{3.7601694528358383`*^9,
3.760169472551669*^9}},ExpressionUUID->"ca134099-a44f-4fdc-af75-\
6ea375b76f8d"],
Cell[BoxData[{
RowBox[{"ClearAll", "[", "\"\<Global`*\>\"", "]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"$HistoryLength", "=", "1"}], ";"}], "\[IndentingNewLine]",
RowBox[{"SetOptions", "[",
RowBox[{
RowBox[{"EvaluationNotebook", "[", "]"}], ",",
RowBox[{"CellContext", "\[Rule]", "Notebook"}]}],
"]"}], "\[IndentingNewLine]",
RowBox[{"$Context", "\[IndentingNewLine]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"startTime", " ", "=", " ",
RowBox[{"AbsoluteTime", "[", "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"timeElapsed", ":=",
RowBox[{
RowBox[{"AbsoluteTime", "[", "]"}], "-", "startTime"}]}], ";"}],
"\[IndentingNewLine]", "\[IndentingNewLine]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"useKernels", "=", "34"}], ";", " ",
RowBox[{"(*",
RowBox[{
"Set", " ", "count", " ", "of", " ", "Mathematica", " ", "kernels", " ",
"to", " ", "launch"}], "*)"}], "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"launchNukes", "=",
RowBox[{"If", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"Length", "@",
RowBox[{"Kernels", "[", "]"}]}], "<", "useKernels"}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"Speak", "@", "\"\<Launching kernels\>\""}], ";",
"\[IndentingNewLine]",
RowBox[{"LaunchKernels", "[", "\[IndentingNewLine]",
RowBox[{"useKernels", "-",
RowBox[{"Length", "@",
RowBox[{"Kernels", "[", "]"}]}]}], "\[IndentingNewLine]", "]"}]}],
",", "\[IndentingNewLine]", "Nothing"}], "\[IndentingNewLine]", "]"}]}],
";"}], "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{"Set", " ", "output", " ", "directory"}],
"*)"}]}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"nbd", "=",
RowBox[{"NotebookDirectory", "[", "]"}]}], ";"}], "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{
RowBox[{"Set", " ", "input"}], ",", " ",
RowBox[{
"batches", " ", "are", " ", "folders", " ", "of", " ", "images"}]}],
"*)"}]}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
"batchDirectory", ":=",
"\"\<D:\\\\[BIG DATA]\\\\ACTIVE - Data From Experiments\\\\HZDR \
Data\\\\X-rays Benchmarks for Image Processing\\\\\>\""}],
"\[IndentingNewLine]", "\[IndentingNewLine]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"SetDirectory", "@", "batchDirectory"}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"batches", " ", "=",
RowBox[{"FileNames", "[", "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{"batches", "//", "Length"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"batches", "//", "TableForm"}],
RowBox[{"(*",
RowBox[{"Prints", " ", "folders", " ", "in", " ", "batch"}], "*)"}],
"\[IndentingNewLine]", "\[IndentingNewLine]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"progress", "[",
RowBox[{"x_", ",", "y_"}], "]"}], ":=",
RowBox[{"TableForm", "@", "\[IndentingNewLine]",
RowBox[{"{", "\[IndentingNewLine]",
RowBox[{"\"\<Processing...\>\"", ",", "\[IndentingNewLine]",
RowBox[{"ProgressIndicator", "@",
RowBox[{"Dynamic", "[",
RowBox[{
RowBox[{"x", "/", "y"}], "//", "N"}], "]"}]}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"ToString", "@",
RowBox[{"Round", "@", "x"}]}], "<>", "\"\</\>\"", "<>",
RowBox[{"ToString", "@", "y"}]}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"ToString", "@",
RowBox[{"Round", "[",
RowBox[{
RowBox[{"100", "*",
RowBox[{"x", "/", "y"}]}], "//", "N"}], "]"}]}], "<>",
"\"\< %\>\""}]}], "\[IndentingNewLine]", "}"}]}]}]}], "Input",
InitializationCell->True,
CellChangeTimes->{{3.7177377158430915`*^9, 3.717737755035079*^9}, {
3.717737785881243*^9, 3.7177378777432365`*^9}, {3.717737915081128*^9,
3.7177380504220033`*^9}, {3.7177380880730743`*^9, 3.717738300412363*^9}, {
3.7177383333519278`*^9, 3.7177383334300537`*^9}, {3.7177383751516523`*^9,
3.71773861392185*^9}, {3.7177386519353323`*^9, 3.717739081522292*^9}, {
3.717743829219696*^9, 3.7177438660163803`*^9}, {3.7177440825436897`*^9,
3.7177441583677993`*^9}, {3.7177441965440702`*^9,
3.7177441966913266`*^9}, {3.7237333110360184`*^9,
3.7237333200208473`*^9}, {3.7264886469717426`*^9,
3.7264886600385194`*^9}, {3.7283034273935757`*^9,
3.7283034581743827`*^9}, {3.729676337796929*^9, 3.729676341823734*^9}, {
3.747041048631316*^9, 3.74704104879334*^9}, {3.7513674506230288`*^9,
3.7513674979286723`*^9}, {3.7513707604688616`*^9, 3.7513707609725127`*^9},
3.751712760209059*^9, {3.751718054524271*^9, 3.751718059769699*^9}, {
3.7518135482953935`*^9, 3.7518135725814433`*^9}, {3.7518710407937007`*^9,
3.751871052004719*^9}, {3.751871358211807*^9, 3.751871364445162*^9}, {
3.751879175723353*^9, 3.7518791825590715`*^9}, {3.7519575243057594`*^9,
3.751957528260184*^9}, {3.7519581327610455`*^9, 3.7519581412344737`*^9}, {
3.751958453957793*^9, 3.7519584557566743`*^9}, {3.751968334426799*^9,
3.7519683353822217`*^9}, {3.7519700282986717`*^9, 3.75197002848617*^9}, {
3.7519737833049164`*^9, 3.75197380799761*^9}, {3.7519738973199735`*^9,
3.7519738974366484`*^9}, 3.751974453373953*^9, 3.7519744838607883`*^9, {
3.7519745775281367`*^9, 3.7519745791647434`*^9}, {3.7519863856792855`*^9,
3.751986410580202*^9}, {3.751987189723457*^9, 3.7519872067171807`*^9}, {
3.7519872740525713`*^9, 3.751987274251018*^9}, 3.7519887579797745`*^9, {
3.7519888044417067`*^9, 3.7519888045384264`*^9}, {3.7519889388743944`*^9,
3.751988953257942*^9}, {3.75198898540973*^9, 3.7519889857218943`*^9}, {
3.7519891583567*^9, 3.751989168418381*^9}, {3.751989242284319*^9,
3.7519892558884606`*^9}, {3.7519893723305483`*^9, 3.751989372402337*^9}, {
3.7519931269744205`*^9, 3.7519931279248924`*^9}, {3.751993166925639*^9,
3.7519931670293694`*^9}, 3.75199861425095*^9, {3.7519986697422304`*^9,
3.7519986922896194`*^9}, {3.751999213796385*^9, 3.7519992351032796`*^9}, {
3.7519994435814323`*^9, 3.7519994603814545`*^9}, {3.7519996162634587`*^9,
3.7519996233658457`*^9}, {3.7519999333676405`*^9,
3.7519999359958153`*^9}, {3.7520002180623083`*^9,
3.7520002187803435`*^9}, {3.7520002493768325`*^9,
3.7520002505482464`*^9}, {3.752000407725655*^9, 3.752000411067837*^9}, {
3.7520004699823575`*^9, 3.75200047026727*^9}, {3.7520022702769604`*^9,
3.7520022747149506`*^9}, {3.7520046929402857`*^9,
3.7520046960967264`*^9}, {3.7520502955602303`*^9,
3.7520503446601734`*^9}, {3.7520514690035224`*^9,
3.7520514690514917`*^9}, {3.7520515670681887`*^9,
3.7520515977009263`*^9}, {3.7520517074841633`*^9,
3.7520517090997686`*^9}, {3.7520518266893578`*^9,
3.7520518310232763`*^9}, {3.7520519932426023`*^9,
3.7520519966515093`*^9}, {3.752211767119261*^9, 3.7522117933048677`*^9},
3.7522118378507395`*^9, {3.7522119014341974`*^9, 3.7522119154280024`*^9}, {
3.752211947983062*^9, 3.7522119754180403`*^9}, {3.75238986004722*^9,
3.7523898600877047`*^9}, 3.759935401921358*^9, {3.7600950420507*^9,
3.7600950507155514`*^9}, 3.76009546165426*^9, {3.760097847762862*^9,
3.7600978479823008`*^9}, {3.7601571295604706`*^9, 3.760157129648235*^9},
3.7601592766146355`*^9, {3.7601729472799244`*^9, 3.760172947511306*^9}, {
3.7601732107197742`*^9, 3.760173211161602*^9}, 3.760175621125779*^9,
3.7602497894762554`*^9, 3.7602549941536517`*^9, 3.7602587711196823`*^9, {
3.760269954882045*^9, 3.760269955256042*^9}, {3.7602794081805344`*^9,
3.760279410170213*^9}, {3.7602794702182603`*^9, 3.7602794767148857`*^9}, {
3.7603410399150243`*^9, 3.760341041124792*^9}, {3.7604556788470125`*^9,
3.760455727922307*^9}, {3.7607682966617975`*^9, 3.760768308975419*^9},
3.7607854536095047`*^9, {3.7608865838057194`*^9, 3.760886593361717*^9}, {
3.7608866844010015`*^9, 3.7608866845675573`*^9}, {3.760887388038473*^9,
3.7608873882957788`*^9}, {3.760892595971661*^9, 3.7608926320929804`*^9}, {
3.760929281108795*^9, 3.7609292932042255`*^9}, {3.7609293967314425`*^9,
3.7609294116522813`*^9}, {3.7609299152508698`*^9,
3.7609299156738005`*^9}, {3.760929954547063*^9, 3.7609300117870555`*^9}, {
3.7609305684759817`*^9, 3.7609305685647535`*^9}, {3.7609314858821344`*^9,
3.7609314866510773`*^9}, {3.76093194642652*^9, 3.7609320560911016`*^9}, {
3.7609321259960537`*^9, 3.760932174706381*^9}, {3.760932243970749*^9,
3.7609322520343113`*^9}, {3.7609322828032403`*^9,
3.7609322830575356`*^9}, {3.7609323214867444`*^9, 3.760932328043228*^9}, {
3.7609324262318645`*^9, 3.760932446891398*^9}, {3.7609325111705904`*^9,
3.7609325119006367`*^9}, {3.760932875991317*^9, 3.760932877280859*^9},
3.7609344640420094`*^9, {3.7609346032407713`*^9, 3.7609346068281736`*^9},
3.7609433236004734`*^9, {3.760956474733452*^9, 3.760956588831177*^9}, {
3.760957423846837*^9, 3.760957424285645*^9}, {3.7609580829565725`*^9,
3.760958083252755*^9}, {3.7609624911993523`*^9, 3.760962491368901*^9},
3.760964457907423*^9, {3.7609646733113832`*^9, 3.7609646739666595`*^9}, {
3.7612251729077897`*^9, 3.761225175298395*^9}, 3.761228707061983*^9, {
3.761228758894994*^9, 3.7612287693206973`*^9}, 3.76122887626292*^9, {
3.761241692049399*^9, 3.761241700577155*^9}, {3.761276326824277*^9,
3.7612763974426746`*^9}, {3.761276432872349*^9, 3.7612764775169487`*^9}, {
3.7612946605842495`*^9, 3.761294670639862*^9}, {3.761299408431904*^9,
3.761299408500719*^9}, {3.7612996367268124`*^9, 3.7612996374924726`*^9}, {
3.761300049404646*^9, 3.7613000513349247`*^9}, 3.7613041176850076`*^9, {
3.7613180259074817`*^9, 3.7613180299262967`*^9}, {3.761326801495341*^9,
3.761326801590087*^9}, {3.761361249393982*^9, 3.7613612743078856`*^9},
3.761361637701935*^9, 3.7613688777915*^9, {3.7613702345313025`*^9,
3.761370234824539*^9}, 3.7613711538469987`*^9, {3.7613717056648607`*^9,
3.761371739016631*^9}, {3.7613737377183404`*^9, 3.761373764221431*^9}, {
3.7613739329982166`*^9, 3.7613739347046556`*^9}, {3.76138015596413*^9,
3.7613801562354217`*^9}, 3.7613846372534046`*^9, 3.7613861252512884`*^9, {
3.761386510741501*^9, 3.761386512992342*^9}, {3.76138735930517*^9,
3.7613873604308023`*^9}, 3.7613919238287992`*^9, {3.7613966008619995`*^9,
3.761396602922511*^9}, {3.761397681510357*^9, 3.7613977017222805`*^9}, {
3.761397741281606*^9, 3.7613977420625305`*^9}, 3.761458322673535*^9, {
3.7614808507366533`*^9, 3.761480850863311*^9}, {3.761481217958542*^9,
3.761481218006412*^9}, {3.761481391522843*^9, 3.7614813917023582`*^9}, {
3.7616463961540794`*^9, 3.7616463965540085`*^9}, {3.7616466354593477`*^9,
3.7616466372246256`*^9}, 3.7616469120822287`*^9, {3.7616469825807066`*^9,
3.7616469828070736`*^9}, 3.7616471557855463`*^9, {3.7616474401845856`*^9,
3.7616474403651204`*^9}, {3.7669408858877015`*^9,
3.7669409039843745`*^9}, {3.766941304508911*^9, 3.766941317480905*^9}, {
3.7669421675895166`*^9, 3.7669421679592876`*^9}, {3.7669422723714056`*^9,
3.7669422852215776`*^9}, 3.7693096869252996`*^9, {3.7693121239866257`*^9,
3.769312124973962*^9}, {3.770495826828769*^9, 3.7704958272831993`*^9}, {
3.770496682805866*^9, 3.7704966853412914`*^9}, 3.7704972485030303`*^9, {
3.772348615909038*^9, 3.7723486259132843`*^9}, {3.7723569128808775`*^9,
3.7723569371043353`*^9}, 3.772357142969572*^9, {3.773302667131933*^9,
3.7733026751664457`*^9}, 3.7733110313379755`*^9, {3.773313780313419*^9,
3.7733138221432843`*^9}, {3.773314248470578*^9, 3.7733142486251464`*^9}, {
3.7733142787356873`*^9, 3.773314292375209*^9}, 3.77331446898584*^9,
3.7733158643634233`*^9, 3.773384309726469*^9, {3.7733843768285084`*^9,
3.773384377838806*^9}, {3.7733844281663017`*^9, 3.773384449669899*^9}, {
3.773385380102294*^9, 3.7733853802798233`*^9}, {3.773385937875291*^9,
3.773385938044855*^9}, {3.7733861080067606`*^9, 3.7733861091726418`*^9}, {
3.777997349884369*^9, 3.7779973563449507`*^9}, {3.7779996736864486`*^9,
3.7779996945889626`*^9}, {3.778000628153318*^9, 3.77800062846565*^9}, {
3.778910686621645*^9, 3.778910697341301*^9}, 3.778912337336089*^9,
3.7789123768874874`*^9, {3.7789159986463156`*^9, 3.7789160026207256`*^9}, {
3.7809872939257684`*^9, 3.7809873006298585`*^9}, {3.780987475485282*^9,
3.78098747556008*^9}, {3.7809896040832243`*^9, 3.780989604150044*^9}, {
3.781935631264923*^9, 3.7819357387741823`*^9}, {3.781935786817588*^9,
3.781935789483755*^9}, {3.781935822050601*^9, 3.781935844021475*^9},
3.781935952957399*^9, {3.7819360298904686`*^9, 3.781936152963578*^9}, {
3.781936269545663*^9, 3.781936273291142*^9}, {3.7819363239942007`*^9,
3.7819363715786777`*^9}, {3.7819364243604083`*^9, 3.781936490311517*^9}, {
3.7819365596095605`*^9, 3.781936596070054*^9}, {3.7819366925687356`*^9,
3.7819366957739286`*^9}, {3.7819368052746944`*^9, 3.781936807140668*^9}, {
3.781936859476156*^9, 3.781936863401528*^9}, {3.7819416869917955`*^9,
3.7819417112924576`*^9}, {3.782543730338276*^9, 3.7825437436547947`*^9}, {
3.7825445288316917`*^9, 3.7825445413330674`*^9}, {3.782549525253271*^9,
3.7825495759256086`*^9}, 3.782550829225337*^9, 3.7825510657753696`*^9, {
3.7825610200080705`*^9, 3.782561029255045*^9}, {3.782561330183058*^9,
3.7825613307435355`*^9}, {3.7825621095052013`*^9,
3.7825621437652845`*^9}, {3.782562204700952*^9, 3.782562240849332*^9}, {
3.7825623277982025`*^9, 3.782562329644215*^9}, {3.782562394600174*^9,
3.7825623991765485`*^9}, {3.782562555569565*^9, 3.782562586701932*^9}, {
3.782811721951993*^9, 3.78281173300521*^9}, {3.782811806833519*^9,
3.7828118474077225`*^9}, {3.7828118863261986`*^9, 3.782811886544095*^9}, {
3.78281216649263*^9, 3.7828121743060193`*^9}, {3.782812285957327*^9,
3.782812310254076*^9}, {3.782905628363512*^9, 3.7829056766168594`*^9}, {
3.7829057346254635`*^9, 3.782905736966573*^9}, {3.7829541779702463`*^9,
3.782954178967338*^9}, {3.78295495311665*^9, 3.782954960798777*^9},
3.783318420161974*^9, {3.783318592271903*^9, 3.7833185995539093`*^9}, {
3.7833186779453497`*^9, 3.783318678257719*^9}, {3.7833392025862613`*^9,
3.7833392047583385`*^9}, {3.783339263051766*^9, 3.7833392655205774`*^9}, {
3.7836865941072903`*^9, 3.7836866002947683`*^9}, {3.783686712826186*^9,
3.7836867178144765`*^9}, {3.7836867657394342`*^9, 3.7836867657785387`*^9},
3.783687283264184*^9, {3.7836874026207447`*^9, 3.7836874027049575`*^9}, {
3.783687604715908*^9, 3.783687606035407*^9}, {3.783690156587172*^9,
3.783690156887972*^9}, {3.783775559742628*^9, 3.783775565458743*^9},
3.7838403790244675`*^9, {3.783840817865399*^9, 3.7838408183406677`*^9}, {
3.7838409041394987`*^9, 3.7838409079737425`*^9}, {3.783840999613789*^9,
3.783841000758848*^9}, {3.7838411538186135`*^9, 3.783841169385147*^9}, {
3.783841260332086*^9, 3.7838412603942523`*^9}, {3.783841443005767*^9,
3.7838414437407427`*^9}, 3.7839189602328396`*^9, {3.783918993528123*^9,
3.7839189935776834`*^9}, {3.783921394659896*^9, 3.783921395575432*^9}, {
3.7839217286527004`*^9, 3.783921735277869*^9}, {3.7839314390562525`*^9,
3.7839314415103645`*^9}, {3.7839354079410405`*^9, 3.78393548147972*^9},
3.7842903496261168`*^9, 3.784292608699628*^9, {3.784292658412279*^9,
3.784292662423986*^9}, {3.784292828983741*^9, 3.7842928320539427`*^9}, {
3.784298737150395*^9, 3.7842987508490076`*^9}, {3.7843036626957164`*^9,
3.784303662775931*^9}, 3.7843272589156914`*^9, {3.7843275909060335`*^9,
3.7843275912402177`*^9}, {3.7843591557525606`*^9,
3.7843591557659545`*^9}, {3.784386027858904*^9, 3.784386031639289*^9}, {
3.7843919626786337`*^9, 3.7843919627282486`*^9}, 3.784403184161606*^9,
3.7844071042245655`*^9, {3.842588872792037*^9, 3.8425888978411617`*^9}, {
3.843875638052524*^9, 3.843875661849861*^9}, 3.844507229481266*^9, {
3.845035801008132*^9, 3.845035805843377*^9}, {3.8450382118847113`*^9,
3.84503821515665*^9}, {3.84503842497435*^9, 3.845038446050909*^9}, {
3.845084210927106*^9, 3.84508421117356*^9}, {3.845112687313458*^9,
3.84511268755442*^9}, {3.845114719936674*^9, 3.845114720002236*^9}, {
3.845115702138193*^9, 3.8451157022150993`*^9}, {3.845116687638585*^9,
3.845116687721293*^9}, {3.845118985972445*^9, 3.845118986056671*^9}, {
3.845120808246766*^9, 3.845120812006054*^9}, {3.845787898673205*^9,
3.84578790103152*^9}, {3.845791710200428*^9, 3.8457917209660673`*^9}, {
3.8502989742301683`*^9, 3.850298974618709*^9}, {3.851146621360949*^9,
3.85114663188135*^9}, {3.851165396420528*^9, 3.851165397574546*^9}, {
3.851165522448071*^9, 3.851165527132092*^9}, {3.851167839090938*^9,
3.851167839528161*^9}, {3.85116807302209*^9, 3.851168096360923*^9}, {
3.85125684849809*^9, 3.851256849315588*^9}, {3.851257136983713*^9,
3.851257137393353*^9}, 3.851416788917988*^9, {3.851436177429657*^9,
3.851436190092196*^9}, {3.851491656249277*^9, 3.851491676529953*^9}, {
3.851494345875263*^9, 3.851494367757698*^9}, {3.8552554216858377`*^9,
3.855255431453865*^9}, {3.855382004875628*^9, 3.8553820365855618`*^9}, {
3.855391256596958*^9, 3.855391264209152*^9}, {3.855391303552845*^9,
3.85539130413202*^9}, {3.8557293033159647`*^9, 3.855729317759015*^9}, {
3.855729377956114*^9, 3.855729397602292*^9}, {3.855729502706747*^9,
3.855729505315651*^9}, {3.855729692733131*^9, 3.855729711371088*^9}, {
3.85572975637493*^9, 3.85572977753918*^9}, {3.855729837498407*^9,
3.8557298481118*^9}, {3.856249390847074*^9, 3.856249437039401*^9}, {
3.856249486786076*^9, 3.85624960495793*^9}, {3.8562499255168123`*^9,
3.856249944509707*^9}, {3.856252289743327*^9, 3.8562522927056837`*^9}, {
3.856254748817528*^9, 3.856254782830542*^9}, {3.856255285725709*^9,
3.856255289154048*^9}, {3.856268313370656*^9, 3.8562683435110283`*^9}, {
3.8562683919993057`*^9, 3.8562684053174667`*^9}, {3.859021672351989*^9,
3.859021681643783*^9}, {3.859451425847169*^9, 3.8594514351375723`*^9}, {
3.860045958434455*^9, 3.860045960493469*^9}, {3.860045995381274*^9,
3.860045996580369*^9}, {3.8600498451758375`*^9, 3.860049855711029*^9},
3.8600498986090145`*^9, {3.860049950356762*^9, 3.860049954671027*^9}, {
3.8600588117248917`*^9, 3.860058834112878*^9}, 3.860059040764468*^9, {
3.8600596120856943`*^9, 3.860059619659663*^9}, {3.860060030197404*^9,
3.860060035079748*^9}, {3.860078517566392*^9, 3.86007853473974*^9}, {
3.860741813770084*^9, 3.860741817282125*^9}, 3.8607418602949266`*^9,
3.860744350617853*^9, {3.8622410041123123`*^9, 3.862241023256938*^9}, {
3.86291444972351*^9, 3.862914450674755*^9}, {3.8629470509037037`*^9,
3.86294709339123*^9}, {3.8629471851051483`*^9, 3.862947192455482*^9}, {
3.869297713287373*^9, 3.869297747266222*^9}, {3.869299098431284*^9,
3.869299121042487*^9}, {3.870787019030633*^9, 3.870787023390145*^9}, {
3.870787639402027*^9, 3.87078771812568*^9}, 3.870788136571521*^9, {
3.8707884184591722`*^9, 3.8707884289094954`*^9}, {3.8707887903006134`*^9,
3.8707888076595945`*^9}, 3.870790224219264*^9},
CellLabel->"In[1]:=",ExpressionUUID->"5bdd9b41-adda-49f7-8ac7-e53702cea021"]
}, Open ]],
Cell[CellGroupData[{
Cell["Filter function definitions", "Section",
CellChangeTimes->{{3.751808845615265*^9, 3.75180886393727*^9}, {
3.751808901177807*^9, 3.7518089106497416`*^9}, {3.8426073866211615`*^9,
3.8426073883328094`*^9}, {3.842607419564908*^9, 3.8426074208915234`*^9}, {
3.85539217810675*^9, 3.8553922322676373`*^9}, {3.869297787524592*^9,
3.8692977951037283`*^9}, {3.8707878323074036`*^9,
3.870787836635366*^9}},ExpressionUUID->"46134b1a-e07e-4140-b2c8-\
d07a1cf56718"],
Cell[CellGroupData[{
Cell["Measurements", "Subsection",
CellChangeTimes->{{3.8553922564755487`*^9,
3.855392274521996*^9}},ExpressionUUID->"d15ccfb4-8b6a-43d3-86cb-\
1fa3f92c1214"],
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{"minimumComponentSize", "=", "3000"}], ";"}], " ",
RowBox[{"(*",
RowBox[{"Also", " ", "used", " ", "for", " ", "localFilter"}], "*)"}],
"\[IndentingNewLine]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"getSegmentData", "[", "image_", "]"}], ":=",
RowBox[{"(", "\[IndentingNewLine]",
RowBox[{
RowBox[{"ComponentMeasurements", "[",
RowBox[{"image", ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
"\"\<Image\>\"", ",", "\"\<FilledCount\>\"", ",", "\"\<Centroid\>\"",
",", "\"\<SemiAxes\>\"", ",", "\"\<BoundingBox\>\""}], "}"}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"#FilledCount", ">", "minimumComponentSize"}], "&"}]}],
"\[IndentingNewLine]", "]"}], "/.",
RowBox[{"Rule", "\[Rule]", "List"}]}], "\[IndentingNewLine]", ")"}]}],
";"}]}], "Input",
InitializationCell->True,
CellChangeTimes->{{3.8426065570436583`*^9, 3.8426066665406322`*^9}, {
3.842607007516513*^9, 3.842607055476473*^9}, {3.842607109158572*^9,
3.8426071354205365`*^9}, 3.8438779972923813`*^9, {3.8441620862155457`*^9,
3.844162102320812*^9}, {3.844162168697233*^9, 3.844162182347393*^9},
3.8441625552347507`*^9, {3.844164251039551*^9, 3.844164256863307*^9},
3.851166226451797*^9, {3.851411532709231*^9, 3.851411537913583*^9}, {
3.851411571809169*^9, 3.851411610630981*^9}, {3.869297770482448*^9,
3.869297774196671*^9}},
CellLabel->"In[15]:=",ExpressionUUID->"879259f2-7656-480a-bdb2-94d48148443e"]
}, Open ]],
Cell[CellGroupData[{
Cell["Local filter", "Subsection",
CellChangeTimes->{{3.855392266253675*^9, 3.855392268362562*^9}, {
3.855729987429985*^9,
3.855729993631806*^9}},ExpressionUUID->"72cb9da9-d861-4931-a3ab-\
66302b11f2d7"],
Cell[CellGroupData[{
Cell["Interrogation window generator", "Subsubsection",
CellChangeTimes->{{3.855730002832407*^9, 3.855730015378971*^9}, {
3.86929785068484*^9, 3.86929785622878*^9}, {3.8707877271152325`*^9,
3.8707877362206793`*^9}},ExpressionUUID->"0b6d20cc-4936-4e26-a83e-\
03e3b772a459"],
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{"scaleSide", " ", "=", " ", "1.2"}], ";"}], " ",
RowBox[{"(*",
RowBox[{
"scale", " ", "modifier", " ", "of", " ", "segment", " ", "bounding", " ",
"box"}], "*)"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"xPad", "[", "box_", "]"}], " ", ":=", " ",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"2", ",", "1"}], "]"}], "]"}], "-",
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"1", ",", "1"}], "]"}], "]"}]}], ")"}], "*",
RowBox[{
RowBox[{"(",
RowBox[{"scaleSide", "-", "1"}], ")"}], "/", "2"}]}], ")"}], "//",
"Round"}]}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"yPad", "[", "box_", "]"}], " ", ":=", " ",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"2", ",", "2"}], "]"}], "]"}], "-",
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"1", ",", "2"}], "]"}], "]"}]}], ")"}], "*",
RowBox[{
RowBox[{"(",
RowBox[{"scaleSide", "-", "1"}], ")"}], "/", "2"}]}], ")"}], "//",
"Round"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"boxCenter", "[", "box_", "]"}], " ", ":=", " ",
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"1", ",", "1"}], "]"}], "]"}], "+",
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"2", ",", "1"}], "]"}], "]"}]}], ")"}], "/", "2"}], ",",
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"1", ",", "2"}], "]"}], "]"}], "+",
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"2", ",", "2"}], "]"}], "]"}]}], ")"}], "/", "2"}]}],
"}"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{
"Logic", " ", "to", " ", "avoid", " ", "boxes", " ", "out", " ", "of", " ",
"image", " ", "bounds"}], "*)"}]}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"newBox", "[", "box_", "]"}], ":=",
RowBox[{"{", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"If", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"1", ",", "1"}], "]"}], "]"}], "-",
RowBox[{"xPad", "[", "box", "]"}]}], ")"}], "<", "0"}], " ", ",",
"\[IndentingNewLine]", "0", ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"1", ",", "1"}], "]"}], "]"}], "-",
RowBox[{"xPad", "[", "box", "]"}]}]}], "\[IndentingNewLine]", "]"}],
",", "\[IndentingNewLine]",
RowBox[{"If", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"1", ",", "2"}], "]"}], "]"}], "-",
RowBox[{"yPad", "[", "box", "]"}]}], ")"}], "<", "0"}], " ", ",",
"\[IndentingNewLine]", "0", ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"1", ",", "2"}], "]"}], "]"}], "-",
RowBox[{"yPad", "[", "box", "]"}]}]}], "\[IndentingNewLine]",
"]"}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"If", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"2", ",", "1"}], "]"}], "]"}], "+",
RowBox[{"xPad", "[", "box", "]"}]}], ")"}], ">", "widthPixels"}],
",", "\[IndentingNewLine]", "widthPixels", ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"2", ",", "1"}], "]"}], "]"}], "+",
RowBox[{"xPad", "[", "box", "]"}]}]}], "\[IndentingNewLine]", "]"}],
",", "\[IndentingNewLine]",
RowBox[{"If", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"(",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"2", ",", "2"}], "]"}], "]"}], "+",
RowBox[{"yPad", "[", "box", "]"}]}], ")"}], ">", "heightPixels"}],
",", "\[IndentingNewLine]", "heightPixels", ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"box", "[",
RowBox[{"[",
RowBox[{"2", ",", "2"}], "]"}], "]"}], "+",
RowBox[{"yPad", "[", "box", "]"}]}]}], "\[IndentingNewLine]",
"]"}]}], "}"}]}], "\[IndentingNewLine]", "}"}]}]}], "Input",
InitializationCell->True,
CellChangeTimes->{{3.8444756687969522`*^9, 3.844475673756844*^9}, {
3.844508040436142*^9, 3.844508043415061*^9}, {3.844508094184463*^9,
3.844508121101644*^9}, {3.844508590752921*^9, 3.844508606101742*^9}, {
3.844509060452243*^9, 3.844509066315613*^9}, {3.844509535653557*^9,
3.844509569011448*^9}, {3.8445096045397043`*^9, 3.844509627349168*^9}, {
3.84450980662374*^9, 3.844509837721684*^9}, {3.844511345260723*^9,
3.8445113577695637`*^9}, {3.8447766046522293`*^9, 3.8447766145757513`*^9},
3.845018863747046*^9, {3.845790508774413*^9, 3.84579051056236*^9},
3.845791812943026*^9, {3.8491666552353888`*^9, 3.849166656803797*^9}, {
3.851257440494066*^9, 3.851257442080125*^9}, 3.851411072079576*^9,
3.862288467819206*^9, {3.862291830857634*^9, 3.862291831892325*^9}, {
3.8629298233911123`*^9, 3.86292982516271*^9}, {3.8692978582547483`*^9,
3.869297922812454*^9}, {3.869299153041678*^9, 3.869299174629799*^9}, {
3.8707877571728587`*^9, 3.870787775621525*^9}},
CellLabel->"In[40]:=",ExpressionUUID->"d1095e33-3a62-4236-a71c-cd273ada1ac0"]
}, Open ]],
Cell[CellGroupData[{
Cell["Local filter sequence", "Subsubsection",
CellChangeTimes->{{3.855730039094634*^9, 3.855730048629545*^9},
3.855730119511755*^9,
3.87078781439604*^9},ExpressionUUID->"200b3a4a-a577-4c86-bee7-\
2edccbb6b300"],
Cell[BoxData[{
RowBox[{
RowBox[{
RowBox[{"repair", "[",
RowBox[{"img_", ",", "scale_"}], "]"}], ":=",
RowBox[{
RowBox[{"Closing", "[",
RowBox[{"img", ",",
RowBox[{"DiskMatrix", "@", "scale"}]}], "]"}], "//",
"FillingTransform"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"localFilter", "[", "image_", "]"}], ":=",
RowBox[{"Block", "[",
RowBox[{
RowBox[{"{", "}"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"nonLocal", "=",
RowBox[{
RowBox[{
RowBox[{"NonlocalMeansFilter", "[",
RowBox[{
"#", ",", "\[IndentingNewLine]", "nonlocalMeansFilteringRadius", ",",
"\[IndentingNewLine]", "nonlocalMeansSearchRadius"}],
"\[IndentingNewLine]", "]"}], "&"}], "@", "image"}]}], ";",
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"localNonLocal", "=",
RowBox[{
RowBox[{
RowBox[{"LocalAdaptiveBinarize", "[",
RowBox[{"#", ",", "localAdaptiveRadius", ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
"localAdaptiveMeanFactor", ",", "localAdaptiveDeviationFactor",
",", "localAdaptiveOffset"}], "}"}]}], "\[IndentingNewLine]",
"]"}], "&"}], "@", "nonLocal"}]}], ";", " ",
RowBox[{"(*",
RowBox[{"tuned", " ", "to", " ", "be", " ", "conservative"}], "*)"}],
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"filledNon", "=",
RowBox[{"FillingTransform", "@",
RowBox[{"DeleteBorderComponents", "@", "localNonLocal"}]}]}], ";",
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"resolveNon", " ", "=",
RowBox[{
RowBox[{
RowBox[{
RowBox[{
RowBox[{
RowBox[{
RowBox[{"Opening", "[",
RowBox[{"#", ",",
RowBox[{"DiskMatrix", "@", "resolveOpeningScale"}]}], "]"}],
"&"}], "@", "\[IndentingNewLine]",
RowBox[{"Erosion", "[",
RowBox[{"#", ",",
RowBox[{"DiskMatrix", "@", "resolveErosionScale"}]}], "]"}]}],
"&"}], "@", " ", "\[IndentingNewLine]",
RowBox[{"DeleteSmallComponents", "[",
RowBox[{"#", ",", "minimumComponentSize"}], "]"}]}], "&"}], "@",
"filledNon"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"grad", " ", "=",
RowBox[{
RowBox[{
RowBox[{"GradientFilter", "[",
RowBox[{"#", ",", "GradientFilterRadius"}], "]"}], "&"}], "@",
"nonLocal"}]}], ";",
RowBox[{"(*",
RowBox[{"can", " ", "still", " ", "tuned"}], "*)"}],
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"localBinarized", "=", " ",
RowBox[{
RowBox[{
RowBox[{"LocalAdaptiveBinarize", "[",
RowBox[{"#", ",", "LocalBinRadius", ",",
RowBox[{"{",
RowBox[{"1", ",", "0", ",", "0.00001"}], "}"}]}], "]"}], "&"}],
"@", "grad"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"addedANDfilled", "=",
RowBox[{
RowBox[{
RowBox[{"DeleteBorderComponents", "@",
RowBox[{"Opening", "[",
RowBox[{"#", ",",
RowBox[{"DiskMatrix", "@", "addFillOpeningScale"}]}], "]"}]}],
"&"}], "@",
RowBox[{"FillingTransform", "@",
RowBox[{"ImageAdd", "[",
RowBox[{"localBinarized", ",", "resolveNon"}], "]"}]}]}]}], ";",
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"resolve", " ", "=", " ",
RowBox[{
RowBox[{
RowBox[{"DeleteSmallComponents", "[",
RowBox[{"#", ",", "minimumComponentSize"}], "]"}], "&"}], "@",
"addedANDfilled"}]}], ";", "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"makeRepairs", "=",
RowBox[{
RowBox[{
RowBox[{
RowBox[{
RowBox[{"Binarize", "/@",
RowBox[{"repair", "[",
RowBox[{"#", ",", "repairScale"}], "]"}]}], "&"}], "/@",
RowBox[{"Image", "/@",
RowBox[{"Last", "/@",
RowBox[{"Last", "/@",
RowBox[{"ComponentMeasurements", "[",
RowBox[{"#", ",",
RowBox[{"{", "\"\<Mask\>\"", "}"}]}], "]"}]}]}]}]}], "&"}], "@",
"resolve"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"combin", "=",
RowBox[{"If", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"makeRepairs", "\[Equal]",
RowBox[{"{", "}"}]}], ",", "resolve", ",",
RowBox[{"ImageAdd", "[", "makeRepairs", "]"}]}],
"\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"outline", " ", "=", " ",
RowBox[{
RowBox[{
RowBox[{"Binarize", "[",
RowBox[{"#", ",", "threshold"}], "]"}], "&"}], "@", "nonLocal"}]}],
";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"finalOutput", "=",
RowBox[{
RowBox[{
RowBox[{"DeleteSmallComponents", "[",
RowBox[{"#", ",", "localMinSize"}], "]"}], "&"}], "@",
RowBox[{"Binarize", "[",
RowBox[{
RowBox[{"outline", "-",
RowBox[{"ColorNegate", "@", "combin"}]}], ",", "0.999"}],
"]"}]}]}]}]}],
RowBox[{"(*",
RowBox[{"wtf", ",", " ",
RowBox[{
"also", " ", "need", " ", "another", " ", "area", " ", "filter"}]}],
"*)"}], "\[IndentingNewLine]", "]"}]}]}], "Input",
InitializationCell->True,
CellChangeTimes->{{3.849165468231838*^9, 3.84916547208801*^9}, {
3.849165516340804*^9, 3.849165529890294*^9}, {3.849165626423729*^9,
3.849165674073311*^9}, {3.849165730700326*^9, 3.8491657420514307`*^9}, {
3.849165778244113*^9, 3.849165788550479*^9}, {3.849165818812743*^9,
3.84916583006354*^9}, {3.849166085384906*^9, 3.8491661126193438`*^9}, {
3.8491663249035673`*^9, 3.849166336479144*^9}, {3.8508086530682993`*^9,
3.8508086746566*^9}, {3.850808758174551*^9, 3.8508087754423723`*^9}, {
3.850808865123225*^9, 3.8508088652622766`*^9}, 3.850810750193274*^9,
3.850810873080394*^9, 3.850811227662965*^9, {3.8508112648564672`*^9,
3.850811272755131*^9}, {3.850811395124139*^9, 3.850811395193986*^9}, {
3.8508962963501263`*^9, 3.850896314870048*^9}, 3.850896439558076*^9, {
3.85089839639988*^9, 3.85089842765831*^9}, {3.850898490680416*^9,
3.850898491774251*^9}, {3.850898798168311*^9, 3.8508987982317657`*^9}, {
3.8508998734109697`*^9, 3.850899952612303*^9}, {3.851070586555759*^9,
3.851070591993224*^9}, {3.851070743980932*^9, 3.851070785762224*^9}, {
3.8510708271497717`*^9, 3.851070843831998*^9}, {3.8511604654602613`*^9,
3.851160471518746*^9}, {3.8511605363230133`*^9, 3.851160561923091*^9}, {
3.851160638621375*^9, 3.851160713213951*^9}, {3.851160773073618*^9,
3.8511607764362383`*^9}, {3.851160879304347*^9, 3.851160894446467*^9}, {
3.851160946411192*^9, 3.851160950812594*^9}, {3.85116099149681*^9,
3.851160992706768*^9}, {3.851161284374817*^9, 3.8511612881158113`*^9}, {
3.851161375238935*^9, 3.8511613832419033`*^9}, {3.851161502018971*^9,
3.851161506026701*^9}, {3.851162632882958*^9, 3.851162650444531*^9}, {
3.851162898951083*^9, 3.851162899793001*^9}, {3.851165916643284*^9,
3.8511659288077517`*^9}, {3.851411001577317*^9, 3.851411002735545*^9}, {
3.851411106248914*^9, 3.851411106659194*^9}, {3.851411149766631*^9,
3.851411203890164*^9}, {3.851411490338826*^9, 3.8514114923673267`*^9}, {
3.851420215284925*^9, 3.851420287646965*^9}, {3.855392329350402*^9,
3.855392351954213*^9}, {3.8600479937044764`*^9, 3.860048000269642*^9}, {
3.860048096423245*^9, 3.860048097527088*^9}, {3.8600484270621967`*^9,
3.8600484292707977`*^9}, {3.860058888626412*^9, 3.8600589171576653`*^9},
3.862240963187581*^9, {3.862250327035775*^9, 3.862250332573162*^9}, {
3.862290490889947*^9, 3.862290506359131*^9}, {3.8622934681701393`*^9,
3.8622934682535353`*^9}, 3.862293933904554*^9, 3.8622940334277353`*^9, {
3.8622952046242847`*^9, 3.862295207118287*^9}, 3.8622952768234577`*^9, {
3.862295371426626*^9, 3.862295374647915*^9}, {3.862296918574012*^9,
3.862296918713704*^9}, {3.86229718839336*^9, 3.862297204209866*^9},
3.862297326439307*^9, {3.862297363810978*^9, 3.8622973693614063`*^9}, {
3.862298154409315*^9, 3.862298162713524*^9}, {3.862298287420413*^9,
3.8622982880367126`*^9}, {3.862298937927034*^9, 3.8622989380882807`*^9},
3.86229904304469*^9, {3.862299099465261*^9, 3.862299114870165*^9}, {
3.8622991466212883`*^9, 3.862299158693223*^9}, {3.8622992742481318`*^9,
3.862299300331071*^9}, 3.8629321563676853`*^9, {3.8629329176272593`*^9,
3.862933004215103*^9}, {3.862933131384767*^9, 3.862933133515559*^9}, {
3.862933607666532*^9, 3.8629338177623987`*^9}, 3.862935483217122*^9, {
3.862935941639187*^9, 3.8629360083573236`*^9}, {3.862936113216325*^9,
3.862936138472087*^9}, {3.8629362907935257`*^9, 3.8629363215915203`*^9}, {
3.862936502231299*^9, 3.862936512220972*^9}, {3.86293674807047*^9,
3.8629367968624697`*^9}, {3.862937898740398*^9, 3.862937912386444*^9}, {
3.862938000323145*^9, 3.862938014470604*^9}, 3.8629381679325047`*^9, {
3.862938206799197*^9, 3.8629382071805887`*^9}, {3.86293828951814*^9,
3.862938359331738*^9}, 3.8629969636382513`*^9, {3.869299235191389*^9,
3.86929924090233*^9}, {3.8707877858492746`*^9, 3.870787803284393*^9}, {
3.8707879583021555`*^9, 3.870787994571618*^9}, {3.870788454659085*^9,
3.8707884896113977`*^9}},
CellLabel->"In[45]:=",ExpressionUUID->"67210cac-2048-43dc-9a0e-3c36160f2148"]
}, Open ]]
}, Open ]],
Cell[CellGroupData[{
Cell["Global sequence init.", "Subsection",
CellChangeTimes->{{3.855392372789317*^9, 3.8553923987099037`*^9}, {
3.869299284673504*^9,
3.8692992855089607`*^9}},ExpressionUUID->"e0c4af7e-9127-48cd-95b7-\
58f9e3fd9080"],
Cell[BoxData[
RowBox[{
RowBox[{"(*",
RowBox[{"Works", " ", "on", " ", "an", " ", "image"}], "*)"}],
"\[IndentingNewLine]",
RowBox[{
RowBox[{"fromGlobalToRebuild", "[", "image_", "]"}], ":=",
RowBox[{"Block", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{", "}"}], ",", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{"global", " ", "filter"}], "*)"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"globalGauss", "=",
RowBox[{
RowBox[{
RowBox[{"GaussianFilter", "[",
RowBox[{"#", ",", "3"}], "]"}], "&"}], "@", "image"}]}], ";",
"\[IndentingNewLine]",
RowBox[{"globalClean", "=",
RowBox[{
RowBox[{
RowBox[{"DeleteBorderComponents", "@",
RowBox[{"Binarize", "[",
RowBox[{"#", ",", "threshold"}], "]"}]}], "&"}], "@",
"globalGauss"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{"first", " ", "segmentation"}], "*)"}], "\[IndentingNewLine]",
RowBox[{"segments", " ", "=", " ",
RowBox[{"getSegmentData", "@", "globalClean"}]}], ";",
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{
"local", " ", "filtering", " ", "and", " ", "image", " ", "remap"}],
"*)"}], "\[IndentingNewLine]",
RowBox[{"If", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"Length", "@", "segments"}], ">", "0"}], ",",
"\[IndentingNewLine]",
RowBox[{"(", "\[IndentingNewLine]",
RowBox[{
RowBox[{"boxes", " ", "=", " ",
RowBox[{
RowBox[{
RowBox[{"newBox", "@",
RowBox[{"Last", "@",
RowBox[{"Flatten", "[",
RowBox[{"#", ",", "1"}], "]"}]}]}], "&"}], "/@",
"segments"}]}], ";", "\[IndentingNewLine]",
RowBox[{"boxCenters", "=",
RowBox[{"boxCenter", "/@", "boxes"}]}], ";", "\[IndentingNewLine]",
RowBox[{"windows", "=",
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"ImageTrim", "[",
RowBox[{"image", ",", "#"}], "]"}], "&"}], "/@", "boxes"}],
")"}]}], ";", "\[IndentingNewLine]",
RowBox[{"localOut", " ", "=",
RowBox[{"localFilter", "/@", "windows"}]}], ";",
"\[IndentingNewLine]",
RowBox[{"onCanvas", " ", "=",
RowBox[{"MapThread", "[",
RowBox[{
RowBox[{
RowBox[{"ImageCompose", "[",
RowBox[{"blackCanvas", ",", "#1", ",", "#2"}], "]"}], "&"}],
",",
RowBox[{"{",
RowBox[{"localOut", ",", "boxCenters"}], "}"}]}], "]"}]}], ";",
"\[IndentingNewLine]",
RowBox[{"ImageAdd", "[", "onCanvas", "]"}]}], "\[IndentingNewLine]",
")"}], ",", "\[IndentingNewLine]", "blackCanvas"}],
"\[IndentingNewLine]", "]"}]}]}], "\[IndentingNewLine]",
"]"}]}]}]], "Input",
InitializationCell->True,
CellChangeTimes->{{3.844327947132184*^9, 3.844327993532775*^9}, {
3.844328068509672*^9, 3.844328086460628*^9}, {3.844328157287871*^9,
3.844328184029101*^9}, {3.84432922069366*^9, 3.844329406395509*^9}, {
3.844329719343751*^9, 3.844329721361863*^9}, {3.8443299100997*^9,
3.84432995293017*^9}, 3.844330314590372*^9, {3.844331801367824*^9,
3.844331803574844*^9}, 3.8443318887053432`*^9, {3.844344362002143*^9,
3.844344365358268*^9}, {3.8444758321829777`*^9, 3.844475836522172*^9}, {
3.844476636608193*^9, 3.8444766711707363`*^9}, {3.844476717143077*^9,
3.8444767543435793`*^9}, {3.844476793411387*^9, 3.844476847033173*^9}, {
3.8444771700990868`*^9, 3.844477177245574*^9}, {3.844490174909404*^9,
3.844490256357587*^9}, 3.844490286846259*^9, {3.844491932433262*^9,
3.844491936317299*^9}, {3.844510329775901*^9, 3.844510341878995*^9}, {
3.844510792704219*^9, 3.8445108814217663`*^9}, {3.844776207760549*^9,
3.8447762267697268`*^9}, {3.844777025792883*^9, 3.8447770424727173`*^9}, {
3.844950017589574*^9, 3.844950022993186*^9}, 3.8450189935432463`*^9,
3.851165446813231*^9, 3.851165492426255*^9, {3.851410453094966*^9,
3.851410456504076*^9}, {3.851759417778524*^9, 3.8517594794090776`*^9}, {
3.851759538881502*^9, 3.8517596926437902`*^9}, {3.8517597493089457`*^9,
3.851759754264937*^9}, {3.855255811138956*^9, 3.8552558359551687`*^9}, {
3.860047956749874*^9, 3.8600479885549583`*^9}, {3.8600500082357397`*^9,
3.86005001484288*^9}, 3.860052612167486*^9, 3.86224096726058*^9, {
3.8622478875722446`*^9, 3.862247912465518*^9}, {3.862521364309702*^9,
3.862521404975964*^9}, {3.862523989235916*^9, 3.862524016561905*^9}, {
3.862524224913505*^9, 3.862524253563901*^9}, {3.862914735192995*^9,
3.862914751136565*^9}, {3.8629354379696827`*^9, 3.862935445122716*^9}, {
3.862947581637824*^9, 3.862947604896407*^9}, {3.8692992579302692`*^9,
3.8692993041911077`*^9}, {3.8707885015759945`*^9, 3.8707885170346594`*^9}},
CellLabel->"In[47]:=",ExpressionUUID->"a957005f-7f39-4070-9f17-9d0681a6a928"]
}, Open ]]
}, Open ]],
Cell[CellGroupData[{
Cell["Final sequence definition and image processing", "Section",
CellChangeTimes->{{3.8445078246768427`*^9, 3.844507839762246*^9}, {
3.845791585994466*^9, 3.845791594672381*^9}, {3.869298020893303*^9,
3.869298021174493*^9}, {3.869298077133464*^9,
3.869298099808764*^9}},ExpressionUUID->"9fe9be40-4d96-49c8-b592-\
2dd3ed17322d"],
Cell[BoxData[
RowBox[{
RowBox[{"processor", "[", "tiff_", "]"}], ":=",
RowBox[{"Block", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{", "}"}], ",", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{"image", " ", "import"}], "*)"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"subFolder", "=",
RowBox[{"batchDirectory", "<>", "tiff", "<>", "\"\</\>\""}]}], ";",
"\[IndentingNewLine]",
RowBox[{"SetDirectory", "@", "subFolder"}], ";", "\[IndentingNewLine]",
RowBox[{"files", "=",
RowBox[{"FileNames", "[", "]"}]}], ";", "\[IndentingNewLine]",
RowBox[{"lowerLimit", "=", "1"}], ";", "\n",
RowBox[{"upperLimit", "=",
RowBox[{"Length", "@", "files"}]}], ";", "\[IndentingNewLine]", "\n",
RowBox[{"images", "=",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"Import", "[",
RowBox[{
RowBox[{"subFolder", "<>", "#"}], ",",
RowBox[{"IncludeMetaInformation", "\[Rule]", "None"}]}], "]"}],
"&"}], "/@",
RowBox[{"files", "[",
RowBox[{"[",
RowBox[{"lowerLimit", ";;", "upperLimit"}], "]"}], "]"}]}], "//",
"Parallelize"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"Print", "[",
RowBox[{"\"\<images imported \>\"", ",", "timeElapsed"}], "]"}], ";",
"\[IndentingNewLine]",
RowBox[{"Print", "[",
RowBox[{
RowBox[{
RowBox[{"MemoryAvailable", "[", "]"}], "/",
RowBox[{"1024.", "^", "3."}]}], ",", "\"\< GiB\>\""}], "]"}], ";",
"\[IndentingNewLine]", "\n",
RowBox[{
RowBox[{"{",
RowBox[{"widthPixels", ",", "heightPixels"}], "}"}], "=",
RowBox[{
RowBox[{
RowBox[{"#", "@",
RowBox[{"ImageDimensions", "@",
RowBox[{"First", "@", "images"}]}]}], "&"}], "/@",
RowBox[{"{",
RowBox[{"First", ",", "Last"}], "}"}]}]}], ";", "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"blackCanvas", "=",
RowBox[{"Binarize", "[",
RowBox[{
RowBox[{"First", "@", "images"}], ",", " ", "1"}], "]"}]}], ";",
"\[IndentingNewLine]",
RowBox[{"thresholds", "=",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"FindThreshold", "[",
RowBox[{"#", ",",
RowBox[{"Method", "\[Rule]", "\"\<Entropy\>\""}]}], "]"}], "&"}], "/@",
"images"}], "//", "Parallelize"}]}], ";", "\[IndentingNewLine]",
RowBox[{"threshold", "=",
RowBox[{"Mean", "@", "thresholds"}]}], ";", "\n", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{"Image", " ", "processing"}], "*)"}], "\[IndentingNewLine]",
RowBox[{"bubblesFromBase", " ", "=", " ",
RowBox[{
RowBox[{"fromGlobalToRebuild", "/@", "images"}], "//",
"Parallelize"}]}], ";", "\[IndentingNewLine]",
RowBox[{"Print", "[",
RowBox[{"\"\<images processed \>\"", ",", "timeElapsed"}], "]"}], ";",
"\[IndentingNewLine]",
RowBox[{"Print", "[",
RowBox[{
RowBox[{
RowBox[{"MemoryAvailable", "[", "]"}], "/",
RowBox[{"1024.", "^", "3."}]}], ",", "\"\< GiB\>\""}], "]"}], ";",
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{"Mask", " ", "export"}], "*)"}], "\n",
RowBox[{"batchName", "=",
RowBox[{
RowBox[{
RowBox[{"StringReplace", "[",
RowBox[{"#", ",", " ",
RowBox[{"\"\<.\>\"", "\[Rule]", "\"\<\>\""}]}], "]"}], "&"}], "@",
"tiff"}]}], ";", "\[IndentingNewLine]",
RowBox[{"output", "=",
RowBox[{
"nbd", "<>", "\"\<Output/\>\"", "<>", "\"\<masks/\>\"", "<>",
"batchName", "<>", "\"\</\>\""}]}], ";", "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"If", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"DirectoryQ", "@", "output"}], ",", "\[IndentingNewLine]",
"Nothing", ",", "\[IndentingNewLine]",
RowBox[{"output", "//", "CreateDirectory"}]}], "\[IndentingNewLine]",
"]"}], ";", "\n", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"monitorCounter", "=", "0"}], ";", "\[IndentingNewLine]",
RowBox[{"Monitor", "[", "\[IndentingNewLine]",