-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlass fracture count, export to file.ijm
49 lines (43 loc) · 1.77 KB
/
Glass fracture count, export to file.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
filename = getTitle()
print(filename)
//set output directory
outputdirectory = getDirectory("Choose output folder");
print("Saving to: " +outputdirectory)
//specify minimum size of particles
minval = getNumber("Select minimum particle size", 50);
//print(minval)
//duplicate image and do 8-bit
run("Duplicate...", "title=8bit");
run("8-bit");
//duplicate image
run("Duplicate...", "title=blackbackground and binary");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Invert");
//watershed segmentation
run("Duplicate...", "title=watershed segmentation");
run("Watershed");
//saveAs("tiff", outputdirectory + filename + "_watershed.xls");
//count particles INCLUDING edges
run("Analyze Particles...", "size="+ minval + "-Infinity show=Nothing clear summarize ");
countwithedges = Table.get("Count",0);
print(countwithedges)
//save segmentation image
run("Analyze Particles...", "size="+ minval + "-Infinity show=Outlines clear");
saveAs("tiff", outputdirectory + filename + "_counted with edges.tif");
close();
//count particle count with edges EXLUDED
run("Analyze Particles...", "size="+ minval + "-Infinity show=Nothing exclude clear summarize");
countwithoutedges = Table.get("Count",1);
run("Analyze Particles...", "size="+ minval + "-Infinity show=Outlines exclude clear");
//run("Analyze Particles...", "size=50-Infinity show=Outlines exclude clear summarize");
saveAs("tiff", outputdirectory + filename + "_excluded edges.tif");
close();
//saveAs("results", outputdirectory + filename + "_results");
//save counts
resultpath = outputdirectory + "result.txt";
print("countwithedges: " + countwithedges);
File.append("\n ", resultpath);
File.append("countwithedges: " + countwithedges, resultpath);
File.append("countwithoutedges: " + countwithoutedges, resultpath);
close("*");