forked from sightmachine/SimpleCV
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOFTester.py
More file actions
22 lines (22 loc) · 740 Bytes
/
Copy pathBOFTester.py
File metadata and controls
22 lines (22 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from SimpleCV import *
from numpy import *
from SimpleCV.Features import BOFFeatureExtractor
import os
import glob
import time
cat_path = "./data/cat/truth/"
cheeseburger_path = "./data/cheeseburger/truth/"
paths = [cat_path,cheeseburger_path]
bof = BOFFeatureExtractor()
#bof.load('cbdata.txt')
bof.generate(paths,imgs_per_dir=200,numcodes=256,sz=(11,11),img_layout=(16,16),padding=4 )
bof.save("codebook.png","cbdata.txt")
#count = 0
#test = bof.reconstruct(Image("codebook.png"))
#test.save("anticodebook.jpg")
#for infile in glob.glob( os.path.join(cat_path, '*.jpg') ):
# print "opening file: " + infile
# img = Image(infile)
# oimg = bof.reconstruct(img)
# fname = infile[0:-4]+"_reconstruction.png"
# oimg.save(fname)