train-metrics.py
1.24 KB
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
import sys, string, os, subprocess
os.system("cls")
infile = sys.argv[1]
A = "supervised-class/class_coll.png "
B = "supervised-class/class_epith.png "
C = "supervised-class/class_fibro.png "
D = "supervised-class/class_lymph.png "
E = "supervised-class/class_myo.png "
F = "supervised-class/class_necrosis.png "
G = "supervised-class/class_blood.png "
Ca = "magenta "
Cb = "lime "
Cc = "pink "
Cd = "purple "
Ce = "yellow "
Cf = "orange "
Cg = "maroon "
#project to metrics
subprocess.call("hsiproc " + infile + " " + infile + "-met --metrics metrics.txt")
#create a mask to remove bad pixels
subprocess.call("hsiproc " + infile + "-met " + "finite.bmp --mask-finite")
subprocess.call("hsiproc " + infile + "-met " + infile + "-mask --apply-mask finite.bmp")
#Baseline correction using a set of wavenumber points specified in baseline.txt
subprocess.call("hsiclass " + infile + "-mask classifier.rf --train " + A + B + C + D + E + F + G + "--verbose")
#convert to BIP for speed
subprocess.call("hsiproc " + infile + "-mask " + infile + "-bip --convert bip")
#classify the entire image
subprocess.call("hsiclass " + infile + "-bip " + infile + "-class.bmp " + "--classify classifier.rf --colors " + Ca + Cb + Cc + Cd + Ce + Cf + Cg + "--mask mask.bmp --verbose")