-
Notifications
You must be signed in to change notification settings - Fork 0
/
mask_3D_image.ijm
65 lines (38 loc) · 1.16 KB
/
mask_3D_image.ijm
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
dirRaw = getDirectory("Choose a Directory ALL");
listRaw = getFileList(dirRaw);
n1 = lengthOf(listRaw);
dirSave = getDirectory("Choose a Directory SAVE");
//---------------------------------
crop_n_mask();
//---------------------------------
function crop_n_mask(){
setBatchMode(true);
for (i=0; i<n1; i++) {
pathRaw = dirRaw+listRaw[i];
open(pathRaw);
//split channels and close C2
selectedFile = getTitle();
run("Split Channels");
channel1 = "C1"+"-"+selectedFile;
channel2 = "C2"+"-"+selectedFile;
selectImage(channel2);
close;
//pri-processing
selectImage(channel1);
run("Kuwahara Filter", "sampling=7 stack");
run("Variance...", "radius=10 stack");
setAutoThreshold("Li dark stack");
run("Convert to Mask", "method=Li background=Dark black");
//pixel operations
run("Fill Holes", "stack");
run("Analyze Particles...", "size=100-Infinity show=Masks stack");
run("Invert LUT");
run("Options...", "iterations=4 count=1 black do=Dilate stack");
run("Fill Holes", "stack");
close("\\Others");
selectedFile = replace(selectedFile, ".tif", "");
saveAs("Tiff", dirSave + selectedFile + "_mask");
close("*");
setBatchMode("False");
}
}