-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenSIFT4SegImgs.py
39 lines (30 loc) · 2.08 KB
/
genSIFT4SegImgs.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
from optparse import OptionParser
import computeSIFT as cst
"""Imp Note
patchSize: size of the patch in pixels
maxBinValue: maximum descriptor element after L2 normalization. All above are clipped to this value
numOrientationBins: number of orientation bins for histogram
numSpatialBins: number of spatial bins. The final descriptor size is numSpatialBins x numSpatialBins x numOrientationBins
numSpatialBins = 4,3,2 , sift features will be 128, 72, and 32 respectively
numSpatialBins is initialized in numpy_sift
"""
parser = OptionParser()
parser.add_option("-f", "--feature_path", dest="feature_path", help="Path to features file", default="../MetaData/CatsDog/SegFeatures/")
parser.add_option("-c", "--class", dest="class_type", help="image class, could be Cat, Dog, All", default="all")
parser.add_option("-t", "--type", dest="run4", help="run for train, prediction", default="train")
parser.add_option("-i", "--input", dest="input_path", help="Path to input segmented images.", default="../MetaData/CatsDog/SegImgs/")
parser.add_option("-p", "--params", dest="psize_sbins", help="patch size (i.e. image dim) and numSpatialBins.", default="p64b4")
(options, args) = parser.parse_args()
if options.class_type !='all':
imgsAbstPath = options.input_path + options.run4 + "/" + options.class_type + "/" + options.seg_type
ftrsPath = options.feature_path + options.run4 + "/" + options.class_type + "/" + options.seg_type + \
"/sift" + options.class_type + options.seg_type + "_" + options.psize_sbins + ".csv"
cst.compSIFT(imgsAbstPath, ftrsPath, options.psize_sbins)
else:
for run4 in ['train', 'test']:
for class_type in ['cat', 'dog']:
for psize_sbins in ['p32b4', 'p32b3', 'p32b2', 'p64b4', 'p64b3', 'p64b2', 'p128b4', 'p128b3', 'p128b2']:
imgsAbstPath = options.input_path + run4 + "/" + class_type
ftrsPath = options.feature_path + run4 + "/" + class_type + "/"+ "sift" + class_type + "_" + psize_sbins + ".csv"
cst.compSIFT(imgsAbstPath, ftrsPath, psize_sbins)
test =0