Commit 0374d175 authored by Taddeüs Kroes's avatar Taddeüs Kroes

ImProc ass3: Fixed some stuff.

parent ce1e1305
...@@ -10,11 +10,11 @@ def domainIterator(image): ...@@ -10,11 +10,11 @@ def domainIterator(image):
yield x, y yield x, y
def colHist(image, bins, model): def colHist(image, bins, model):
h = zeros(bins) h = zeros(tuple(bins))
image *= bins image *= list(bins)
if model == 'rgb': if model == 'rgb':
image /= 255 image /= 255.
elif model == 'rgba': elif model == 'rgba':
pass pass
...@@ -37,20 +37,15 @@ def histogramIntersect(h1, h2): ...@@ -37,20 +37,15 @@ def histogramIntersect(h1, h2):
return match / h2.sum() return match / h2.sum()
# Create table of intersections # Create table of intersections
if __name__ == '__main': if __name__ == '__main__':
bins = [8] * 3 bins = [8] * 3
print 'Reading images...'
db = map(lambda x: imread('database/%d.jpg' % x), range(1, 3)) db = map(lambda x: imread('database/%d.jpg' % x), range(1, 3))
print 'done'
table = zeros((len(db), len(db))) table = zeros((len(db), len(db)))
for i, im1 in enumerate(db): for i, im in enumerate(db):
print i for j in xrange(i + 1, len(db)):
for j, im2 in enumerate(db): print 'comparing', i, j
print j table[i, j] = histogramIntersect(colHist(im, bins, 'rgb'),
if i != j: colHist(db[j], bins, 'rgb'))
print i, j
table[i, j] = histogramIntersect(colHist(im1, bins, 'rgb'),
colHist(im2, bins, 'rgb'))
print table print table
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment