-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMy_Batch_Convert_Volume.txt
80 lines (42 loc) · 1.63 KB
/
My_Batch_Convert_Volume.txt
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
//format = getFormat();
tempDir = getDirectory("Choose Temporal Directory ");
outputDir = getDirectory("Choose Results Directory ");
if (nSlices==1) exit("Stack required");
scaleX = 0.5;
scaleY = 0.5;
scaleZ = 0.5;
slices = nSlices;
setBatchMode(true);
width = getWidth();
height = getHeight();
depth = slices;
id = getImageID;
for (i=1; i<= slices; i++) {
showProgress(i, slices);
selectImage(id);
setSlice(i);
run("Duplicate...", "title=temp");
run("Scale...", "x=" + toString(scaleX) + " y=" + toString(scaleY) + " interpolate create title=Scaled");
//run("16-bit");
saveAs("tif", tempDir + pad(i-1, 4));
close();
selectWindow("temp");
close();
}
run("Image Sequence...", "open=" + tempDir + "\\0000.tif number=" + toString(slices) + " starting=1 increment=1 scale=100 file=[] or=[] sort");
//run("Scale...", "x=1.0 y=1.0 z=" + toString(scaleZ) + " interpolate create title=Scaled");
width = width * scaleX;
height = height * scaleY;
depth = depth * scaleZ;
run("Scale...", "x=1.0 y=1.0 z=" + toString(scaleZ) + " width=" + toString(width) + " height=" + toString(height) + " depth=" + toString(depth) + " interpolation=Bilinear process create title=volume");
selectWindow("volume");
run("Image Sequence... ", "format=TIFF name=res_ start=0 digits=4 save=" + outputDir + "res_0000.tif save=" + outputDir + "res_0000.tif");
close();
//run("Close All Without Saving");
showMessage("Finished");
function pad(n, length) {
str = toString(n);
while (lengthOf(str)<length)
str = "0" + str;
return str;
}