~versable/elementary-community/variety

« back to all changes in this revision

Viewing changes to variety/CalibrateDominantColors.py

  • Committer: Versable
  • Date: 2013-06-18 11:21:16 UTC
  • Revision ID: versable@gmail.com-20130618112116-1zevbh7bsfxvc7cq
Clean up for merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
import sys
3
 
 
4
 
from DominantColors import DominantColors
5
 
 
6
 
dir = sys.argv[1]
7
 
m = {}
8
 
 
9
 
for f in sorted(os.listdir(dir)):
10
 
    if f.lower().endswith(".jpg") or f.lower().endswith(".jpg"):
11
 
        try:
12
 
            d = DominantColors(os.path.join(dir, f))
13
 
            calc = d.get_dominant_colors()
14
 
            print f, "light:", calc[2]
15
 
            continue
16
 
 
17
 
            for fuzzy in xrange(20):
18
 
                if DominantColors.contains_color(calc, (255, 217, 100), fuzzy):
19
 
                    m[f] = fuzzy
20
 
                    print f, fuzzy
21
 
                    break
22
 
            else:
23
 
                m[f] = -1
24
 
                print f, "no match"
25
 
 
26
 
        except Exception:
27
 
            print "oops for " + f
28
 
            raise
29
 
            #pass
30
 
 
31
 
#print "\n----results----"
32
 
#for fuzzy in xrange(10):
33
 
#    print fuzzy
34
 
#    for k, v in m.items():
35
 
#        if v == fuzzy:
36
 
#            print k
37
 
#
38
 
#print "no match:"
39
 
#for k, v in m.items():
40
 
#    if v == -1:
41
 
#        print k