/
Binarize_1.py
72 lines (50 loc) · 1.65 KB
/
Binarize_1.py
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
from ij import IJ, Prefs
from ij.plugin.filter import BackgroundSubtracter
Prefs.blackBackground = True
imp = IJ.getImage()
binimp = imp.duplicate()
bs = BackgroundSubtracter()
ip = binimp.getProcessor()
bs.rollingBallBackground(ip, 15, False, False, False, True, True)
IJ.run(binimp, "Unsharp Mask...", "radius=2 mask=0.9")
def smooth(n=1):
for i in range(n):
IJ.run(binimp, "Smooth", "")
smooth(10)
Prefs.blackBackground = True
IJ.setAutoThreshold(binimp, "Moments dark")
IJ.run(binimp, "Make Binary", "thresholded remaining")
smooth(12)
IJ.run(binimp, "Unsharp Mask...", "radius=2 mask=0.9")
IJ.setAutoThreshold(binimp, "Moments white")
IJ.run(binimp, "Make Binary", "thresholded remaining")
IJ.run(binimp, "Erode", "")
IJ.run(binimp, "Dilate", "")
binimp.show()
IJ.run(binimp, "Analyze Particles...", "size=300-Infinity circularity=0.65-1.00 exclude clear add")
"""
IJ.run(binimp, "Erode", "")
binimp.show()
IJ.run(binimp, "Analyze Particles...", "size=320-Infinity circularity=0.7-1.00 exclude clear add")
"""
"""
IJ.run(binimp, "Make Binary", "thresholded remaining")
smooth(10)
IJ.setAutoThreshold(binimp, "Moments dark")
IJ.run(binimp, "Make Binary", "thresholded remaining")
"""
"""
IJ.setAutoThreshold(binimp, "Moments dark")
IJ.run(binimp, "Make Binary", "thresholded remaining")
# Prefs.blackBackground = True
# IJ.setAutoThreshold(binimp, "Otsu dark")
# IJ.run(binimp, "Make Binary", "thresholded remaining")
"""
"""
EDM().toWatershed(binimp.getProcessor())
"""
"""
smooth(20)
IJ.setAutoThreshold(binimp, "Otsu dark")
# IJ.run(imp, "Watershed", "")
# IJ.run(imp, "Analyze Particles...", "size=350-Infinity circularity=0.7-1.00 exclude clear add")